Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: Source/modules/websockets/WebSocketChannel.cpp

Issue 17648006: Rename WorkerContext to WorkerGlobalScope (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocket.idl ('k') | Source/modules/websockets/WorkerContextWebSocket.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698