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

Side by Side Diff: content/browser/service_worker/embedded_worker_registry.h

Issue 246183003: DevTools Support for ServiceWoker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; 41 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
42 42
43 explicit EmbeddedWorkerRegistry( 43 explicit EmbeddedWorkerRegistry(
44 base::WeakPtr<ServiceWorkerContextCore> context); 44 base::WeakPtr<ServiceWorkerContextCore> context);
45 45
46 bool OnMessageReceived(const IPC::Message& message); 46 bool OnMessageReceived(const IPC::Message& message);
47 47
48 // Creates and removes a new worker instance entry for bookkeeping. 48 // Creates and removes a new worker instance entry for bookkeeping.
49 // This doesn't actually start or stop the worker. 49 // This doesn't actually start or stop the worker.
50 scoped_ptr<EmbeddedWorkerInstance> CreateWorker(); 50 scoped_ptr<EmbeddedWorkerInstance> CreateWorker(const GURL& scope);
51 51
52 // Called from EmbeddedWorkerInstance, relayed to the child process. 52 // Called from EmbeddedWorkerInstance, relayed to the child process.
53 void StartWorker(const std::vector<int>& process_ids, 53 void SendStartWorker(scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
54 int embedded_worker_id, 54 const StatusCallback& callback,
55 int64 service_worker_version_id, 55 int process_id);
56 const GURL& scope,
57 const GURL& script_url,
58 const StatusCallback& callback);
59 ServiceWorkerStatusCode StopWorker(int process_id, 56 ServiceWorkerStatusCode StopWorker(int process_id,
60 int embedded_worker_id); 57 int embedded_worker_id);
61 58
62 // Stop all active workers, even if they're handling events. 59 // Stop all active workers, even if they're handling events.
63 void Shutdown(); 60 void Shutdown();
64 61
65 // Called back from EmbeddedWorker in the child process, relayed via 62 // Called back from EmbeddedWorker in the child process, relayed via
66 // ServiceWorkerDispatcherHost. 63 // ServiceWorkerDispatcherHost.
67 void OnWorkerScriptLoaded(int process_id, int embedded_worker_id); 64 void OnWorkerScriptLoaded(int process_id, int embedded_worker_id);
68 void OnWorkerScriptLoadFailed(int process_id, int embedded_worker_id); 65 void OnWorkerScriptLoadFailed(int process_id, int embedded_worker_id);
(...skipping 20 matching lines...) Expand all
89 86
90 private: 87 private:
91 friend class base::RefCounted<EmbeddedWorkerRegistry>; 88 friend class base::RefCounted<EmbeddedWorkerRegistry>;
92 friend class EmbeddedWorkerInstance; 89 friend class EmbeddedWorkerInstance;
93 90
94 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; 91 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap;
95 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; 92 typedef std::map<int, IPC::Sender*> ProcessToSenderMap;
96 93
97 ~EmbeddedWorkerRegistry(); 94 ~EmbeddedWorkerRegistry();
98 95
99 void StartWorkerWithProcessId(
100 int embedded_worker_id,
101 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params,
102 const StatusCallback& callback,
103 ServiceWorkerStatusCode status,
104 int process_id);
105
106 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message); 96 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message);
107 97
108 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. 98 // RemoveWorker is called when EmbeddedWorkerInstance is destructed.
109 // |process_id| could be invalid (i.e. -1) if it's not running. 99 // |process_id| could be invalid (i.e. -1) if it's not running.
110 void RemoveWorker(int process_id, int embedded_worker_id); 100 void RemoveWorker(int process_id, int embedded_worker_id);
111 101
112 base::WeakPtr<ServiceWorkerContextCore> context_; 102 base::WeakPtr<ServiceWorkerContextCore> context_;
113 103
114 WorkerInstanceMap worker_map_; 104 WorkerInstanceMap worker_map_;
115 ProcessToSenderMap process_sender_map_; 105 ProcessToSenderMap process_sender_map_;
116 106
117 // Map from process_id to embedded_worker_id. 107 // Map from process_id to embedded_worker_id.
118 // This map only contains running workers. 108 // This map only contains running workers.
119 std::map<int, std::set<int> > worker_process_map_; 109 std::map<int, std::set<int> > worker_process_map_;
120 110
121 int next_embedded_worker_id_; 111 int next_embedded_worker_id_;
122 112
123 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); 113 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry);
124 }; 114 };
125 115
126 } // namespace content 116 } // namespace content
127 117
128 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ 118 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698