Bug 105279 - Web Inspector: Document* should be used directly in WebSocket Instrumentation
Summary: Web Inspector: Document* should be used directly in WebSocket Instrumentation
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: 2012-12-18 04:54 PST by pdeng6
Modified: 2012-12-19 07:44 PST (History)
10 users (show)

See Also:


Attachments
Patch (5.95 KB, patch)
2012-12-18 05:04 PST, pdeng6
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pdeng6 2012-12-18 04:54:48 PST
In inspectorInstrumentation.h,
first arg of some WebSocket instrumentation functions are ScriptExecutionContext, (didCreateWebSocket, willSendWebSocketHandshakeRequest, didReceiveWebSocketHandshakeResponse, didCloseWebSocket), however they are all feed with Document* in their client (WebSocketChannel.cpp) accurately, and handled as Document* again in instrumentingAgentsForContext(). 
in addition, if Document* is adopted as arg, more info can be accessed, frame info for example.
Comment 1 pdeng6 2012-12-18 05:04:42 PST
Created attachment 179924 [details]
Patch
Comment 2 Pavel Feldman 2012-12-18 05:19:13 PST
What about web sockets in web workers?
Comment 3 pdeng6 2012-12-18 21:20:15 PST
(In reply to comment #2)
> What about web sockets in web workers?
Nice consideration, thanks a lot for your comments :)
Actually, "WebSocketChannel" is the backend of "WorkerThreadableWebSocketChannel", and  ScriptExecutionContext* in the former class is always a Document* rather than WorkerContext* (even when play as a backend of worker)

add Toyoshima-san to review it.

thanks
Pan
Comment 4 Takashi Toyoshima 2012-12-19 05:08:09 PST
(In reply to comment #3)
> Actually, "WebSocketChannel" is the backend of "WorkerThreadableWebSocketChannel", and  ScriptExecutionContext* in the former class is always a Document* rather than WorkerContext* (even when play as a backend of worker)

Right. In the case of Workers, WebSocket objects in the workers have proxy objects in the main thread respectively. The proxy objects always own WebSocketChannel which has Document object as a ScriptExecutionContext.

AFAIK, Inspector code exists in this WebSocketChannel. So, Document object is always available for these interfaces.
Comment 5 Takashi Toyoshima 2012-12-19 05:12:21 PST
By the way, currently DevTools doesn't handle WebSocket objects in SharedWorkers and (dedicated) Workers seemingly, right?
Also DevTools for Workers doesn't contain Network tab for now. I guess WebSocket is the only object which uses networking in Workers now.
Comment 6 Takashi Toyoshima 2012-12-19 05:21:02 PST
(In reply to comment #5)
> By the way, currently DevTools doesn't handle WebSocket objects in SharedWorkers and (dedicated) Workers seemingly, right?
> Also DevTools for Workers doesn't contain Network tab for now. I guess WebSocket is the only object which uses networking in Workers now.

https://bugs.webkit.org/show_bug.cgi?id=105419
I filed a bug though I don't have time to work on this for now.
Comment 7 Pavel Feldman 2012-12-19 05:44:36 PST
> Right. In the case of Workers, WebSocket objects in the workers have proxy objects in the main thread respectively. The proxy objects always own WebSocketChannel which has Document object as a ScriptExecutionContext.

So you are saying that having main thread in the tight loop will prevent workers from dispatching the data? Is this a short term thing or will it be so long term?
Comment 8 Takashi Toyoshima 2012-12-19 06:13:04 PST
(In reply to comment #7)
> So you are saying that having main thread in the tight loop will prevent workers from dispatching the data? Is this a short term thing or will it be so long term?

Yes. We have no plan to change this design.
In the design was not changed, Chrome port handles all network requests in an IO thread in a browser process. So, distributing requests from workers to threads looks very difficult and could be essential change.

http://www.chromium.org/developers/design-documents/multi-process-resource-loading
Comment 9 Takashi Toyoshima 2012-12-19 06:14:04 PST
(In reply to comment #8)
> In the design was not changed,

Sorry, it means 'If the design was not changed,'
Comment 10 WebKit Review Bot 2012-12-19 07:44:23 PST
Comment on attachment 179924 [details]
Patch

Clearing flags on attachment: 179924

Committed r138163: <http://trac.webkit.org/changeset/138163>
Comment 11 WebKit Review Bot 2012-12-19 07:44:27 PST
All reviewed patches have been landed.  Closing bug.