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

Side by Side Diff: content/browser/devtools/service_worker_devtools_manager.cc

Issue 817653002: Split EmbeddedWorkerDevToolsManager into two for Shared- and ServiceWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + indent fixes Created 5 years, 12 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
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/devtools/service_worker_devtools_manager.h"
6
7 #include "content/browser/devtools/devtools_manager.h"
8 #include "content/browser/devtools/ipc_devtools_agent_host.h"
9 #include "content/browser/devtools/service_worker_devtools_agent_host.h"
10 #include "content/browser/devtools/shared_worker_devtools_agent_host.h"
11 #include "content/browser/shared_worker/shared_worker_instance.h"
12 #include "content/common/devtools_messages.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/worker_service.h"
16 #include "ipc/ipc_listener.h"
17
18 namespace content {
19
20 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
21 const ServiceWorkerContextCore* context,
22 base::WeakPtr<ServiceWorkerContextCore> context_weak,
23 int64 version_id,
24 const GURL& url)
25 : context_(context),
26 context_weak_(context_weak),
27 version_id_(version_id),
28 url_(url) {
29 }
30
31 ServiceWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
32 const ServiceWorkerIdentifier& other)
33 : context_(other.context_),
34 context_weak_(other.context_weak_),
35 version_id_(other.version_id_),
36 url_(other.url_) {
37 }
38
39 ServiceWorkerDevToolsManager::
40 ServiceWorkerIdentifier::~ServiceWorkerIdentifier() {
41 }
42
43 bool ServiceWorkerDevToolsManager::ServiceWorkerIdentifier::Matches(
44 const ServiceWorkerIdentifier& other) const {
45 return context_ == other.context_ && version_id_ == other.version_id_;
46 }
47
48 // static
49 ServiceWorkerDevToolsManager* ServiceWorkerDevToolsManager::GetInstance() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 return Singleton<ServiceWorkerDevToolsManager>::get();
52 }
53
54 bool ServiceWorkerDevToolsManager::WorkerCreated(
55 int worker_process_id,
56 int worker_route_id,
57 const ServiceWorkerIdentifier& service_worker_id) {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
59 const WorkerId id(worker_process_id, worker_route_id);
60 AgentHostMap::iterator it = FindExistingWorkerAgentHost(service_worker_id);
61 if (it == workers().end()) {
62 workers()[id] = new ServiceWorkerDevToolsAgentHost(
63 id, service_worker_id, debug_service_worker_on_start_);
64 DevToolsManager::GetInstance()->AgentHostChanged(workers()[id]);
65 return debug_service_worker_on_start_;
66 }
67 WorkerRestarted(id, it);
68 return true;
69 }
70
71 void ServiceWorkerDevToolsManager::WorkerStopIgnored(int worker_process_id,
72 int worker_route_id) {
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
74 // TODO(pfeldman): Show a console message to tell the user that UA didn't
75 // terminate the worker because devtools is attached.
76 }
77
78 ServiceWorkerDevToolsManager::ServiceWorkerDevToolsManager()
79 : debug_service_worker_on_start_(false) {
80 }
81
82 ServiceWorkerDevToolsManager::~ServiceWorkerDevToolsManager() {
83 }
84
85 ServiceWorkerDevToolsManager::AgentHostMap::iterator
86 ServiceWorkerDevToolsManager::FindExistingWorkerAgentHost(
87 const ServiceWorkerIdentifier& service_worker_id) {
88 AgentHostMap::iterator it = workers().begin();
89 for (; it != workers().end(); ++it) {
90 if (static_cast<ServiceWorkerDevToolsAgentHost*>(
91 it->second)->Matches(service_worker_id))
92 break;
93 }
94 return it;
95 }
96
97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698