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/browser/service_worker/embedded_worker_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 FROM_HERE, | 38 FROM_HERE, |
39 base::Bind(NotifyWorkerReadyForInspection, | 39 base::Bind(NotifyWorkerReadyForInspection, |
40 worker_process_id, | 40 worker_process_id, |
41 worker_route_id)); | 41 worker_route_id)); |
42 return; | 42 return; |
43 } | 43 } |
44 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( | 44 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( |
45 worker_process_id, worker_route_id); | 45 worker_process_id, worker_route_id); |
46 } | 46 } |
47 | 47 |
48 void NotifyWorkerContextStarted(int worker_process_id, int worker_route_id) { | |
49 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
50 BrowserThread::PostTask( | |
51 BrowserThread::UI, | |
52 FROM_HERE, | |
53 base::Bind( | |
54 NotifyWorkerContextStarted, worker_process_id, worker_route_id)); | |
55 return; | |
56 } | |
57 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerContextStarted( | |
58 worker_process_id, worker_route_id); | |
59 } | |
60 | |
61 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { | 48 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { |
62 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 49 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
63 BrowserThread::PostTask( | 50 BrowserThread::PostTask( |
64 BrowserThread::UI, | 51 BrowserThread::UI, |
65 FROM_HERE, | 52 FROM_HERE, |
66 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); | 53 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); |
67 return; | 54 return; |
68 } | 55 } |
69 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( | 56 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( |
70 worker_process_id, worker_route_id); | 57 worker_process_id, worker_route_id); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 251 } |
265 | 252 |
266 void EmbeddedWorkerInstance::OnReadyForInspection() { | 253 void EmbeddedWorkerInstance::OnReadyForInspection() { |
267 if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE) | 254 if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE) |
268 NotifyWorkerReadyForInspection(process_id_, | 255 NotifyWorkerReadyForInspection(process_id_, |
269 worker_devtools_agent_route_id_); | 256 worker_devtools_agent_route_id_); |
270 } | 257 } |
271 | 258 |
272 void EmbeddedWorkerInstance::OnScriptLoaded(int thread_id) { | 259 void EmbeddedWorkerInstance::OnScriptLoaded(int thread_id) { |
273 thread_id_ = thread_id; | 260 thread_id_ = thread_id; |
274 if (worker_devtools_agent_route_id_ != MSG_ROUTING_NONE) | |
275 NotifyWorkerContextStarted(process_id_, worker_devtools_agent_route_id_); | |
276 } | 261 } |
277 | 262 |
278 void EmbeddedWorkerInstance::OnScriptLoadFailed() { | 263 void EmbeddedWorkerInstance::OnScriptLoadFailed() { |
279 } | 264 } |
280 | 265 |
281 void EmbeddedWorkerInstance::OnStarted() { | 266 void EmbeddedWorkerInstance::OnStarted() { |
282 // Stop is requested before OnStarted is sent back from the worker. | 267 // Stop is requested before OnStarted is sent back from the worker. |
283 if (status_ == STOPPING) | 268 if (status_ == STOPPING) |
284 return; | 269 return; |
285 DCHECK(status_ == STARTING); | 270 DCHECK(status_ == STARTING); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 327 |
343 void EmbeddedWorkerInstance::AddListener(Listener* listener) { | 328 void EmbeddedWorkerInstance::AddListener(Listener* listener) { |
344 listener_list_.AddObserver(listener); | 329 listener_list_.AddObserver(listener); |
345 } | 330 } |
346 | 331 |
347 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) { | 332 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) { |
348 listener_list_.RemoveObserver(listener); | 333 listener_list_.RemoveObserver(listener); |
349 } | 334 } |
350 | 335 |
351 } // namespace content | 336 } // namespace content |
OLD | NEW |