| 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 |
| 95 private: | 100 private: |
| 96 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; | 101 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
| 97 friend class SharedWorkerServiceImplTest; | 102 friend class SharedWorkerServiceImplTest; |
| 98 | 103 |
| 99 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, | 104 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, |
| 100 const std::vector<int>&); | 105 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; |
| 101 | 110 |
| 102 SharedWorkerServiceImpl(); | 111 SharedWorkerServiceImpl(); |
| 103 virtual ~SharedWorkerServiceImpl(); | 112 virtual ~SharedWorkerServiceImpl(); |
| 104 | 113 |
| 105 void ResetForTesting(); | 114 void ResetForTesting(); |
| 106 | 115 |
| 107 SharedWorkerHost* FindSharedWorkerHost( | 116 SharedWorkerHost* FindSharedWorkerHost( |
| 108 SharedWorkerMessageFilter* filter, | 117 SharedWorkerMessageFilter* filter, |
| 109 int worker_route_id); | 118 int worker_route_id); |
| 110 | 119 |
| 111 SharedWorkerHost* FindSharedWorkerHost( | 120 static SharedWorkerHost* FindSharedWorkerHost( |
| 121 const WorkerHostMap& hosts, |
| 112 const GURL& url, | 122 const GURL& url, |
| 113 const base::string16& name, | 123 const base::string16& name, |
| 114 const WorkerStoragePartition& worker_partition, | 124 const WorkerStoragePartition& worker_partition, |
| 115 ResourceContext* resource_context); | 125 ResourceContext* resource_context); |
| 116 | 126 |
| 117 // Returns the IDs of the renderer processes which are executing | 127 // Returns the IDs of the renderer processes which are executing |
| 118 // SharedWorkers connected to other renderer processes. | 128 // SharedWorkers connected to other renderer processes. |
| 119 const std::set<int> GetRenderersWithWorkerDependency(); | 129 const std::set<int> GetRenderersWithWorkerDependency(); |
| 120 | 130 |
| 121 void ChangeUpdateWorkerDependencyFuncForTesting( | 131 void ChangeUpdateWorkerDependencyFuncForTesting( |
| 122 UpdateWorkerDependencyFunc new_func); | 132 UpdateWorkerDependencyFunc new_func); |
| 123 | 133 |
| 124 std::set<int> last_worker_depended_renderers_; | 134 std::set<int> last_worker_depended_renderers_; |
| 125 UpdateWorkerDependencyFunc update_worker_dependency_; | 135 UpdateWorkerDependencyFunc update_worker_dependency_; |
| 126 | 136 |
| 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; | |
| 131 WorkerHostMap worker_hosts_; | 137 WorkerHostMap worker_hosts_; |
| 138 WorkerHostMap pending_worker_hosts_; |
| 132 | 139 |
| 133 ObserverList<WorkerServiceObserver> observers_; | 140 ObserverList<WorkerServiceObserver> observers_; |
| 134 | 141 |
| 135 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 142 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
| 136 }; | 143 }; |
| 137 | 144 |
| 138 } // namespace content | 145 } // namespace content |
| 139 | 146 |
| 140 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 147 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
| OLD | NEW |