| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/worker/websharedworker_stub.h" | 5 #include "content/worker/websharedworker_stub.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "content/child/child_process.h" | 8 #include "content/child/child_process.h" |
| 9 #include "content/child/child_thread.h" | 9 #include "content/child/child_thread.h" |
| 10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } else { | 95 } else { |
| 96 // If two documents try to load a SharedWorker at the same time, the | 96 // If two documents try to load a SharedWorker at the same time, the |
| 97 // WorkerMsg_Connect for one of the documents can come in before the | 97 // WorkerMsg_Connect for one of the documents can come in before the |
| 98 // worker is started. Just queue up the connect and deliver it once the | 98 // worker is started. Just queue up the connect and deliver it once the |
| 99 // worker starts. | 99 // worker starts. |
| 100 pending_channels_.push_back(channel); | 100 pending_channels_.push_back(channel); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void WebSharedWorkerStub::OnTerminateWorkerContext() { | 104 void WebSharedWorkerStub::OnTerminateWorkerContext() { |
| 105 impl_->terminateWorkerContext(); | 105 running_ = false; |
| 106 | |
| 107 // Call the client to make sure context exits. | 106 // Call the client to make sure context exits. |
| 108 EnsureWorkerContextTerminates(); | 107 EnsureWorkerContextTerminates(); |
| 109 running_ = false; | 108 // This may call "delete this" via WorkerScriptLoadFailed and Shutdown. |
| 109 impl_->terminateWorkerContext(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void WebSharedWorkerStub::WorkerScriptLoaded() { | 112 void WebSharedWorkerStub::WorkerScriptLoaded() { |
| 113 running_ = true; | 113 running_ = true; |
| 114 // Process any pending connections. | 114 // Process any pending connections. |
| 115 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); | 115 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); |
| 116 iter != pending_channels_.end(); | 116 iter != pending_channels_.end(); |
| 117 ++iter) { | 117 ++iter) { |
| 118 impl_->connect(*iter); | 118 impl_->connect(*iter); |
| 119 WorkerThread::current()->Send( | 119 WorkerThread::current()->Send( |
| 120 new WorkerHostMsg_WorkerConnected((*iter)->message_port_id(), | 120 new WorkerHostMsg_WorkerConnected((*iter)->message_port_id(), |
| 121 route_id_)); | 121 route_id_)); |
| 122 } | 122 } |
| 123 pending_channels_.clear(); | 123 pending_channels_.clear(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void WebSharedWorkerStub::WorkerScriptLoadFailed() { | 126 void WebSharedWorkerStub::WorkerScriptLoadFailed() { |
| 127 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); | 127 for (PendingChannelList::const_iterator iter = pending_channels_.begin(); |
| 128 iter != pending_channels_.end(); | 128 iter != pending_channels_.end(); |
| 129 ++iter) { | 129 ++iter) { |
| 130 blink::WebMessagePortChannel* channel = *iter; | 130 blink::WebMessagePortChannel* channel = *iter; |
| 131 channel->destroy(); | 131 channel->destroy(); |
| 132 } | 132 } |
| 133 pending_channels_.clear(); | 133 pending_channels_.clear(); |
| 134 Shutdown(); | 134 Shutdown(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace content | 137 } // namespace content |
| OLD | NEW |