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" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "content/browser/devtools/embedded_worker_devtools_manager.h" | 12 #include "content/browser/devtools/service_worker_devtools_manager.h" |
13 #include "content/browser/service_worker/embedded_worker_registry.h" | 13 #include "content/browser/service_worker/embedded_worker_registry.h" |
14 #include "content/browser/service_worker/service_worker_context_core.h" | 14 #include "content/browser/service_worker/service_worker_context_core.h" |
15 #include "content/common/service_worker/embedded_worker_messages.h" | 15 #include "content/common/service_worker/embedded_worker_messages.h" |
16 #include "content/common/service_worker/service_worker_types.h" | 16 #include "content/common/service_worker/service_worker_types.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
19 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
(...skipping 12 matching lines...) Expand all Loading... |
35 int worker_route_id) { | 35 int worker_route_id) { |
36 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 36 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
38 BrowserThread::PostTask(BrowserThread::UI, | 38 BrowserThread::PostTask(BrowserThread::UI, |
39 FROM_HERE, | 39 FROM_HERE, |
40 base::Bind(NotifyWorkerReadyForInspection, | 40 base::Bind(NotifyWorkerReadyForInspection, |
41 worker_process_id, | 41 worker_process_id, |
42 worker_route_id)); | 42 worker_route_id)); |
43 return; | 43 return; |
44 } | 44 } |
45 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( | 45 ServiceWorkerDevToolsManager::GetInstance()->WorkerReadyForInspection( |
46 worker_process_id, worker_route_id); | 46 worker_process_id, worker_route_id); |
47 } | 47 } |
48 | 48 |
49 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { | 49 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id) { |
50 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 50 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
52 BrowserThread::PostTask( | 52 BrowserThread::PostTask( |
53 BrowserThread::UI, | 53 BrowserThread::UI, |
54 FROM_HERE, | 54 FROM_HERE, |
55 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); | 55 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); |
56 return; | 56 return; |
57 } | 57 } |
58 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( | 58 ServiceWorkerDevToolsManager::GetInstance()->WorkerDestroyed( |
59 worker_process_id, worker_route_id); | 59 worker_process_id, worker_route_id); |
60 } | 60 } |
61 | 61 |
62 void NotifyWorkerStopIgnored(int worker_process_id, int worker_route_id) { | 62 void NotifyWorkerStopIgnored(int worker_process_id, int worker_route_id) { |
63 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 63 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
65 BrowserThread::PostTask(BrowserThread::UI, | 65 BrowserThread::PostTask(BrowserThread::UI, |
66 FROM_HERE, | 66 FROM_HERE, |
67 base::Bind(NotifyWorkerStopIgnored, | 67 base::Bind(NotifyWorkerStopIgnored, |
68 worker_process_id, | 68 worker_process_id, |
69 worker_route_id)); | 69 worker_route_id)); |
70 return; | 70 return; |
71 } | 71 } |
72 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerStopIgnored( | 72 ServiceWorkerDevToolsManager::GetInstance()->WorkerStopIgnored( |
73 worker_process_id, worker_route_id); | 73 worker_process_id, worker_route_id); |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 void RegisterToWorkerDevToolsManager( | 77 void RegisterToWorkerDevToolsManager( |
78 int process_id, | 78 int process_id, |
79 const ServiceWorkerContextCore* service_worker_context, | 79 const ServiceWorkerContextCore* service_worker_context, |
80 base::WeakPtr<ServiceWorkerContextCore> service_worker_context_weak, | 80 base::WeakPtr<ServiceWorkerContextCore> service_worker_context_weak, |
81 int64 service_worker_version_id, | 81 int64 service_worker_version_id, |
82 const GURL& url, | 82 const GURL& url, |
(...skipping 11 matching lines...) Expand all Loading... |
94 url, | 94 url, |
95 callback)); | 95 callback)); |
96 return; | 96 return; |
97 } | 97 } |
98 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; | 98 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; |
99 bool wait_for_debugger = false; | 99 bool wait_for_debugger = false; |
100 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { | 100 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { |
101 // |rph| may be NULL in unit tests. | 101 // |rph| may be NULL in unit tests. |
102 worker_devtools_agent_route_id = rph->GetNextRoutingID(); | 102 worker_devtools_agent_route_id = rph->GetNextRoutingID(); |
103 wait_for_debugger = | 103 wait_for_debugger = |
104 EmbeddedWorkerDevToolsManager::GetInstance()->ServiceWorkerCreated( | 104 ServiceWorkerDevToolsManager::GetInstance()->WorkerCreated( |
105 process_id, | 105 process_id, |
106 worker_devtools_agent_route_id, | 106 worker_devtools_agent_route_id, |
107 EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier( | 107 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier( |
108 service_worker_context, | 108 service_worker_context, |
109 service_worker_context_weak, | 109 service_worker_context_weak, |
110 service_worker_version_id, | 110 service_worker_version_id, |
111 url)); | 111 url)); |
112 } | 112 } |
113 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
114 BrowserThread::IO, | 114 BrowserThread::IO, |
115 FROM_HERE, | 115 FROM_HERE, |
116 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); | 116 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); |
117 } | 117 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 void EmbeddedWorkerInstance::AddListener(Listener* listener) { | 376 void EmbeddedWorkerInstance::AddListener(Listener* listener) { |
377 listener_list_.AddObserver(listener); | 377 listener_list_.AddObserver(listener); |
378 } | 378 } |
379 | 379 |
380 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) { | 380 void EmbeddedWorkerInstance::RemoveListener(Listener* listener) { |
381 listener_list_.RemoveObserver(listener); | 381 listener_list_.RemoveObserver(listener); |
382 } | 382 } |
383 | 383 |
384 } // namespace content | 384 } // namespace content |
OLD | NEW |