Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Side by Side Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 470923004: DevTools: DevToolsAgentHost::Close/GetURL for service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed crash Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/devtools/embedded_worker_devtools_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 FROM_HERE, 49 FROM_HERE,
50 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id)); 50 base::Bind(NotifyWorkerDestroyed, worker_process_id, worker_route_id));
51 return; 51 return;
52 } 52 }
53 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed( 53 EmbeddedWorkerDevToolsManager::GetInstance()->WorkerDestroyed(
54 worker_process_id, worker_route_id); 54 worker_process_id, worker_route_id);
55 } 55 }
56 56
57 void RegisterToWorkerDevToolsManager( 57 void RegisterToWorkerDevToolsManager(
58 int process_id, 58 int process_id,
59 const ServiceWorkerContextCore* const service_worker_context, 59 const ServiceWorkerContextCore* service_worker_context,
60 base::WeakPtr<ServiceWorkerContextCore> service_worker_context_weak,
60 int64 service_worker_version_id, 61 int64 service_worker_version_id,
62 const GURL& url,
61 const base::Callback<void(int worker_devtools_agent_route_id, 63 const base::Callback<void(int worker_devtools_agent_route_id,
62 bool wait_for_debugger)>& callback) { 64 bool wait_for_debugger)>& callback) {
63 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 65 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
64 BrowserThread::PostTask(BrowserThread::UI, 66 BrowserThread::PostTask(BrowserThread::UI,
65 FROM_HERE, 67 FROM_HERE,
66 base::Bind(RegisterToWorkerDevToolsManager, 68 base::Bind(RegisterToWorkerDevToolsManager,
67 process_id, 69 process_id,
68 service_worker_context, 70 service_worker_context,
71 service_worker_context_weak,
69 service_worker_version_id, 72 service_worker_version_id,
73 url,
70 callback)); 74 callback));
71 return; 75 return;
72 } 76 }
73 int worker_devtools_agent_route_id = MSG_ROUTING_NONE; 77 int worker_devtools_agent_route_id = MSG_ROUTING_NONE;
74 bool wait_for_debugger = false; 78 bool wait_for_debugger = false;
75 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) { 79 if (RenderProcessHost* rph = RenderProcessHost::FromID(process_id)) {
76 // |rph| may be NULL in unit tests. 80 // |rph| may be NULL in unit tests.
77 worker_devtools_agent_route_id = rph->GetNextRoutingID(); 81 worker_devtools_agent_route_id = rph->GetNextRoutingID();
78 wait_for_debugger = 82 wait_for_debugger =
79 EmbeddedWorkerDevToolsManager::GetInstance()->ServiceWorkerCreated( 83 EmbeddedWorkerDevToolsManager::GetInstance()->ServiceWorkerCreated(
80 process_id, 84 process_id,
81 worker_devtools_agent_route_id, 85 worker_devtools_agent_route_id,
82 EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier( 86 EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier(
83 service_worker_context, service_worker_version_id)); 87 service_worker_context,
88 service_worker_context_weak,
89 service_worker_version_id,
90 url));
84 } 91 }
85 BrowserThread::PostTask( 92 BrowserThread::PostTask(
86 BrowserThread::IO, 93 BrowserThread::IO,
87 FROM_HERE, 94 FROM_HERE,
88 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger)); 95 base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger));
89 } 96 }
90 97
91 } // namespace 98 } // namespace
92 99
93 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() { 100 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 int process_id, 223 int process_id,
217 ServiceWorkerStatusCode status) { 224 ServiceWorkerStatusCode status) {
218 DCHECK_EQ(process_id_, -1); 225 DCHECK_EQ(process_id_, -1);
219 if (status != SERVICE_WORKER_OK) { 226 if (status != SERVICE_WORKER_OK) {
220 status_ = STOPPED; 227 status_ = STOPPED;
221 callback.Run(status); 228 callback.Run(status);
222 return; 229 return;
223 } 230 }
224 const int64 service_worker_version_id = params->service_worker_version_id; 231 const int64 service_worker_version_id = params->service_worker_version_id;
225 process_id_ = process_id; 232 process_id_ = process_id;
233 GURL script_url(params->script_url);
226 RegisterToWorkerDevToolsManager( 234 RegisterToWorkerDevToolsManager(
227 process_id, 235 process_id,
228 context_.get(), 236 context_.get(),
237 context_,
229 service_worker_version_id, 238 service_worker_version_id,
239 script_url,
230 base::Bind(&EmbeddedWorkerInstance::SendStartWorker, 240 base::Bind(&EmbeddedWorkerInstance::SendStartWorker,
231 weak_factory_.GetWeakPtr(), 241 weak_factory_.GetWeakPtr(),
232 base::Passed(&params), 242 base::Passed(&params),
233 callback)); 243 callback));
234 } 244 }
235 245
236 void EmbeddedWorkerInstance::SendStartWorker( 246 void EmbeddedWorkerInstance::SendStartWorker(
237 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, 247 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
238 const StatusCallback& callback, 248 const StatusCallback& callback,
239 int worker_devtools_agent_route_id, 249 int worker_devtools_agent_route_id,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Sort descending by the reference count. 349 // Sort descending by the reference count.
340 std::sort(counted.begin(), counted.end(), SecondGreater()); 350 std::sort(counted.begin(), counted.end(), SecondGreater());
341 351
342 std::vector<int> result(counted.size()); 352 std::vector<int> result(counted.size());
343 for (size_t i = 0; i < counted.size(); ++i) 353 for (size_t i = 0; i < counted.size(); ++i)
344 result[i] = counted[i].first; 354 result[i] = counted[i].first;
345 return result; 355 return result;
346 } 356 }
347 357
348 } // namespace content 358 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/embedded_worker_devtools_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698