| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/page/Settings.h" | 37 #include "core/page/Settings.h" |
| 38 #include "core/workers/WorkerGlobalScope.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" | |
| 46 #include "wtf/text/WTFString.h" | |
| 47 | 45 |
| 48 namespace WebCore { | 46 namespace WebCore { |
| 49 | 47 |
| 50 static const char webSocketChannelMode[] = "webSocketChannelMode"; | 48 static const char webSocketChannelMode[] = "webSocketChannelMode"; |
| 51 | 49 |
| 52 PassRefPtr<WebSocketChannel> WebSocketChannel::create(ExecutionContext* context,
WebSocketChannelClient* client) | 50 PassRefPtr<WebSocketChannel> WebSocketChannel::create(ExecutionContext* context,
WebSocketChannelClient* client) |
| 53 { | 51 { |
| 54 ASSERT(context); | 52 ASSERT(context); |
| 55 ASSERT(client); | 53 ASSERT(client); |
| 56 | 54 |
| 57 if (context->isWorkerGlobalScope()) { | 55 if (context->isWorkerGlobalScope()) { |
| 58 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 56 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
| 59 WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop(); | 57 WorkerRunLoop& runLoop = workerGlobalScope->thread()->runLoop(); |
| 60 String mode = webSocketChannelMode; | 58 String mode = webSocketChannelMode; |
| 61 mode.append(String::number(runLoop.createUniqueId())); | 59 mode.append(String::number(runLoop.createUniqueId())); |
| 62 return WorkerThreadableWebSocketChannel::create(workerGlobalScope, clien
t, mode); | 60 return WorkerThreadableWebSocketChannel::create(workerGlobalScope, clien
t, mode); |
| 63 } | 61 } |
| 64 | 62 |
| 65 Document* document = toDocument(context); | 63 Document* document = toDocument(context); |
| 66 Settings* settings = document->settings(); | 64 Settings* settings = document->settings(); |
| 67 if (settings && settings->experimentalWebSocketEnabled()) { | 65 if (settings && settings->experimentalWebSocketEnabled()) { |
| 68 // FIXME: Create and return an "experimental" WebSocketChannel instead o
f a MainThreadWebSocketChannel. | 66 // FIXME: Create and return an "experimental" WebSocketChannel instead o
f a MainThreadWebSocketChannel. |
| 69 return MainThreadWebSocketChannel::create(document, client); | 67 return MainThreadWebSocketChannel::create(document, client); |
| 70 } | 68 } |
| 71 return MainThreadWebSocketChannel::create(document, client); | 69 return MainThreadWebSocketChannel::create(document, client); |
| 72 } | 70 } |
| 73 | 71 |
| 74 } // namespace WebCore | 72 } // namespace WebCore |
| OLD | NEW |