Bug 113331 - Web Inspector: Encapsulate SetEmbedderData/GetEmbedderData
Summary: Web Inspector: Encapsulate SetEmbedderData/GetEmbedderData
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-26 12:07 PDT by johnjbarton
Modified: 2013-04-02 11:34 PDT (History)
13 users (show)

See Also:


Attachments
Patch (7.26 KB, patch)
2013-03-26 12:14 PDT, johnjbarton
no flags Details | Formatted Diff | Diff
Fix 2/2 issues from review in comment #2 (7.05 KB, patch)
2013-04-01 10:50 PDT, johnjbarton
no flags Details | Formatted Diff | Diff
Fix 1/1 issue from review in comment #4 (6.77 KB, patch)
2013-04-02 09:22 PDT, johnjbarton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description johnjbarton 2013-03-26 12:07:35 PDT
We currently have two different sets of V8 embedder data.

1) V8PerContextData. This data is stored as a pointer on the context via SetAlignedPointerInEmbedderData.

2) A string like "page,232", stored on the context via SetEmbedderData, and used by the Inspector support binding code.

Confusingly both systems index into the *same array* on the Context. Thus if you search the code base for SetEmbedderData it will appear that only index 0 is used.  Using index 1 or 2 in SetEmbedder data leads to mysterious crashes, because in fact these indexes are used by the V8PerContextData and friends.

The overall system would be less confusing and fragile of all uses this underlying array where together. 

(Using the V8PerContextData to store the Inspector value could be an extra step, but mixing the two kinds of data would be more confusing in my opinion).

Patch ready.
Comment 1 johnjbarton 2013-03-26 12:14:47 PDT
Created attachment 195137 [details]
Patch
Comment 2 Pavel Feldman 2013-03-30 02:11:45 PDT
Comment on attachment 195137 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=195137&action=review

> Source/WebCore/bindings/v8/V8PerContextData.cpp:175
> +            wanted = snprintf(buffer, sizeof(buffer), "%s", worldName);

So you formatted the format above, but you don't actually need it here? Why formatting the format at all then? I.e. 
if (debugId == -1)
    snprintf(buffer, sizeof(buffer), "%s", worldName);
else
    snprintf(buffer, sizeof(buffer), "%s,%d", worldName, debugId);

sounds simpler.

> Source/WebCore/bindings/v8/V8PerContextData.cpp:185
> +v8::Handle<v8::Value> V8PerContextDebugData::getDebugData(v8::Handle<v8::Context> context)

No get prefixes in WebKit, simply debugData()
Comment 3 johnjbarton 2013-04-01 10:50:36 PDT
Created attachment 195992 [details]
Fix 2/2 issues from review in comment #2
Comment 4 Adam Barth 2013-04-01 22:50:50 PDT
Comment on attachment 195992 [details]
Fix 2/2 issues from review in comment #2

View in context: https://bugs.webkit.org/attachment.cgi?id=195992&action=review

> Source/WebCore/bindings/v8/V8PerContextData.h:143
> +    static v8::Handle<v8::Value> createDebugData(const char* worldName, int debugId);
> +    static v8::Handle<v8::Value> debugData(v8::Handle<v8::Context>);
> +    static void setDebugData(v8::Handle<v8::Context>, v8::Handle<v8::Value>);

These can be file-level statics and don't need to be declared in the header file.
Comment 5 Pavel Feldman 2013-04-02 07:23:26 PDT
Comment on attachment 195992 [details]
Fix 2/2 issues from review in comment #2

Looks good given Adam's comment is fixed. Clearing r?.
Comment 6 johnjbarton 2013-04-02 09:22:41 PDT
Created attachment 196159 [details]
Fix 1/1 issue from review in comment #4
Comment 7 WebKit Review Bot 2013-04-02 11:34:05 PDT
Comment on attachment 196159 [details]
Fix 1/1 issue from review in comment #4

Clearing flags on attachment: 196159

Committed r147475: <http://trac.webkit.org/changeset/147475>
Comment 8 WebKit Review Bot 2013-04-02 11:34:09 PDT
All reviewed patches have been landed.  Closing bug.