| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/service_worker/embedded_worker_context_client.h" | 5 #include "content/renderer/service_worker/embedded_worker_context_client.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 FROM_HERE, | 158 FROM_HERE, |
| 159 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, | 159 base::Bind(&EmbeddedWorkerContextClient::SendWorkerStarted, |
| 160 weak_factory_.GetWeakPtr())); | 160 weak_factory_.GetWeakPtr())); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void EmbeddedWorkerContextClient::willDestroyWorkerContext() { | 163 void EmbeddedWorkerContextClient::willDestroyWorkerContext() { |
| 164 // At this point OnWorkerRunLoopStopped is already called, so | 164 // At this point OnWorkerRunLoopStopped is already called, so |
| 165 // worker_task_runner_->RunsTasksOnCurrentThread() returns false | 165 // worker_task_runner_->RunsTasksOnCurrentThread() returns false |
| 166 // (while we're still on the worker thread). | 166 // (while we're still on the worker thread). |
| 167 script_context_.reset(); | 167 script_context_.reset(); |
| 168 | |
| 169 #if !defined(HAS_SERVICE_WORKER_CONTEXT_DESTROYED) | |
| 170 // TODO(kinuko): Remove this after blink side is landed. | |
| 171 main_thread_proxy_->PostTask( | |
| 172 FROM_HERE, | |
| 173 base::Bind(&CallWorkerContextDestroyedOnMainThread, | |
| 174 embedded_worker_id_)); | |
| 175 #endif | |
| 176 } | 168 } |
| 177 | 169 |
| 178 void EmbeddedWorkerContextClient::workerContextDestroyed() { | 170 void EmbeddedWorkerContextClient::workerContextDestroyed() { |
| 179 // TODO(kinuko): Remove this ifdef after blink side is landed. | |
| 180 #ifdef HAS_SERVICE_WORKER_CONTEXT_DESTROYED | |
| 181 // Now we should be able to free the WebEmbeddedWorker container on the | 171 // Now we should be able to free the WebEmbeddedWorker container on the |
| 182 // main thread. | 172 // main thread. |
| 183 main_thread_proxy_->PostTask( | 173 main_thread_proxy_->PostTask( |
| 184 FROM_HERE, | 174 FROM_HERE, |
| 185 base::Bind(&CallWorkerContextDestroyedOnMainThread, | 175 base::Bind(&CallWorkerContextDestroyedOnMainThread, |
| 186 embedded_worker_id_)); | 176 embedded_worker_id_)); |
| 187 #endif | |
| 188 } | 177 } |
| 189 | 178 |
| 190 void EmbeddedWorkerContextClient::reportException( | 179 void EmbeddedWorkerContextClient::reportException( |
| 191 const blink::WebString& error_message, | 180 const blink::WebString& error_message, |
| 192 int line_number, | 181 int line_number, |
| 193 int column_number, | 182 int column_number, |
| 194 const blink::WebString& source_url) { | 183 const blink::WebString& source_url) { |
| 195 Send(new EmbeddedWorkerHostMsg_ReportException( | 184 Send(new EmbeddedWorkerHostMsg_ReportException( |
| 196 embedded_worker_id_, error_message, line_number, | 185 embedded_worker_id_, error_message, line_number, |
| 197 column_number, GURL(source_url))); | 186 column_number, GURL(source_url))); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 297 } |
| 309 | 298 |
| 310 void EmbeddedWorkerContextClient::SendWorkerStarted() { | 299 void EmbeddedWorkerContextClient::SendWorkerStarted() { |
| 311 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 300 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 312 Send(new EmbeddedWorkerHostMsg_WorkerStarted( | 301 Send(new EmbeddedWorkerHostMsg_WorkerStarted( |
| 313 WorkerTaskRunner::Instance()->CurrentWorkerId(), | 302 WorkerTaskRunner::Instance()->CurrentWorkerId(), |
| 314 embedded_worker_id_)); | 303 embedded_worker_id_)); |
| 315 } | 304 } |
| 316 | 305 |
| 317 } // namespace content | 306 } // namespace content |
| OLD | NEW |