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 #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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/service_worker/service_worker_status_code.h" | 18 #include "content/common/service_worker/service_worker_status_code.h" |
19 | 19 |
20 class EmbeddedWorkerMsg_StartWorker; | 20 struct EmbeddedWorkerMsg_StartWorker_Params; |
21 class GURL; | 21 class GURL; |
22 | 22 |
23 namespace IPC { | 23 namespace IPC { |
24 class Message; | 24 class Message; |
25 class Sender; | 25 class Sender; |
26 } | 26 } |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 | 29 |
30 class EmbeddedWorkerInstance; | 30 class EmbeddedWorkerInstance; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 friend class base::RefCounted<EmbeddedWorkerRegistry>; | 89 friend class base::RefCounted<EmbeddedWorkerRegistry>; |
90 friend class EmbeddedWorkerInstance; | 90 friend class EmbeddedWorkerInstance; |
91 | 91 |
92 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; | 92 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; |
93 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; | 93 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; |
94 | 94 |
95 ~EmbeddedWorkerRegistry(); | 95 ~EmbeddedWorkerRegistry(); |
96 | 96 |
97 void StartWorkerWithProcessId( | 97 void StartWorkerWithProcessId( |
98 int embedded_worker_id, | 98 int embedded_worker_id, |
99 scoped_ptr<EmbeddedWorkerMsg_StartWorker> message, | 99 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params, |
100 const StatusCallback& callback, | 100 const StatusCallback& callback, |
101 ServiceWorkerStatusCode status, | 101 ServiceWorkerStatusCode status, |
102 int process_id); | 102 int process_id); |
103 | 103 |
104 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message); | 104 ServiceWorkerStatusCode Send(int process_id, IPC::Message* message); |
105 | 105 |
106 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. | 106 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. |
107 // |process_id| could be invalid (i.e. -1) if it's not running. | 107 // |process_id| could be invalid (i.e. -1) if it's not running. |
108 void RemoveWorker(int process_id, int embedded_worker_id); | 108 void RemoveWorker(int process_id, int embedded_worker_id); |
109 | 109 |
110 base::WeakPtr<ServiceWorkerContextCore> context_; | 110 base::WeakPtr<ServiceWorkerContextCore> context_; |
111 | 111 |
112 WorkerInstanceMap worker_map_; | 112 WorkerInstanceMap worker_map_; |
113 ProcessToSenderMap process_sender_map_; | 113 ProcessToSenderMap process_sender_map_; |
114 | 114 |
115 // Map from process_id to embedded_worker_id. | 115 // Map from process_id to embedded_worker_id. |
116 // This map only contains running workers. | 116 // This map only contains running workers. |
117 std::map<int, std::set<int> > worker_process_map_; | 117 std::map<int, std::set<int> > worker_process_map_; |
118 | 118 |
119 int next_embedded_worker_id_; | 119 int next_embedded_worker_id_; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); | 121 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); |
122 }; | 122 }; |
123 | 123 |
124 } // namespace content | 124 } // namespace content |
125 | 125 |
126 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 126 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
OLD | NEW |