OLD | NEW |
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_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "content/common/shared_worker.mojom.h" |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/worker_service.h" | 21 #include "content/public/browser/worker_service.h" |
21 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" | 22 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" |
22 | 23 |
23 struct ViewHostMsg_CreateWorker_Params; | |
24 | |
25 namespace IPC { | 24 namespace IPC { |
26 class Message; | 25 class Message; |
27 } | 26 } |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 | 29 |
31 class SharedWorkerInstance; | 30 class SharedWorkerInstance; |
32 class SharedWorkerHost; | 31 class SharedWorkerHost; |
33 class SharedWorkerMessageFilter; | 32 class SharedWorkerMessageFilter; |
34 class ResourceContext; | 33 class ResourceContext; |
35 class WorkerServiceObserver; | 34 class WorkerServiceObserver; |
36 class WorkerStoragePartitionId; | 35 class WorkerStoragePartitionId; |
37 | 36 |
38 // The implementation of WorkerService. We try to place workers in an existing | 37 // The implementation of WorkerService. We try to place workers in an existing |
39 // renderer process when possible. | 38 // renderer process when possible. |
40 class CONTENT_EXPORT SharedWorkerServiceImpl | 39 class CONTENT_EXPORT SharedWorkerServiceImpl |
41 : public NON_EXPORTED_BASE(WorkerService) { | 40 : public NON_EXPORTED_BASE(WorkerService) { |
42 public: | 41 public: |
43 // Returns the SharedWorkerServiceImpl singleton. | 42 // Returns the SharedWorkerServiceImpl singleton. |
44 static SharedWorkerServiceImpl* GetInstance(); | 43 static SharedWorkerServiceImpl* GetInstance(); |
45 | 44 |
46 // WorkerService implementation: | 45 // WorkerService implementation: |
47 bool TerminateWorker(int process_id, int route_id) override; | 46 bool TerminateWorker(int process_id, int route_id) override; |
48 std::vector<WorkerInfo> GetWorkers() override; | 47 std::vector<WorkerInfo> GetWorkers() override; |
49 void AddObserver(WorkerServiceObserver* observer) override; | 48 void AddObserver(WorkerServiceObserver* observer) override; |
50 void RemoveObserver(WorkerServiceObserver* observer) override; | 49 void RemoveObserver(WorkerServiceObserver* observer) override; |
51 | 50 |
52 // These methods correspond to worker related IPCs. | 51 // These methods correspond to worker related IPCs. |
53 blink::WebWorkerCreationError CreateWorker( | 52 blink::WebWorkerCreationError CreateWorker( |
54 const ViewHostMsg_CreateWorker_Params& params, | 53 mojom::SharedWorkerCreateParamsPtr params, |
55 int route_id, | 54 int route_id, |
56 SharedWorkerMessageFilter* filter, | 55 SharedWorkerMessageFilter* filter, |
57 ResourceContext* resource_context, | 56 ResourceContext* resource_context, |
58 const WorkerStoragePartitionId& partition_id); | 57 const WorkerStoragePartitionId& partition_id); |
59 void ConnectToWorker(int route_id, | 58 void ConnectToWorker(int route_id, |
60 int sent_message_port_id, | 59 int sent_message_port_id, |
61 SharedWorkerMessageFilter* filter); | 60 SharedWorkerMessageFilter* filter); |
62 void DocumentDetached(unsigned long long document_id, | 61 void DocumentDetached(unsigned long long document_id, |
63 SharedWorkerMessageFilter* filter); | 62 SharedWorkerMessageFilter* filter); |
64 void WorkerContextClosed(int worker_route_id, | 63 void WorkerContextClosed(int worker_route_id, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 int next_pending_instance_id_; | 172 int next_pending_instance_id_; |
174 | 173 |
175 base::ObserverList<WorkerServiceObserver> observers_; | 174 base::ObserverList<WorkerServiceObserver> observers_; |
176 | 175 |
177 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 176 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
178 }; | 177 }; |
179 | 178 |
180 } // namespace content | 179 } // namespace content |
181 | 180 |
182 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 181 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |