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

Side by Side Diff: Source/core/workers/WorkerMessagingProxy.cpp

Issue 474683003: Not for review - Rebase of crrev.com/62833003 Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 6 years, 1 month 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
« no previous file with comments | « Source/core/workers/Worker.cpp ('k') | Source/core/workers/WorkerObjectProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 24 matching lines...) Expand all
35 #include "core/events/MessageEvent.h" 35 #include "core/events/MessageEvent.h"
36 #include "core/frame/Console.h" 36 #include "core/frame/Console.h"
37 #include "core/frame/FrameConsole.h" 37 #include "core/frame/FrameConsole.h"
38 #include "core/frame/LocalDOMWindow.h" 38 #include "core/frame/LocalDOMWindow.h"
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/frame/csp/ContentSecurityPolicy.h" 40 #include "core/frame/csp/ContentSecurityPolicy.h"
41 #include "core/inspector/ScriptCallStack.h" 41 #include "core/inspector/ScriptCallStack.h"
42 #include "core/inspector/WorkerDebuggerAgent.h" 42 #include "core/inspector/WorkerDebuggerAgent.h"
43 #include "core/loader/DocumentLoadTiming.h" 43 #include "core/loader/DocumentLoadTiming.h"
44 #include "core/loader/DocumentLoader.h" 44 #include "core/loader/DocumentLoader.h"
45 #include "core/page/Chrome.h"
46 #include "core/page/ChromeClient.h"
47 #include "core/page/Page.h"
45 #include "core/workers/DedicatedWorkerGlobalScope.h" 48 #include "core/workers/DedicatedWorkerGlobalScope.h"
46 #include "core/workers/DedicatedWorkerThread.h" 49 #include "core/workers/DedicatedWorkerThread.h"
50 #include "core/workers/UIWorkerThread.h"
47 #include "core/workers/Worker.h" 51 #include "core/workers/Worker.h"
48 #include "core/workers/WorkerClients.h" 52 #include "core/workers/WorkerClients.h"
49 #include "core/workers/WorkerInspectorProxy.h" 53 #include "core/workers/WorkerInspectorProxy.h"
50 #include "core/workers/WorkerObjectProxy.h" 54 #include "core/workers/WorkerObjectProxy.h"
51 #include "core/workers/WorkerThreadStartupData.h" 55 #include "core/workers/WorkerThreadStartupData.h"
56 #include "platform/TraceEvent.h"
52 #include "platform/heap/Handle.h" 57 #include "platform/heap/Handle.h"
53 #include "wtf/Functional.h" 58 #include "wtf/Functional.h"
54 #include "wtf/MainThread.h" 59 #include "wtf/MainThread.h"
55 60
56 namespace blink { 61 namespace blink {
57 62
58 class MessageWorkerGlobalScopeTask : public ExecutionContextTask { 63 class MessageWorkerGlobalScopeTask : public ExecutionContextTask {
59 public: 64 public:
60 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) 65 static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<Serialized ScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
61 { 66 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 106
102 WorkerMessagingProxy::~WorkerMessagingProxy() 107 WorkerMessagingProxy::~WorkerMessagingProxy()
103 { 108 {
104 ASSERT(!m_workerObject); 109 ASSERT(!m_workerObject);
105 ASSERT((m_executionContext->isDocument() && isMainThread()) 110 ASSERT((m_executionContext->isDocument() && isMainThread())
106 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e xecutionContext.get())->thread()->isCurrentThread())); 111 || (m_executionContext->isWorkerGlobalScope() && toWorkerGlobalScope(m_e xecutionContext.get())->thread()->isCurrentThread()));
107 } 112 }
108 113
109 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S tring& userAgent, const String& sourceCode, WorkerThreadStartMode startMode) 114 void WorkerMessagingProxy::startWorkerGlobalScope(const KURL& scriptURL, const S tring& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
110 { 115 {
116 TRACE_EVENT0("teleport", "WorkerMessagingProxy::startWorkerGlobalScope");
111 // FIXME: This need to be revisited when we support nested worker one day 117 // FIXME: This need to be revisited when we support nested worker one day
112 ASSERT(m_executionContext->isDocument()); 118 ASSERT(m_executionContext->isDocument());
113 if (m_askedToTerminate) { 119 if (m_askedToTerminate) {
114 // Worker.terminate() could be called from JS before the thread was crea ted. 120 // Worker.terminate() could be called from JS before the thread was crea ted.
115 return; 121 return;
116 } 122 }
117 Document* document = toDocument(m_executionContext.get()); 123 Document* document = toDocument(m_executionContext.get());
118 SecurityOrigin* starterOrigin = document->securityOrigin(); 124 SecurityOrigin* starterOrigin = document->securityOrigin();
119 125
120 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecu rityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedH eaderType(), starterOrigin, m_workerClients.release()); 126 OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartu pData::create(scriptURL, userAgent, sourceCode, startMode, document->contentSecu rityPolicy()->deprecatedHeader(), document->contentSecurityPolicy()->deprecatedH eaderType(), starterOrigin, m_workerClients.release());
127 startupData->m_compositorId = document->page()->chrome().client().compositor Id();
121 double originTime = document->loader() ? document->loader()->timing()->refer enceMonotonicTime() : monotonicallyIncreasingTime(); 128 double originTime = document->loader() ? document->loader()->timing()->refer enceMonotonicTime() : monotonicallyIncreasingTime();
122 129
123 RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(*this, *m_workerObjectProxy.get(), originTime, startupData.release()); 130 RefPtr<DedicatedWorkerThread> thread;
131 if (m_workerObject->isUIWorker())
132 thread = UIWorkerThread::create(*this, *m_workerObjectProxy.get(), origi nTime, startupData.release());
133 else
134 thread = DedicatedWorkerThread::create(*this, *m_workerObjectProxy.get() , originTime, startupData.release());
135
124 thread->start(); 136 thread->start();
125 workerThreadCreated(thread); 137 workerThreadCreated(thread);
126 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work erThread.get(), scriptURL); 138 m_workerInspectorProxy->workerThreadCreated(m_executionContext.get(), m_work erThread.get(), scriptURL);
127 } 139 }
128 140
129 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript Value> message, PassOwnPtr<MessagePortChannelArray> channels) 141 void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScript Value> message, PassOwnPtr<MessagePortChannelArray> channels)
130 { 142 {
131 if (!m_workerObject || m_askedToTerminate) 143 if (!m_workerObject || m_askedToTerminate)
132 return; 144 return;
133 145
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 297
286 // FIXME: This need to be revisited when we support nested worker one day 298 // FIXME: This need to be revisited when we support nested worker one day
287 ASSERT(m_executionContext->isDocument()); 299 ASSERT(m_executionContext->isDocument());
288 Document* document = toDocument(m_executionContext.get()); 300 Document* document = toDocument(m_executionContext.get());
289 LocalFrame* frame = document->frame(); 301 LocalFrame* frame = document->frame();
290 if (frame) 302 if (frame)
291 frame->console().adoptWorkerMessagesAfterTermination(this); 303 frame->console().adoptWorkerMessagesAfterTermination(this);
292 } 304 }
293 305
294 } // namespace blink 306 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/Worker.cpp ('k') | Source/core/workers/WorkerObjectProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698