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

Side by Side Diff: content/browser/devtools/embedded_worker_devtools_manager.h

Issue 262773004: Add ServiceWorker support in EmbeddedWorkerDevToolsManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename service_worker_path to storage_partition_path Created 6 years, 7 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 | « no previous file | content/browser/devtools/embedded_worker_devtools_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/files/file_path.h"
10 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "content/browser/shared_worker/shared_worker_instance.h" 15 #include "content/browser/shared_worker/shared_worker_instance.h"
15 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace content { 20 namespace content {
(...skipping 10 matching lines...) Expand all
30 // Returns the EmbeddedWorkerDevToolsManager singleton. 31 // Returns the EmbeddedWorkerDevToolsManager singleton.
31 static EmbeddedWorkerDevToolsManager* GetInstance(); 32 static EmbeddedWorkerDevToolsManager* GetInstance();
32 33
33 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id, 34 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
34 int worker_route_id); 35 int worker_route_id);
35 36
36 // Returns true when the worker must be paused on start. 37 // Returns true when the worker must be paused on start.
37 bool SharedWorkerCreated(int worker_process_id, 38 bool SharedWorkerCreated(int worker_process_id,
38 int worker_route_id, 39 int worker_route_id,
39 const SharedWorkerInstance& instance); 40 const SharedWorkerInstance& instance);
41 // Returns true when the worker must be paused on start.
42 // TODO(horo): Currently we identify ServiceWorkers with the path of storage
43 // partition and the scope of ServiceWorker. Consider having a class like
44 // SharedWorkerInstance instead of the pair.
45 bool ServiceWorkerCreated(int worker_process_id,
46 int worker_route_id,
47 const base::FilePath& storage_partition_path,
48 const GURL& service_worker_scope);
49 void WorkerContextStarted(int worker_process_id, int worker_route_id);
40 void WorkerDestroyed(int worker_process_id, int worker_route_id); 50 void WorkerDestroyed(int worker_process_id, int worker_route_id);
41 void WorkerContextStarted(int worker_process_id, int worker_route_id);
42 51
43 private: 52 private:
44 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; 53 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>;
45 friend class EmbeddedWorkerDevToolsManagerTest; 54 friend class EmbeddedWorkerDevToolsManagerTest;
46 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); 55 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest);
47 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); 56 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest);
48 57
49 enum WorkerState { 58 enum WorkerState {
50 WORKER_UNINSPECTED, 59 WORKER_UNINSPECTED,
51 WORKER_INSPECTED, 60 WORKER_INSPECTED,
52 WORKER_TERMINATED, 61 WORKER_TERMINATED,
53 WORKER_PAUSED, 62 WORKER_PAUSED,
54 }; 63 };
55 64
56 class WorkerInfo { 65 class WorkerInfo {
57 public: 66 public:
58 explicit WorkerInfo(const SharedWorkerInstance& instance) 67 // Creates WorkerInfo for SharedWorker.
59 : instance_(instance), state_(WORKER_UNINSPECTED), agent_host_(NULL) {} 68 explicit WorkerInfo(const SharedWorkerInstance& instance);
69 // Creates WorkerInfo for ServiceWorker.
70 WorkerInfo(const base::FilePath& storage_partition_path,
71 const GURL& service_worker_scope);
72 ~WorkerInfo();
60 73
61 const SharedWorkerInstance& instance() const { return instance_; }
62 WorkerState state() { return state_; } 74 WorkerState state() { return state_; }
63 void set_state(WorkerState new_state) { state_ = new_state; } 75 void set_state(WorkerState new_state) { state_ = new_state; }
64 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } 76 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; }
65 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { 77 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) {
66 agent_host_ = agent_host; 78 agent_host_ = agent_host;
67 } 79 }
80 bool Matches(const SharedWorkerInstance& other);
81 bool Matches(const base::FilePath& other_storage_partition_path,
82 const GURL& other_service_worker_scope);
68 83
69 private: 84 private:
70 const SharedWorkerInstance instance_; 85 scoped_ptr<SharedWorkerInstance> shared_worker_instance_;
86 scoped_ptr<base::FilePath> storage_partition_path_;
87 scoped_ptr<GURL> service_worker_scope_;
71 WorkerState state_; 88 WorkerState state_;
72 EmbeddedWorkerDevToolsAgentHost* agent_host_; 89 EmbeddedWorkerDevToolsAgentHost* agent_host_;
73 }; 90 };
74 91
75 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; 92 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap;
76 93
77 EmbeddedWorkerDevToolsManager(); 94 EmbeddedWorkerDevToolsManager();
78 virtual ~EmbeddedWorkerDevToolsManager(); 95 virtual ~EmbeddedWorkerDevToolsManager();
79 96
80 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); 97 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host);
81 98
82 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( 99 WorkerInfoMap::iterator FindExistingSharedWorkerInfo(
83 const SharedWorkerInstance& instance); 100 const SharedWorkerInstance& instance);
101 WorkerInfoMap::iterator FindExistingServiceWorkerInfo(
102 const base::FilePath& storage_partition_path,
103 const GURL& service_worker_scope);
104
105 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it);
84 106
85 // Resets to its initial state as if newly created. 107 // Resets to its initial state as if newly created.
86 void ResetForTesting(); 108 void ResetForTesting();
87 109
88 WorkerInfoMap workers_; 110 WorkerInfoMap workers_;
89 111
90 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); 112 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager);
91 }; 113 };
92 114
93 } // namespace content 115 } // namespace content
94 116
95 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 117 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/embedded_worker_devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698