Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 WebEmbeddedWorkerImpl& m_embeddedWorker; | 139 WebEmbeddedWorkerImpl& m_embeddedWorker; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 WebEmbeddedWorker* WebEmbeddedWorker::create( | 142 WebEmbeddedWorker* WebEmbeddedWorker::create( |
| 143 WebServiceWorkerContextClient* client, | 143 WebServiceWorkerContextClient* client, |
| 144 WebWorkerPermissionClientProxy* permissionClient) | 144 WebWorkerPermissionClientProxy* permissionClient) |
| 145 { | 145 { |
| 146 return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(permissionClient )); | 146 return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(permissionClient )); |
| 147 } | 147 } |
| 148 | 148 |
| 149 static HashSet<WebEmbeddedWorkerImpl*>& aliveWebEmbeddedWorkerImplInstances() | |
|
michaeln
2014/07/25 02:49:52
this is long'ish, runningWorkerInstances()?
kouhei (in TOK)
2014/07/25 05:00:39
Acknowledged.
| |
| 150 { | |
| 151 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); | |
| 152 return set; | |
| 153 } | |
| 154 | |
| 149 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl( | 155 WebEmbeddedWorkerImpl::WebEmbeddedWorkerImpl( |
| 150 PassOwnPtr<WebServiceWorkerContextClient> client, | 156 PassOwnPtr<WebServiceWorkerContextClient> client, |
| 151 PassOwnPtr<WebWorkerPermissionClientProxy> permissionClient) | 157 PassOwnPtr<WebWorkerPermissionClientProxy> permissionClient) |
| 152 : m_workerContextClient(client) | 158 : m_workerContextClient(client) |
| 153 , m_permissionClient(permissionClient) | 159 , m_permissionClient(permissionClient) |
| 154 , m_webView(0) | 160 , m_webView(0) |
| 155 , m_mainFrame(0) | 161 , m_mainFrame(0) |
| 156 , m_askedToTerminate(false) | 162 , m_askedToTerminate(false) |
| 157 , m_pauseAfterDownloadState(DontPauseAfterDownload) | 163 , m_pauseAfterDownloadState(DontPauseAfterDownload) |
| 158 { | 164 { |
| 165 aliveWebEmbeddedWorkerImplInstances().add(this); | |
| 159 } | 166 } |
| 160 | 167 |
| 161 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() | 168 WebEmbeddedWorkerImpl::~WebEmbeddedWorkerImpl() |
| 162 { | 169 { |
| 170 ASSERT(aliveWebEmbeddedWorkerImplInstances().contains(this)); | |
| 171 aliveWebEmbeddedWorkerImplInstances().remove(this); | |
| 163 ASSERT(m_webView); | 172 ASSERT(m_webView); |
| 164 | 173 |
| 165 // Detach the client before closing the view to avoid getting called back. | 174 // Detach the client before closing the view to avoid getting called back. |
| 166 toWebLocalFrameImpl(m_mainFrame)->setClient(0); | 175 toWebLocalFrameImpl(m_mainFrame)->setClient(0); |
| 167 | 176 |
| 168 m_webView->close(); | 177 m_webView->close(); |
| 169 m_mainFrame->close(); | 178 m_mainFrame->close(); |
| 170 } | 179 } |
| 171 | 180 |
| 181 void WebEmbeddedWorkerImpl::terminateAll() | |
| 182 { | |
| 183 HashSet<WebEmbeddedWorkerImpl*> instances = aliveWebEmbeddedWorkerImplInstan ces(); | |
| 184 for (HashSet<WebEmbeddedWorkerImpl*>::iterator it = instances.begin(), itEnd = instances.end(); it != itEnd; ++it) { | |
| 185 (*it)->terminateWorkerContext(); | |
| 186 } | |
| 187 } | |
| 188 | |
| 172 void WebEmbeddedWorkerImpl::startWorkerContext( | 189 void WebEmbeddedWorkerImpl::startWorkerContext( |
| 173 const WebEmbeddedWorkerStartData& data) | 190 const WebEmbeddedWorkerStartData& data) |
| 174 { | 191 { |
| 175 ASSERT(!m_askedToTerminate); | 192 ASSERT(!m_askedToTerminate); |
| 176 ASSERT(!m_mainScriptLoader); | 193 ASSERT(!m_mainScriptLoader); |
| 177 ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload); | 194 ASSERT(m_pauseAfterDownloadState == DontPauseAfterDownload); |
| 178 m_workerStartData = data; | 195 m_workerStartData = data; |
| 179 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload) | 196 if (data.pauseAfterDownloadMode == WebEmbeddedWorkerStartData::PauseAfterDow nload) |
| 180 m_pauseAfterDownloadState = DoPauseAfterDownload; | 197 m_pauseAfterDownloadState = DoPauseAfterDownload; |
| 181 prepareShadowPageForLoader(); | 198 prepareShadowPageForLoader(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 m_mainScriptLoader.clear(); | 376 m_mainScriptLoader.clear(); |
| 360 | 377 |
| 361 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); | 378 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *toW ebLocalFrameImpl(m_mainFrame)->frame()->document(), *m_workerContextClient); |
| 362 m_loaderProxy = LoaderProxy::create(*this); | 379 m_loaderProxy = LoaderProxy::create(*this); |
| 363 | 380 |
| 364 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); | 381 m_workerThread = ServiceWorkerThread::create(*m_loaderProxy, *m_workerGlobal ScopeProxy, startupData.release()); |
| 365 m_workerThread->start(); | 382 m_workerThread->start(); |
| 366 } | 383 } |
| 367 | 384 |
| 368 } // namespace blink | 385 } // namespace blink |
| OLD | NEW |