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

Side by Side Diff: third_party/WebKit/Source/core/workers/InProcessWorkerMessagingProxy.cpp

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Add missing ScopedAsyncTaskScheduler instance for the new unit tests; required by a recent change t… Created 3 years, 10 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
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 OriginTrialContext::getTokens(document).get(), 112 OriginTrialContext::getTokens(document).get(),
113 std::move(workerSettings), workerV8Settings); 113 std::move(workerSettings), workerV8Settings);
114 114
115 initializeWorkerThread(std::move(startupData)); 115 initializeWorkerThread(std::move(startupData));
116 workerInspectorProxy()->workerThreadCreated(document, workerThread(), 116 workerInspectorProxy()->workerThreadCreated(document, workerThread(),
117 scriptURL); 117 scriptURL);
118 } 118 }
119 119
120 void InProcessWorkerMessagingProxy::postMessageToWorkerObject( 120 void InProcessWorkerMessagingProxy::postMessageToWorkerObject(
121 PassRefPtr<SerializedScriptValue> message, 121 PassRefPtr<SerializedScriptValue> message,
122 std::unique_ptr<MessagePortChannelArray> channels) { 122 MessagePortChannelArray channels) {
123 DCHECK(isParentContextThread()); 123 DCHECK(isParentContextThread());
124 if (!m_workerObject || askedToTerminate()) 124 if (!m_workerObject || askedToTerminate())
125 return; 125 return;
126 126
127 MessagePortArray* ports = 127 MessagePortArray* ports =
128 MessagePort::entanglePorts(*getExecutionContext(), std::move(channels)); 128 MessagePort::entanglePorts(*getExecutionContext(), std::move(channels));
129 m_workerObject->dispatchEvent( 129 m_workerObject->dispatchEvent(
130 MessageEvent::create(ports, std::move(message))); 130 MessageEvent::create(ports, std::move(message)));
131 } 131 }
132 132
133 void InProcessWorkerMessagingProxy::postMessageToWorkerGlobalScope( 133 void InProcessWorkerMessagingProxy::postMessageToWorkerGlobalScope(
134 PassRefPtr<SerializedScriptValue> message, 134 PassRefPtr<SerializedScriptValue> message,
135 std::unique_ptr<MessagePortChannelArray> channels) { 135 MessagePortChannelArray channels) {
136 DCHECK(isParentContextThread()); 136 DCHECK(isParentContextThread());
137 if (askedToTerminate()) 137 if (askedToTerminate())
138 return; 138 return;
139 139
140 if (workerThread()) { 140 if (workerThread()) {
141 // A message event is an activity and may initiate another activity. 141 // A message event is an activity and may initiate another activity.
142 m_workerGlobalScopeHasPendingActivity = true; 142 m_workerGlobalScopeHasPendingActivity = true;
143 ++m_unconfirmedMessageCount; 143 ++m_unconfirmedMessageCount;
144 std::unique_ptr<WTF::CrossThreadClosure> task = crossThreadBind( 144 std::unique_ptr<WTF::CrossThreadClosure> task = crossThreadBind(
145 &InProcessWorkerObjectProxy::processMessageFromWorkerObject, 145 &InProcessWorkerObjectProxy::processMessageFromWorkerObject,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 bool InProcessWorkerMessagingProxy::hasPendingActivity() const { 234 bool InProcessWorkerMessagingProxy::hasPendingActivity() const {
235 DCHECK(isParentContextThread()); 235 DCHECK(isParentContextThread());
236 if (askedToTerminate()) 236 if (askedToTerminate())
237 return false; 237 return false;
238 return m_workerGlobalScopeHasPendingActivity; 238 return m_workerGlobalScopeHasPendingActivity;
239 } 239 }
240 240
241 InProcessWorkerMessagingProxy::QueuedTask::QueuedTask( 241 InProcessWorkerMessagingProxy::QueuedTask::QueuedTask(
242 RefPtr<SerializedScriptValue> message, 242 RefPtr<SerializedScriptValue> message,
243 std::unique_ptr<MessagePortChannelArray> channels) 243 MessagePortChannelArray channels)
244 : message(std::move(message)), channels(std::move(channels)) {} 244 : message(std::move(message)), channels(std::move(channels)) {}
245 245
246 InProcessWorkerMessagingProxy::QueuedTask::~QueuedTask() = default; 246 InProcessWorkerMessagingProxy::QueuedTask::~QueuedTask() = default;
247 247
248 } // namespace blink 248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698