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 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "modules/websockets/WebSocketChannel.h" | 33 #include "modules/websockets/WebSocketChannel.h" |
34 | 34 |
35 #include "bindings/core/v8/ScriptCallStackFactory.h" | 35 #include "bindings/core/v8/ScriptCallStackFactory.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
38 #include "core/inspector/ScriptCallStack.h" | 38 #include "core/inspector/ScriptCallStack.h" |
39 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
40 #include "core/workers/WorkerThread.h" | 40 #include "core/workers/WorkerThread.h" |
41 #include "modules/websockets/MainThreadWebSocketChannel.h" | |
42 #include "modules/websockets/NewWebSocketChannelImpl.h" | 41 #include "modules/websockets/NewWebSocketChannelImpl.h" |
43 #include "modules/websockets/WebSocketChannelClient.h" | 42 #include "modules/websockets/WebSocketChannelClient.h" |
44 #include "modules/websockets/WorkerThreadableWebSocketChannel.h" | 43 #include "modules/websockets/WorkerThreadableWebSocketChannel.h" |
45 #include "platform/RuntimeEnabledFeatures.h" | |
46 | 44 |
47 namespace blink { | 45 namespace blink { |
48 | 46 |
49 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC
hannelClient* client) | 47 WebSocketChannel* WebSocketChannel::create(ExecutionContext* context, WebSocketC
hannelClient* client) |
50 { | 48 { |
51 ASSERT(context); | 49 ASSERT(context); |
52 ASSERT(client); | 50 ASSERT(client); |
53 | 51 |
54 String sourceURL; | 52 String sourceURL; |
55 unsigned lineNumber = 0; | 53 unsigned lineNumber = 0; |
56 RefPtrWillBeRawPtr<ScriptCallStack> callStack = createScriptCallStack(1, tru
e); | 54 RefPtrWillBeRawPtr<ScriptCallStack> callStack = createScriptCallStack(1, tru
e); |
57 if (callStack && callStack->size()) { | 55 if (callStack && callStack->size()) { |
58 sourceURL = callStack->at(0).sourceURL(); | 56 sourceURL = callStack->at(0).sourceURL(); |
59 lineNumber = callStack->at(0).lineNumber(); | 57 lineNumber = callStack->at(0).lineNumber(); |
60 } | 58 } |
61 | 59 |
62 if (context->isWorkerGlobalScope()) { | 60 if (context->isWorkerGlobalScope()) { |
63 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 61 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
64 return WorkerThreadableWebSocketChannel::create(*workerGlobalScope, clie
nt, sourceURL, lineNumber); | 62 return WorkerThreadableWebSocketChannel::create(*workerGlobalScope, clie
nt, sourceURL, lineNumber); |
65 } | 63 } |
66 | 64 |
67 Document* document = toDocument(context); | 65 Document* document = toDocument(context); |
68 if (RuntimeEnabledFeatures::experimentalWebSocketEnabled()) { | 66 return NewWebSocketChannelImpl::create(document, client, sourceURL, lineNumb
er); |
69 return NewWebSocketChannelImpl::create(document, client, sourceURL, line
Number); | |
70 } | |
71 return MainThreadWebSocketChannel::create(document, client, sourceURL, lineN
umber); | |
72 } | 67 } |
73 | 68 |
74 } // namespace blink | 69 } // namespace blink |
OLD | NEW |