OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "modules/websockets/WebSocketChannel.h" | 31 #include "modules/websockets/WebSocketChannel.h" |
32 | 32 |
33 #include "bindings/core/v8/ScriptCallStack.h" | 33 #include "bindings/core/v8/ScriptCallStack.h" |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
36 #include "core/workers/WorkerGlobalScope.h" | 36 #include "core/workers/WorkerGlobalScope.h" |
37 #include "core/workers/WorkerThread.h" | |
38 #include "modules/websockets/DocumentWebSocketChannel.h" | 37 #include "modules/websockets/DocumentWebSocketChannel.h" |
39 #include "modules/websockets/WebSocketChannelClient.h" | 38 #include "modules/websockets/WebSocketChannelClient.h" |
40 #include "modules/websockets/WorkerWebSocketChannel.h" | 39 #include "modules/websockets/WorkerWebSocketChannel.h" |
41 | 40 |
42 namespace blink { | 41 namespace blink { |
43 | 42 |
44 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC
hannelClient* client) | 43 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC
hannelClient* client) |
45 { | 44 { |
46 ASSERT(context); | 45 ASSERT(context); |
47 ASSERT(client); | 46 ASSERT(client); |
48 | 47 |
49 String sourceURL; | 48 String sourceURL; |
50 unsigned lineNumber = 0; | 49 unsigned lineNumber = 0; |
51 RefPtr<ScriptCallStack> callStack = ScriptCallStack::capture(1); | 50 RefPtr<ScriptCallStack> callStack = ScriptCallStack::capture(1); |
52 if (callStack && !callStack->isEmpty()) { | 51 if (callStack && !callStack->isEmpty()) { |
53 sourceURL = callStack->topSourceURL(); | 52 sourceURL = callStack->topSourceURL(); |
54 lineNumber = callStack->topLineNumber(); | 53 lineNumber = callStack->topLineNumber(); |
55 } | 54 } |
56 | 55 |
57 if (context->isWorkerGlobalScope()) { | 56 if (context->isWorkerGlobalScope()) { |
58 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 57 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
59 return WorkerWebSocketChannel::create(*workerGlobalScope, client, source
URL, lineNumber); | 58 return WorkerWebSocketChannel::create(*workerGlobalScope, client, source
URL, lineNumber); |
60 } | 59 } |
61 | 60 |
62 Document* document = toDocument(context); | 61 Document* document = toDocument(context); |
63 return DocumentWebSocketChannel::create(document, client, sourceURL, lineNum
ber); | 62 return DocumentWebSocketChannel::create(document, client, sourceURL, lineNum
ber); |
64 } | 63 } |
65 | 64 |
66 } // namespace blink | 65 } // namespace blink |
OLD | NEW |