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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 namespace blink { | 55 namespace blink { |
56 | 56 |
57 typedef WorkerThreadableWebSocketChannel::Bridge Bridge; | 57 typedef WorkerThreadableWebSocketChannel::Bridge Bridge; |
58 typedef WorkerThreadableWebSocketChannel::Peer Peer; | 58 typedef WorkerThreadableWebSocketChannel::Peer Peer; |
59 | 59 |
60 // Created and destroyed on the worker thread. All setters of this class are | 60 // Created and destroyed on the worker thread. All setters of this class are |
61 // called on the main thread, while all getters are called on the worker | 61 // called on the main thread, while all getters are called on the worker |
62 // thread. signalWorkerThread() must be called before any getters are called. | 62 // thread. signalWorkerThread() must be called before any getters are called. |
63 class ThreadableWebSocketChannelSyncHelper : public GarbageCollectedFinalized<Th
readableWebSocketChannelSyncHelper> { | 63 class ThreadableWebSocketChannelSyncHelper : public GarbageCollectedFinalized<Th
readableWebSocketChannelSyncHelper> { |
64 public: | 64 public: |
65 static ThreadableWebSocketChannelSyncHelper* create(PassOwnPtr<blink::WebWai
tableEvent> event) | 65 static ThreadableWebSocketChannelSyncHelper* create(PassOwnPtr<WebWaitableEv
ent> event) |
66 { | 66 { |
67 return new ThreadableWebSocketChannelSyncHelper(event); | 67 return new ThreadableWebSocketChannelSyncHelper(event); |
68 } | 68 } |
69 | 69 |
70 ~ThreadableWebSocketChannelSyncHelper() | 70 ~ThreadableWebSocketChannelSyncHelper() |
71 { | 71 { |
72 } | 72 } |
73 | 73 |
74 // All setters are called on the main thread. | 74 // All setters are called on the main thread. |
75 void setConnectRequestResult(bool connectRequestResult) | 75 void setConnectRequestResult(bool connectRequestResult) |
(...skipping 14 matching lines...) Expand all Loading... |
90 m_event->signal(); | 90 m_event->signal(); |
91 } | 91 } |
92 void wait() | 92 void wait() |
93 { | 93 { |
94 m_event->wait(); | 94 m_event->wait(); |
95 } | 95 } |
96 | 96 |
97 void trace(Visitor* visitor) { } | 97 void trace(Visitor* visitor) { } |
98 | 98 |
99 private: | 99 private: |
100 explicit ThreadableWebSocketChannelSyncHelper(PassOwnPtr<blink::WebWaitableE
vent> event) | 100 explicit ThreadableWebSocketChannelSyncHelper(PassOwnPtr<WebWaitableEvent> e
vent) |
101 : m_event(event) | 101 : m_event(event) |
102 , m_connectRequestResult(false) | 102 , m_connectRequestResult(false) |
103 { | 103 { |
104 } | 104 } |
105 | 105 |
106 OwnPtr<blink::WebWaitableEvent> m_event; | 106 OwnPtr<WebWaitableEvent> m_event; |
107 bool m_connectRequestResult; | 107 bool m_connectRequestResult; |
108 }; | 108 }; |
109 | 109 |
110 WorkerThreadableWebSocketChannel::WorkerThreadableWebSocketChannel(WorkerGlobalS
cope& workerGlobalScope, WebSocketChannelClient* client, const String& sourceURL
, unsigned lineNumber) | 110 WorkerThreadableWebSocketChannel::WorkerThreadableWebSocketChannel(WorkerGlobalS
cope& workerGlobalScope, WebSocketChannelClient* client, const String& sourceURL
, unsigned lineNumber) |
111 : m_workerClientWrapper(ThreadableWebSocketChannelClientWrapper::create(clie
nt)) | 111 : m_workerClientWrapper(ThreadableWebSocketChannelClientWrapper::create(clie
nt)) |
112 , m_bridge(Bridge::create(m_workerClientWrapper, workerGlobalScope)) | 112 , m_bridge(Bridge::create(m_workerClientWrapper, workerGlobalScope)) |
113 , m_sourceURLAtConnection(sourceURL) | 113 , m_sourceURLAtConnection(sourceURL) |
114 , m_lineNumberAtConnection(lineNumber) | 114 , m_lineNumberAtConnection(lineNumber) |
115 { | 115 { |
116 ASSERT(m_workerClientWrapper.get()); | 116 ASSERT(m_workerClientWrapper.get()); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 visitor->trace(m_workerClientWrapper); | 394 visitor->trace(m_workerClientWrapper); |
395 visitor->trace(m_mainWebSocketChannel); | 395 visitor->trace(m_mainWebSocketChannel); |
396 visitor->trace(m_syncHelper); | 396 visitor->trace(m_syncHelper); |
397 WebSocketChannelClient::trace(visitor); | 397 WebSocketChannelClient::trace(visitor); |
398 } | 398 } |
399 | 399 |
400 Bridge::Bridge(ThreadableWebSocketChannelClientWrapper* workerClientWrapper, Wor
kerGlobalScope& workerGlobalScope) | 400 Bridge::Bridge(ThreadableWebSocketChannelClientWrapper* workerClientWrapper, Wor
kerGlobalScope& workerGlobalScope) |
401 : m_workerClientWrapper(workerClientWrapper) | 401 : m_workerClientWrapper(workerClientWrapper) |
402 , m_workerGlobalScope(workerGlobalScope) | 402 , m_workerGlobalScope(workerGlobalScope) |
403 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) | 403 , m_loaderProxy(m_workerGlobalScope->thread()->workerLoaderProxy()) |
404 , m_syncHelper(ThreadableWebSocketChannelSyncHelper::create(adoptPtr(blink::
Platform::current()->createWaitableEvent()))) | 404 , m_syncHelper(ThreadableWebSocketChannelSyncHelper::create(adoptPtr(Platfor
m::current()->createWaitableEvent()))) |
405 , m_peer(Peer::create(m_workerClientWrapper, m_loaderProxy, m_syncHelper)) | 405 , m_peer(Peer::create(m_workerClientWrapper, m_loaderProxy, m_syncHelper)) |
406 { | 406 { |
407 ASSERT(m_workerClientWrapper.get()); | 407 ASSERT(m_workerClientWrapper.get()); |
408 } | 408 } |
409 | 409 |
410 Bridge::~Bridge() | 410 Bridge::~Bridge() |
411 { | 411 { |
412 ASSERT(!m_peer); | 412 ASSERT(!m_peer); |
413 } | 413 } |
414 | 414 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 505 |
506 void Bridge::trace(Visitor* visitor) | 506 void Bridge::trace(Visitor* visitor) |
507 { | 507 { |
508 visitor->trace(m_workerClientWrapper); | 508 visitor->trace(m_workerClientWrapper); |
509 visitor->trace(m_workerGlobalScope); | 509 visitor->trace(m_workerGlobalScope); |
510 visitor->trace(m_syncHelper); | 510 visitor->trace(m_syncHelper); |
511 visitor->trace(m_peer); | 511 visitor->trace(m_peer); |
512 } | 512 } |
513 | 513 |
514 } // namespace blink | 514 } // namespace blink |
OLD | NEW |