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 <memory> |
8 #include <set> | 9 #include <set> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/containers/scoped_ptr_hash_map.h" | 12 #include "base/containers/scoped_ptr_hash_map.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/worker_service.h" | 18 #include "content/public/browser/worker_service.h" |
19 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" | 19 #include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h" |
20 | 20 |
21 struct ViewHostMsg_CreateWorker_Params; | 21 struct ViewHostMsg_CreateWorker_Params; |
22 | 22 |
23 namespace IPC { | 23 namespace IPC { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 friend struct base::DefaultSingletonTraits<SharedWorkerServiceImpl>; | 98 friend struct base::DefaultSingletonTraits<SharedWorkerServiceImpl>; |
99 friend class SharedWorkerServiceImplTest; | 99 friend class SharedWorkerServiceImplTest; |
100 | 100 |
101 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, | 101 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, |
102 const std::vector<int>&); | 102 const std::vector<int>&); |
103 typedef bool (*TryIncrementWorkerRefCountFunc)(bool); | 103 typedef bool (*TryIncrementWorkerRefCountFunc)(bool); |
104 // Pair of render_process_id and worker_route_id. | 104 // Pair of render_process_id and worker_route_id. |
105 typedef std::pair<int, int> ProcessRouteIdPair; | 105 typedef std::pair<int, int> ProcessRouteIdPair; |
106 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, | 106 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, |
107 scoped_ptr<SharedWorkerHost>> WorkerHostMap; | 107 std::unique_ptr<SharedWorkerHost>> |
108 typedef base::ScopedPtrHashMap<int, scoped_ptr<SharedWorkerPendingInstance>> | 108 WorkerHostMap; |
| 109 typedef base::ScopedPtrHashMap<int, |
| 110 std::unique_ptr<SharedWorkerPendingInstance>> |
109 PendingInstanceMap; | 111 PendingInstanceMap; |
110 | 112 |
111 SharedWorkerServiceImpl(); | 113 SharedWorkerServiceImpl(); |
112 ~SharedWorkerServiceImpl() override; | 114 ~SharedWorkerServiceImpl() override; |
113 | 115 |
114 void ResetForTesting(); | 116 void ResetForTesting(); |
115 | 117 |
116 // Reserves the render process to create Shared Worker. This reservation | 118 // Reserves the render process to create Shared Worker. This reservation |
117 // procedure will be executed on UI thread and | 119 // procedure will be executed on UI thread and |
118 // RenderProcessReservedCallback() or RenderProcessReserveFailedCallback() | 120 // RenderProcessReservedCallback() or RenderProcessReserveFailedCallback() |
119 // will be called on IO thread. | 121 // will be called on IO thread. |
120 void ReserveRenderProcessToCreateWorker( | 122 void ReserveRenderProcessToCreateWorker( |
121 scoped_ptr<SharedWorkerPendingInstance> pending_instance, | 123 std::unique_ptr<SharedWorkerPendingInstance> pending_instance, |
122 blink::WebWorkerCreationError* creation_error); | 124 blink::WebWorkerCreationError* creation_error); |
123 | 125 |
124 // Called after the render process is reserved to create Shared Worker in it. | 126 // Called after the render process is reserved to create Shared Worker in it. |
125 void RenderProcessReservedCallback(int pending_instance_id, | 127 void RenderProcessReservedCallback(int pending_instance_id, |
126 int worker_process_id, | 128 int worker_process_id, |
127 int worker_route_id, | 129 int worker_route_id, |
128 bool is_new_worker, | 130 bool is_new_worker, |
129 bool pause_on_start); | 131 bool pause_on_start); |
130 | 132 |
131 // Called after the fast shutdown is detected while reserving the render | 133 // Called after the fast shutdown is detected while reserving the render |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 int next_pending_instance_id_; | 165 int next_pending_instance_id_; |
164 | 166 |
165 base::ObserverList<WorkerServiceObserver> observers_; | 167 base::ObserverList<WorkerServiceObserver> observers_; |
166 | 168 |
167 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 169 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
168 }; | 170 }; |
169 | 171 |
170 } // namespace content | 172 } // namespace content |
171 | 173 |
172 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 174 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |