| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // ServiceWorkerDispatcherHost. | 53 // ServiceWorkerDispatcherHost. |
| 54 void OnWorkerStarted(int process_id, int thread_id, int embedded_worker_id); | 54 void OnWorkerStarted(int process_id, int thread_id, int embedded_worker_id); |
| 55 void OnWorkerStopped(int process_id, int embedded_worker_id); | 55 void OnWorkerStopped(int process_id, int embedded_worker_id); |
| 56 void OnSendMessageToBrowser(int embedded_worker_id, | 56 void OnSendMessageToBrowser(int embedded_worker_id, |
| 57 const IPC::Message& message); | 57 const IPC::Message& message); |
| 58 | 58 |
| 59 // Keeps a map from process_id to sender information. | 59 // Keeps a map from process_id to sender information. |
| 60 void AddChildProcessSender(int process_id, IPC::Sender* sender); | 60 void AddChildProcessSender(int process_id, IPC::Sender* sender); |
| 61 void RemoveChildProcessSender(int process_id); | 61 void RemoveChildProcessSender(int process_id); |
| 62 | 62 |
| 63 // For testing and internals-inspecting |
| 64 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; |
| 65 const WorkerInstanceMap& worker_instances() const { return worker_map_; } |
| 66 |
| 63 private: | 67 private: |
| 64 friend class base::RefCounted<EmbeddedWorkerRegistry>; | 68 friend class base::RefCounted<EmbeddedWorkerRegistry>; |
| 65 friend class EmbeddedWorkerInstance; | 69 friend class EmbeddedWorkerInstance; |
| 66 | 70 |
| 67 typedef std::map<int, EmbeddedWorkerInstance*> WorkerInstanceMap; | |
| 68 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; | 71 typedef std::map<int, IPC::Sender*> ProcessToSenderMap; |
| 69 | 72 |
| 70 ~EmbeddedWorkerRegistry(); | 73 ~EmbeddedWorkerRegistry(); |
| 71 bool Send(int process_id, IPC::Message* message); | 74 bool Send(int process_id, IPC::Message* message); |
| 72 | 75 |
| 73 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. | 76 // RemoveWorker is called when EmbeddedWorkerInstance is destructed. |
| 74 // |process_id| could be invalid (i.e. -1) if it's not running. | 77 // |process_id| could be invalid (i.e. -1) if it's not running. |
| 75 void RemoveWorker(int process_id, int embedded_worker_id); | 78 void RemoveWorker(int process_id, int embedded_worker_id); |
| 76 | 79 |
| 77 base::WeakPtr<ServiceWorkerContextCore> context_; | 80 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 78 | 81 |
| 79 WorkerInstanceMap worker_map_; | 82 WorkerInstanceMap worker_map_; |
| 80 ProcessToSenderMap process_sender_map_; | 83 ProcessToSenderMap process_sender_map_; |
| 81 | 84 |
| 82 // Map from process_id to embedded_worker_id. | 85 // Map from process_id to embedded_worker_id. |
| 83 // This map only contains running workers. | 86 // This map only contains running workers. |
| 84 std::map<int, int> worker_process_map_; | 87 std::map<int, int> worker_process_map_; |
| 85 | 88 |
| 86 int next_embedded_worker_id_; | 89 int next_embedded_worker_id_; |
| 87 | 90 |
| 88 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); | 91 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerRegistry); |
| 89 }; | 92 }; |
| 90 | 93 |
| 91 } // namespace content | 94 } // namespace content |
| 92 | 95 |
| 93 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ | 96 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_REGISTRY_H_ |
| OLD | NEW |