OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 27 matching lines...) Expand all Loading... |
38 #include "core/fileapi/Blob.h" | 38 #include "core/fileapi/Blob.h" |
39 #include "core/workers/WorkerGlobalScope.h" | 39 #include "core/workers/WorkerGlobalScope.h" |
40 #include "core/workers/WorkerLoaderProxy.h" | 40 #include "core/workers/WorkerLoaderProxy.h" |
41 #include "core/workers/WorkerThread.h" | 41 #include "core/workers/WorkerThread.h" |
42 #include "modules/websockets/DocumentWebSocketChannel.h" | 42 #include "modules/websockets/DocumentWebSocketChannel.h" |
43 #include "platform/WaitableEvent.h" | 43 #include "platform/WaitableEvent.h" |
44 #include "platform/heap/SafePoint.h" | 44 #include "platform/heap/SafePoint.h" |
45 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
46 #include "wtf/Assertions.h" | 46 #include "wtf/Assertions.h" |
47 #include "wtf/Functional.h" | 47 #include "wtf/Functional.h" |
48 #include "wtf/PtrUtil.h" | |
49 #include "wtf/text/CString.h" | 48 #include "wtf/text/CString.h" |
50 #include "wtf/text/WTFString.h" | 49 #include "wtf/text/WTFString.h" |
51 #include <memory> | |
52 | 50 |
53 namespace blink { | 51 namespace blink { |
54 | 52 |
55 typedef WorkerWebSocketChannel::Bridge Bridge; | 53 typedef WorkerWebSocketChannel::Bridge Bridge; |
56 typedef WorkerWebSocketChannel::Peer Peer; | 54 typedef WorkerWebSocketChannel::Peer Peer; |
57 | 55 |
58 // Created and destroyed on the worker thread. All setters of this class are | 56 // Created and destroyed on the worker thread. All setters of this class are |
59 // called on the main thread, while all getters are called on the worker | 57 // called on the main thread, while all getters are called on the worker |
60 // thread. signalWorkerThread() must be called before any getters are called. | 58 // thread. signalWorkerThread() must be called before any getters are called. |
61 class WebSocketChannelSyncHelper : public GarbageCollectedFinalized<WebSocketCha
nnelSyncHelper> { | 59 class WebSocketChannelSyncHelper : public GarbageCollectedFinalized<WebSocketCha
nnelSyncHelper> { |
62 public: | 60 public: |
63 static WebSocketChannelSyncHelper* create(std::unique_ptr<WaitableEvent> eve
nt) | 61 static WebSocketChannelSyncHelper* create(PassOwnPtr<WaitableEvent> event) |
64 { | 62 { |
65 return new WebSocketChannelSyncHelper(std::move(event)); | 63 return new WebSocketChannelSyncHelper(std::move(event)); |
66 } | 64 } |
67 | 65 |
68 ~WebSocketChannelSyncHelper() | 66 ~WebSocketChannelSyncHelper() |
69 { | 67 { |
70 } | 68 } |
71 | 69 |
72 // All setters are called on the main thread. | 70 // All setters are called on the main thread. |
73 void setConnectRequestResult(bool connectRequestResult) | 71 void setConnectRequestResult(bool connectRequestResult) |
(...skipping 14 matching lines...) Expand all Loading... |
88 m_event->signal(); | 86 m_event->signal(); |
89 } | 87 } |
90 void wait() | 88 void wait() |
91 { | 89 { |
92 m_event->wait(); | 90 m_event->wait(); |
93 } | 91 } |
94 | 92 |
95 DEFINE_INLINE_TRACE() { } | 93 DEFINE_INLINE_TRACE() { } |
96 | 94 |
97 private: | 95 private: |
98 explicit WebSocketChannelSyncHelper(std::unique_ptr<WaitableEvent> event) | 96 explicit WebSocketChannelSyncHelper(PassOwnPtr<WaitableEvent> event) |
99 : m_event(std::move(event)) | 97 : m_event(std::move(event)) |
100 , m_connectRequestResult(false) | 98 , m_connectRequestResult(false) |
101 { | 99 { |
102 } | 100 } |
103 | 101 |
104 std::unique_ptr<WaitableEvent> m_event; | 102 OwnPtr<WaitableEvent> m_event; |
105 bool m_connectRequestResult; | 103 bool m_connectRequestResult; |
106 }; | 104 }; |
107 | 105 |
108 WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalSc
ope, WebSocketChannelClient* client, std::unique_ptr<SourceLocation> location) | 106 WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalSc
ope, WebSocketChannelClient* client, PassOwnPtr<SourceLocation> location) |
109 : m_bridge(new Bridge(client, workerGlobalScope)) | 107 : m_bridge(new Bridge(client, workerGlobalScope)) |
110 , m_locationAtConnection(std::move(location)) | 108 , m_locationAtConnection(std::move(location)) |
111 { | 109 { |
112 m_bridge->initialize(m_locationAtConnection->clone()); | 110 m_bridge->initialize(m_locationAtConnection->clone()); |
113 } | 111 } |
114 | 112 |
115 WorkerWebSocketChannel::~WorkerWebSocketChannel() | 113 WorkerWebSocketChannel::~WorkerWebSocketChannel() |
116 { | 114 { |
117 ASSERT(!m_bridge); | 115 ASSERT(!m_bridge); |
118 } | 116 } |
(...skipping 21 matching lines...) Expand all Loading... |
140 ASSERT(m_bridge); | 138 ASSERT(m_bridge); |
141 m_bridge->send(blobData); | 139 m_bridge->send(blobData); |
142 } | 140 } |
143 | 141 |
144 void WorkerWebSocketChannel::close(int code, const String& reason) | 142 void WorkerWebSocketChannel::close(int code, const String& reason) |
145 { | 143 { |
146 ASSERT(m_bridge); | 144 ASSERT(m_bridge); |
147 m_bridge->close(code, reason); | 145 m_bridge->close(code, reason); |
148 } | 146 } |
149 | 147 |
150 void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, std:
:unique_ptr<SourceLocation> location) | 148 void WorkerWebSocketChannel::fail(const String& reason, MessageLevel level, Pass
OwnPtr<SourceLocation> location) |
151 { | 149 { |
152 if (!m_bridge) | 150 if (!m_bridge) |
153 return; | 151 return; |
154 | 152 |
155 std::unique_ptr<SourceLocation> capturedLocation = SourceLocation::capture()
; | 153 OwnPtr<SourceLocation> capturedLocation = SourceLocation::capture(); |
156 if (!capturedLocation->isUnknown()) { | 154 if (!capturedLocation->isUnknown()) { |
157 // If we are in JavaScript context, use the current location instead | 155 // If we are in JavaScript context, use the current location instead |
158 // of passed one - it's more precise. | 156 // of passed one - it's more precise. |
159 m_bridge->fail(reason, level, std::move(capturedLocation)); | 157 m_bridge->fail(reason, level, std::move(capturedLocation)); |
160 } else if (location->isUnknown()) { | 158 } else if (location->isUnknown()) { |
161 // No information is specified by the caller - use the url | 159 // No information is specified by the caller - use the url |
162 // and the line number at the connection. | 160 // and the line number at the connection. |
163 m_bridge->fail(reason, level, m_locationAtConnection->clone()); | 161 m_bridge->fail(reason, level, m_locationAtConnection->clone()); |
164 } else { | 162 } else { |
165 // Use the specified information. | 163 // Use the specified information. |
(...skipping 21 matching lines...) Expand all Loading... |
187 , m_syncHelper(syncHelper) | 185 , m_syncHelper(syncHelper) |
188 { | 186 { |
189 DCHECK(isMainThread()); | 187 DCHECK(isMainThread()); |
190 } | 188 } |
191 | 189 |
192 Peer::~Peer() | 190 Peer::~Peer() |
193 { | 191 { |
194 DCHECK(isMainThread()); | 192 DCHECK(isMainThread()); |
195 } | 193 } |
196 | 194 |
197 bool Peer::initialize(std::unique_ptr<SourceLocation> location, ExecutionContext
* context) | 195 bool Peer::initialize(PassOwnPtr<SourceLocation> location, ExecutionContext* con
text) |
198 { | 196 { |
199 ASSERT(isMainThread()); | 197 ASSERT(isMainThread()); |
200 if (wasContextDestroyedBeforeObserverCreation()) | 198 if (wasContextDestroyedBeforeObserverCreation()) |
201 return false; | 199 return false; |
202 Document* document = toDocument(context); | 200 Document* document = toDocument(context); |
203 m_mainWebSocketChannel = DocumentWebSocketChannel::create(document, this, st
d::move(location)); | 201 m_mainWebSocketChannel = DocumentWebSocketChannel::create(document, this, st
d::move(location)); |
204 return true; | 202 return true; |
205 } | 203 } |
206 | 204 |
207 void Peer::connect(const KURL& url, const String& protocol) | 205 void Peer::connect(const KURL& url, const String& protocol) |
208 { | 206 { |
209 ASSERT(isMainThread()); | 207 ASSERT(isMainThread()); |
210 ASSERT(m_syncHelper); | 208 ASSERT(m_syncHelper); |
211 if (!m_mainWebSocketChannel) { | 209 if (!m_mainWebSocketChannel) { |
212 m_syncHelper->setConnectRequestResult(false); | 210 m_syncHelper->setConnectRequestResult(false); |
213 } else { | 211 } else { |
214 bool connectRequestResult = m_mainWebSocketChannel->connect(url, protoco
l); | 212 bool connectRequestResult = m_mainWebSocketChannel->connect(url, protoco
l); |
215 m_syncHelper->setConnectRequestResult(connectRequestResult); | 213 m_syncHelper->setConnectRequestResult(connectRequestResult); |
216 } | 214 } |
217 m_syncHelper->signalWorkerThread(); | 215 m_syncHelper->signalWorkerThread(); |
218 } | 216 } |
219 | 217 |
220 void Peer::sendTextAsCharVector(std::unique_ptr<Vector<char>> data) | 218 void Peer::sendTextAsCharVector(PassOwnPtr<Vector<char>> data) |
221 { | 219 { |
222 ASSERT(isMainThread()); | 220 ASSERT(isMainThread()); |
223 if (m_mainWebSocketChannel) | 221 if (m_mainWebSocketChannel) |
224 m_mainWebSocketChannel->sendTextAsCharVector(std::move(data)); | 222 m_mainWebSocketChannel->sendTextAsCharVector(std::move(data)); |
225 } | 223 } |
226 | 224 |
227 void Peer::sendBinaryAsCharVector(std::unique_ptr<Vector<char>> data) | 225 void Peer::sendBinaryAsCharVector(PassOwnPtr<Vector<char>> data) |
228 { | 226 { |
229 ASSERT(isMainThread()); | 227 ASSERT(isMainThread()); |
230 if (m_mainWebSocketChannel) | 228 if (m_mainWebSocketChannel) |
231 m_mainWebSocketChannel->sendBinaryAsCharVector(std::move(data)); | 229 m_mainWebSocketChannel->sendBinaryAsCharVector(std::move(data)); |
232 } | 230 } |
233 | 231 |
234 void Peer::sendBlob(PassRefPtr<BlobDataHandle> blobData) | 232 void Peer::sendBlob(PassRefPtr<BlobDataHandle> blobData) |
235 { | 233 { |
236 ASSERT(isMainThread()); | 234 ASSERT(isMainThread()); |
237 if (m_mainWebSocketChannel) | 235 if (m_mainWebSocketChannel) |
238 m_mainWebSocketChannel->send(blobData); | 236 m_mainWebSocketChannel->send(blobData); |
239 } | 237 } |
240 | 238 |
241 void Peer::close(int code, const String& reason) | 239 void Peer::close(int code, const String& reason) |
242 { | 240 { |
243 ASSERT(isMainThread()); | 241 ASSERT(isMainThread()); |
244 ASSERT(m_syncHelper); | 242 ASSERT(m_syncHelper); |
245 if (!m_mainWebSocketChannel) | 243 if (!m_mainWebSocketChannel) |
246 return; | 244 return; |
247 m_mainWebSocketChannel->close(code, reason); | 245 m_mainWebSocketChannel->close(code, reason); |
248 } | 246 } |
249 | 247 |
250 void Peer::fail(const String& reason, MessageLevel level, std::unique_ptr<Source
Location> location) | 248 void Peer::fail(const String& reason, MessageLevel level, PassOwnPtr<SourceLocat
ion> location) |
251 { | 249 { |
252 ASSERT(isMainThread()); | 250 ASSERT(isMainThread()); |
253 ASSERT(m_syncHelper); | 251 ASSERT(m_syncHelper); |
254 if (!m_mainWebSocketChannel) | 252 if (!m_mainWebSocketChannel) |
255 return; | 253 return; |
256 m_mainWebSocketChannel->fail(reason, level, std::move(location)); | 254 m_mainWebSocketChannel->fail(reason, level, std::move(location)); |
257 } | 255 } |
258 | 256 |
259 void Peer::disconnect() | 257 void Peer::disconnect() |
260 { | 258 { |
(...skipping 25 matching lines...) Expand all Loading... |
286 if (bridge->client()) | 284 if (bridge->client()) |
287 bridge->client()->didReceiveTextMessage(payload); | 285 bridge->client()->didReceiveTextMessage(payload); |
288 } | 286 } |
289 | 287 |
290 void Peer::didReceiveTextMessage(const String& payload) | 288 void Peer::didReceiveTextMessage(const String& payload) |
291 { | 289 { |
292 ASSERT(isMainThread()); | 290 ASSERT(isMainThread()); |
293 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveTextMessage, m_bridge, payload)); | 291 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveTextMessage, m_bridge, payload)); |
294 } | 292 } |
295 | 293 |
296 static void workerGlobalScopeDidReceiveBinaryMessage(Bridge* bridge, std::unique
_ptr<Vector<char>> payload, ExecutionContext* context) | 294 static void workerGlobalScopeDidReceiveBinaryMessage(Bridge* bridge, PassOwnPtr<
Vector<char>> payload, ExecutionContext* context) |
297 { | 295 { |
298 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 296 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
299 if (bridge->client()) | 297 if (bridge->client()) |
300 bridge->client()->didReceiveBinaryMessage(std::move(payload)); | 298 bridge->client()->didReceiveBinaryMessage(std::move(payload)); |
301 } | 299 } |
302 | 300 |
303 void Peer::didReceiveBinaryMessage(std::unique_ptr<Vector<char>> payload) | 301 void Peer::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) |
304 { | 302 { |
305 ASSERT(isMainThread()); | 303 ASSERT(isMainThread()); |
306 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveBinaryMessage, m_bridge, passed(std::move(payload)))); | 304 m_loaderProxy->postTaskToWorkerGlobalScope(createCrossThreadTask(&workerGlob
alScopeDidReceiveBinaryMessage, m_bridge, passed(std::move(payload)))); |
307 } | 305 } |
308 | 306 |
309 static void workerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, uint64_t c
onsumed, ExecutionContext* context) | 307 static void workerGlobalScopeDidConsumeBufferedAmount(Bridge* bridge, uint64_t c
onsumed, ExecutionContext* context) |
310 { | 308 { |
311 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); | 309 ASSERT_UNUSED(context, context->isWorkerGlobalScope()); |
312 if (bridge->client()) | 310 if (bridge->client()) |
313 bridge->client()->didConsumeBufferedAmount(consumed); | 311 bridge->client()->didConsumeBufferedAmount(consumed); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 visitor->trace(m_mainWebSocketChannel); | 375 visitor->trace(m_mainWebSocketChannel); |
378 visitor->trace(m_syncHelper); | 376 visitor->trace(m_syncHelper); |
379 WebSocketChannelClient::trace(visitor); | 377 WebSocketChannelClient::trace(visitor); |
380 WorkerThreadLifecycleObserver::trace(visitor); | 378 WorkerThreadLifecycleObserver::trace(visitor); |
381 } | 379 } |
382 | 380 |
383 Bridge::Bridge(WebSocketChannelClient* client, WorkerGlobalScope& workerGlobalSc
ope) | 381 Bridge::Bridge(WebSocketChannelClient* client, WorkerGlobalScope& workerGlobalSc
ope) |
384 : m_client(client) | 382 : m_client(client) |
385 , m_workerGlobalScope(workerGlobalScope) | 383 , m_workerGlobalScope(workerGlobalScope) |
386 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) | 384 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) |
387 , m_syncHelper(WebSocketChannelSyncHelper::create(wrapUnique(new WaitableEve
nt()))) | 385 , m_syncHelper(WebSocketChannelSyncHelper::create(adoptPtr(new WaitableEvent
()))) |
388 { | 386 { |
389 } | 387 } |
390 | 388 |
391 Bridge::~Bridge() | 389 Bridge::~Bridge() |
392 { | 390 { |
393 ASSERT(!m_peer); | 391 ASSERT(!m_peer); |
394 } | 392 } |
395 | 393 |
396 void Bridge::createPeerOnMainThread(std::unique_ptr<SourceLocation> location, Wo
rkerThreadLifecycleContext* workerThreadLifecycleContext, ExecutionContext* cont
ext) | 394 void Bridge::createPeerOnMainThread(PassOwnPtr<SourceLocation> location, WorkerT
hreadLifecycleContext* workerThreadLifecycleContext, ExecutionContext* context) |
397 { | 395 { |
398 DCHECK(isMainThread()); | 396 DCHECK(isMainThread()); |
399 DCHECK(!m_peer); | 397 DCHECK(!m_peer); |
400 Peer* peer = new Peer(this, m_loaderProxy, m_syncHelper, workerThreadLifecyc
leContext); | 398 Peer* peer = new Peer(this, m_loaderProxy, m_syncHelper, workerThreadLifecyc
leContext); |
401 if (peer->initialize(std::move(location), context)) | 399 if (peer->initialize(std::move(location), context)) |
402 m_peer = peer; | 400 m_peer = peer; |
403 m_syncHelper->signalWorkerThread(); | 401 m_syncHelper->signalWorkerThread(); |
404 } | 402 } |
405 | 403 |
406 void Bridge::initialize(std::unique_ptr<SourceLocation> location) | 404 void Bridge::initialize(PassOwnPtr<SourceLocation> location) |
407 { | 405 { |
408 // Wait for completion of the task on the main thread because the connection | 406 // Wait for completion of the task on the main thread because the connection |
409 // must synchronously be established (see Bridge::connect). | 407 // must synchronously be established (see Bridge::connect). |
410 if (!waitForMethodCompletion(createCrossThreadTask(&Bridge::createPeerOnMain
Thread, wrapCrossThreadPersistent(this), passed(std::move(location)), wrapCrossT
hreadPersistent(m_workerGlobalScope->thread()->getWorkerThreadLifecycleContext()
)))) { | 408 if (!waitForMethodCompletion(createCrossThreadTask(&Bridge::createPeerOnMain
Thread, wrapCrossThreadPersistent(this), passed(std::move(location)), wrapCrossT
hreadPersistent(m_workerGlobalScope->thread()->getWorkerThreadLifecycleContext()
)))) { |
411 // The worker thread has been signalled to shutdown before method comple
tion. | 409 // The worker thread has been signalled to shutdown before method comple
tion. |
412 disconnect(); | 410 disconnect(); |
413 } | 411 } |
414 } | 412 } |
415 | 413 |
416 bool Bridge::connect(const KURL& url, const String& protocol) | 414 bool Bridge::connect(const KURL& url, const String& protocol) |
417 { | 415 { |
418 if (!m_peer) | 416 if (!m_peer) |
419 return false; | 417 return false; |
420 | 418 |
421 // Wait for completion of the task on the main thread because the mixed | 419 // Wait for completion of the task on the main thread because the mixed |
422 // content check must synchronously be conducted. | 420 // content check must synchronously be conducted. |
423 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::connect, wrapCross
ThreadPersistent(m_peer.get()), url, protocol))) | 421 if (!waitForMethodCompletion(createCrossThreadTask(&Peer::connect, wrapCross
ThreadPersistent(m_peer.get()), url, protocol))) |
424 return false; | 422 return false; |
425 | 423 |
426 return m_syncHelper->connectRequestResult(); | 424 return m_syncHelper->connectRequestResult(); |
427 } | 425 } |
428 | 426 |
429 void Bridge::send(const CString& message) | 427 void Bridge::send(const CString& message) |
430 { | 428 { |
431 ASSERT(m_peer); | 429 ASSERT(m_peer); |
432 std::unique_ptr<Vector<char>> data = wrapUnique(new Vector<char>(message.len
gth())); | 430 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(message.length())); |
433 if (message.length()) | 431 if (message.length()) |
434 memcpy(data->data(), static_cast<const char*>(message.data()), message.l
ength()); | 432 memcpy(data->data(), static_cast<const char*>(message.data()), message.l
ength()); |
435 | 433 |
436 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharV
ector, wrapCrossThreadPersistent(m_peer.get()), passed(std::move(data)))); | 434 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendTextAsCharV
ector, wrapCrossThreadPersistent(m_peer.get()), passed(std::move(data)))); |
437 } | 435 } |
438 | 436 |
439 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne
d byteLength) | 437 void Bridge::send(const DOMArrayBuffer& binaryData, unsigned byteOffset, unsigne
d byteLength) |
440 { | 438 { |
441 ASSERT(m_peer); | 439 ASSERT(m_peer); |
442 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied
into Vector<char>. | 440 // ArrayBuffer isn't thread-safe, hence the content of ArrayBuffer is copied
into Vector<char>. |
443 std::unique_ptr<Vector<char>> data = wrapUnique(new Vector<char>(byteLength)
); | 441 OwnPtr<Vector<char>> data = adoptPtr(new Vector<char>(byteLength)); |
444 if (binaryData.byteLength()) | 442 if (binaryData.byteLength()) |
445 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO
ffset, byteLength); | 443 memcpy(data->data(), static_cast<const char*>(binaryData.data()) + byteO
ffset, byteLength); |
446 | 444 |
447 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCha
rVector, wrapCrossThreadPersistent(m_peer.get()), passed(std::move(data)))); | 445 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBinaryAsCha
rVector, wrapCrossThreadPersistent(m_peer.get()), passed(std::move(data)))); |
448 } | 446 } |
449 | 447 |
450 void Bridge::send(PassRefPtr<BlobDataHandle> data) | 448 void Bridge::send(PassRefPtr<BlobDataHandle> data) |
451 { | 449 { |
452 ASSERT(m_peer); | 450 ASSERT(m_peer); |
453 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, wrapC
rossThreadPersistent(m_peer.get()), data)); | 451 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::sendBlob, wrapC
rossThreadPersistent(m_peer.get()), data)); |
454 } | 452 } |
455 | 453 |
456 void Bridge::close(int code, const String& reason) | 454 void Bridge::close(int code, const String& reason) |
457 { | 455 { |
458 ASSERT(m_peer); | 456 ASSERT(m_peer); |
459 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, wrapCros
sThreadPersistent(m_peer.get()), code, reason)); | 457 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::close, wrapCros
sThreadPersistent(m_peer.get()), code, reason)); |
460 } | 458 } |
461 | 459 |
462 void Bridge::fail(const String& reason, MessageLevel level, std::unique_ptr<Sour
ceLocation> location) | 460 void Bridge::fail(const String& reason, MessageLevel level, PassOwnPtr<SourceLoc
ation> location) |
463 { | 461 { |
464 ASSERT(m_peer); | 462 ASSERT(m_peer); |
465 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, wrapCross
ThreadPersistent(m_peer.get()), reason, level, passed(std::move(location)))); | 463 m_loaderProxy->postTaskToLoader(createCrossThreadTask(&Peer::fail, wrapCross
ThreadPersistent(m_peer.get()), reason, level, passed(std::move(location)))); |
466 } | 464 } |
467 | 465 |
468 void Bridge::disconnect() | 466 void Bridge::disconnect() |
469 { | 467 { |
470 if (!m_peer) | 468 if (!m_peer) |
471 return; | 469 return; |
472 | 470 |
(...skipping 26 matching lines...) Expand all Loading... |
499 } | 497 } |
500 | 498 |
501 DEFINE_TRACE(Bridge) | 499 DEFINE_TRACE(Bridge) |
502 { | 500 { |
503 visitor->trace(m_client); | 501 visitor->trace(m_client); |
504 visitor->trace(m_workerGlobalScope); | 502 visitor->trace(m_workerGlobalScope); |
505 visitor->trace(m_syncHelper); | 503 visitor->trace(m_syncHelper); |
506 } | 504 } |
507 | 505 |
508 } // namespace blink | 506 } // namespace blink |
OLD | NEW |