Chromium Code Reviews| Index: third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp |
| diff --git a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp |
| index 4bcf08becbb71b9600024e3f42871149fbc8fff9..745f0e21d48c2cd66f79e505dfb3bd64c1c601dc 100644 |
| --- a/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp |
| +++ b/third_party/WebKit/Source/modules/websockets/WorkerWebSocketChannel.cpp |
| @@ -72,15 +72,29 @@ public: |
| // All setters are called on the main thread. |
| void setConnectRequestResult(bool connectRequestResult) |
| { |
| + DCHECK(isMainThread()); |
| m_connectRequestResult = connectRequestResult; |
| } |
| + void setWorkerThreadTerminated(bool workerThreadTerminated) |
| + { |
| + DCHECK(isMainThread()); |
| + m_workerThreadTerminated = workerThreadTerminated; |
| + } |
| + |
| // All getter are called on the worker thread. |
| bool connectRequestResult() const |
| { |
| + DCHECK(!isMainThread()); |
| return m_connectRequestResult; |
| } |
| + bool workerThreadTerminated() const |
| + { |
| + DCHECK(!isMainThread()); |
| + return m_workerThreadTerminated; |
| + } |
| + |
| // This should be called after all setters are called and before any |
| // getters are called. |
| void signalWorkerThread() |
| @@ -97,12 +111,12 @@ public: |
| private: |
| explicit WebSocketChannelSyncHelper(std::unique_ptr<WaitableEvent> event) |
| : m_event(std::move(event)) |
| - , m_connectRequestResult(false) |
| { |
| } |
| std::unique_ptr<WaitableEvent> m_event; |
| - bool m_connectRequestResult; |
| + bool m_connectRequestResult = false; |
| + bool m_workerThreadTerminated = false; |
| }; |
| WorkerWebSocketChannel::WorkerWebSocketChannel(WorkerGlobalScope& workerGlobalScope, WebSocketChannelClient* client, std::unique_ptr<SourceLocation> location) |
| @@ -365,6 +379,7 @@ void Peer::didError() |
| void Peer::contextDestroyed() |
| { |
| DCHECK(isMainThread()); |
| + m_syncHelper->setWorkerThreadTerminated(true); |
|
yhirano
2016/08/23 02:27:15
I think this can be called after m_syncHelper->sig
|
| if (m_mainWebSocketChannel) { |
| m_mainWebSocketChannel->disconnect(); |
| m_mainWebSocketChannel = nullptr; |
| @@ -495,7 +510,7 @@ bool Bridge::waitForMethodCompletion(const WebTraceLocation& location, std::uniq |
| SafePointScope scope(BlinkGC::HeapPointersOnStack); |
| m_syncHelper->wait(); |
| // This is checking whether a shutdown event is fired or not. |
| - return !m_workerGlobalScope->thread()->terminated(); |
| + return !m_syncHelper->workerThreadTerminated(); |
| } |
| DEFINE_TRACE(Bridge) |