| 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 17 matching lines...) Expand all Loading... |
| 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 "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "modules/websockets/WebSocketChannel.h" | 33 #include "modules/websockets/WebSocketChannel.h" |
| 34 | 34 |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/ScriptExecutionContext.h" | 36 #include "core/dom/ScriptExecutionContext.h" |
| 37 #include "core/page/Settings.h" | 37 #include "core/page/Settings.h" |
| 38 #include "core/workers/WorkerContext.h" | 38 #include "core/workers/WorkerGlobalScope.h" |
| 39 #include "core/workers/WorkerRunLoop.h" | 39 #include "core/workers/WorkerRunLoop.h" |
| 40 #include "core/workers/WorkerThread.h" | 40 #include "core/workers/WorkerThread.h" |
| 41 #include "modules/websockets/MainThreadWebSocketChannel.h" | 41 #include "modules/websockets/MainThreadWebSocketChannel.h" |
| 42 #include "modules/websockets/ThreadableWebSocketChannelClientWrapper.h" | 42 #include "modules/websockets/ThreadableWebSocketChannelClientWrapper.h" |
| 43 #include "modules/websockets/WebSocketChannelClient.h" | 43 #include "modules/websockets/WebSocketChannelClient.h" |
| 44 #include "modules/websockets/WorkerThreadableWebSocketChannel.h" | 44 #include "modules/websockets/WorkerThreadableWebSocketChannel.h" |
| 45 #include "wtf/PassRefPtr.h" | 45 #include "wtf/PassRefPtr.h" |
| 46 #include "wtf/text/WTFString.h" | 46 #include "wtf/text/WTFString.h" |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 static const char webSocketChannelMode[] = "webSocketChannelMode"; | 50 static const char webSocketChannelMode[] = "webSocketChannelMode"; |
| 51 | 51 |
| 52 PassRefPtr<WebSocketChannel> WebSocketChannel::create(ScriptExecutionContext* co
ntext, WebSocketChannelClient* client) | 52 PassRefPtr<WebSocketChannel> WebSocketChannel::create(ScriptExecutionContext* co
ntext, WebSocketChannelClient* client) |
| 53 { | 53 { |
| 54 ASSERT(context); | 54 ASSERT(context); |
| 55 ASSERT(client); | 55 ASSERT(client); |
| 56 | 56 |
| 57 if (context->isWorkerContext()) { | 57 if (context->isWorkerGlobalScope()) { |
| 58 WorkerContext* workerContext = static_cast<WorkerContext*>(context); | 58 WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(c
ontext); |
| 59 WorkerRunLoop& runLoop = workerContext->thread()->runLoop(); | 59 WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop(); |
| 60 String mode = webSocketChannelMode; | 60 String mode = webSocketChannelMode; |
| 61 mode.append(String::number(runLoop.createUniqueId())); | 61 mode.append(String::number(runLoop.createUniqueId())); |
| 62 return WorkerThreadableWebSocketChannel::create(workerContext, client, m
ode); | 62 return WorkerThreadableWebSocketChannel::create(workerGlobalScope, clien
t, mode); |
| 63 } | 63 } |
| 64 | 64 |
| 65 Document* document = toDocument(context); | 65 Document* document = toDocument(context); |
| 66 Settings* settings = document->settings(); | 66 Settings* settings = document->settings(); |
| 67 if (settings && settings->experimentalWebSocketEnabled()) { | 67 if (settings && settings->experimentalWebSocketEnabled()) { |
| 68 // FIXME: Create and return an "experimental" WebSocketChannel instead o
f a MainThreadWebSocketChannel. | 68 // FIXME: Create and return an "experimental" WebSocketChannel instead o
f a MainThreadWebSocketChannel. |
| 69 return MainThreadWebSocketChannel::create(document, client); | 69 return MainThreadWebSocketChannel::create(document, client); |
| 70 } | 70 } |
| 71 return MainThreadWebSocketChannel::create(document, client); | 71 return MainThreadWebSocketChannel::create(document, client); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace WebCore | 74 } // namespace WebCore |
| OLD | NEW |