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 <set> | 8 #include <set> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 SharedWorkerMessageFilter* filter); | 85 SharedWorkerMessageFilter* filter); |
86 | 86 |
87 void OnSharedWorkerMessageFilterClosing( | 87 void OnSharedWorkerMessageFilterClosing( |
88 SharedWorkerMessageFilter* filter); | 88 SharedWorkerMessageFilter* filter); |
89 | 89 |
90 // Checks the worker dependency of renderer processes and calls | 90 // Checks the worker dependency of renderer processes and calls |
91 // IncrementWorkerRefCount and DecrementWorkerRefCount of | 91 // IncrementWorkerRefCount and DecrementWorkerRefCount of |
92 // RenderProcessHostImpl on UI thread if necessary. | 92 // RenderProcessHostImpl on UI thread if necessary. |
93 void CheckWorkerDependency(); | 93 void CheckWorkerDependency(); |
94 | 94 |
95 void WorkerCreatedResultCallback(int worker_process_id, | |
96 int worker_route_id, | |
97 bool pause_on_start); | |
98 void NotifyWorkerDestroyed(int worker_process_id, int worker_route_id); | |
99 | |
100 private: | 95 private: |
101 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; | 96 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
102 friend class SharedWorkerServiceImplTest; | 97 friend class SharedWorkerServiceImplTest; |
103 | 98 |
104 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, | 99 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, |
105 const std::vector<int>&); | 100 const std::vector<int>&); |
106 // Pair of render_process_id and worker_route_id. | |
107 typedef std::pair<int, int> ProcessRouteIdPair; | |
108 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, SharedWorkerHost> | |
109 WorkerHostMap; | |
110 | 101 |
111 SharedWorkerServiceImpl(); | 102 SharedWorkerServiceImpl(); |
112 virtual ~SharedWorkerServiceImpl(); | 103 virtual ~SharedWorkerServiceImpl(); |
113 | 104 |
114 void ResetForTesting(); | 105 void ResetForTesting(); |
115 | 106 |
116 SharedWorkerHost* FindSharedWorkerHost( | 107 SharedWorkerHost* FindSharedWorkerHost( |
117 SharedWorkerMessageFilter* filter, | 108 SharedWorkerMessageFilter* filter, |
118 int worker_route_id); | 109 int worker_route_id); |
119 | 110 |
120 static SharedWorkerHost* FindSharedWorkerHost( | 111 SharedWorkerHost* FindSharedWorkerHost( |
121 const WorkerHostMap& hosts, | |
122 const GURL& url, | 112 const GURL& url, |
123 const base::string16& name, | 113 const base::string16& name, |
124 const WorkerStoragePartition& worker_partition, | 114 const WorkerStoragePartition& worker_partition, |
125 ResourceContext* resource_context); | 115 ResourceContext* resource_context); |
126 | 116 |
127 // Returns the IDs of the renderer processes which are executing | 117 // Returns the IDs of the renderer processes which are executing |
128 // SharedWorkers connected to other renderer processes. | 118 // SharedWorkers connected to other renderer processes. |
129 const std::set<int> GetRenderersWithWorkerDependency(); | 119 const std::set<int> GetRenderersWithWorkerDependency(); |
130 | 120 |
131 void ChangeUpdateWorkerDependencyFuncForTesting( | 121 void ChangeUpdateWorkerDependencyFuncForTesting( |
132 UpdateWorkerDependencyFunc new_func); | 122 UpdateWorkerDependencyFunc new_func); |
133 | 123 |
134 std::set<int> last_worker_depended_renderers_; | 124 std::set<int> last_worker_depended_renderers_; |
135 UpdateWorkerDependencyFunc update_worker_dependency_; | 125 UpdateWorkerDependencyFunc update_worker_dependency_; |
136 | 126 |
| 127 // Pair of render_process_id and worker_route_id. |
| 128 typedef std::pair<int, int> ProcessRouteIdPair; |
| 129 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, |
| 130 SharedWorkerHost> WorkerHostMap; |
137 WorkerHostMap worker_hosts_; | 131 WorkerHostMap worker_hosts_; |
138 WorkerHostMap pending_worker_hosts_; | |
139 | 132 |
140 ObserverList<WorkerServiceObserver> observers_; | 133 ObserverList<WorkerServiceObserver> observers_; |
141 | 134 |
142 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 135 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
143 }; | 136 }; |
144 | 137 |
145 } // namespace content | 138 } // namespace content |
146 | 139 |
147 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 140 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |