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> |
| 9 |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
10 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
11 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
12 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
14 #include "content/public/browser/worker_service.h" | 16 #include "content/public/browser/worker_service.h" |
15 | 17 |
16 struct ViewHostMsg_CreateWorker_Params; | 18 struct ViewHostMsg_CreateWorker_Params; |
17 | 19 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SharedWorkerMessageFilter* filter); | 80 SharedWorkerMessageFilter* filter); |
79 void AllowIndexedDB(int worker_route_id, | 81 void AllowIndexedDB(int worker_route_id, |
80 const GURL& url, | 82 const GURL& url, |
81 const base::string16& name, | 83 const base::string16& name, |
82 bool* result, | 84 bool* result, |
83 SharedWorkerMessageFilter* filter); | 85 SharedWorkerMessageFilter* filter); |
84 | 86 |
85 void OnSharedWorkerMessageFilterClosing( | 87 void OnSharedWorkerMessageFilterClosing( |
86 SharedWorkerMessageFilter* filter); | 88 SharedWorkerMessageFilter* filter); |
87 | 89 |
| 90 // Checks the worker dependency of renderer processes and calls |
| 91 // IncrementWorkerRefCount and DecrementWorkerRefCount of |
| 92 // RenderProcessHostImpl on UI thread if necessary. |
| 93 void CheckWorkerDependency(); |
| 94 |
88 private: | 95 private: |
89 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; | 96 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
| 97 friend class SharedWorkerServiceImplTest; |
| 98 |
| 99 typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>&, |
| 100 const std::vector<int>&); |
90 | 101 |
91 SharedWorkerServiceImpl(); | 102 SharedWorkerServiceImpl(); |
92 virtual ~SharedWorkerServiceImpl(); | 103 virtual ~SharedWorkerServiceImpl(); |
93 | 104 |
| 105 void ResetForTesting(); |
| 106 |
94 SharedWorkerHost* FindSharedWorkerHost( | 107 SharedWorkerHost* FindSharedWorkerHost( |
95 SharedWorkerMessageFilter* filter, | 108 SharedWorkerMessageFilter* filter, |
96 int worker_route_id); | 109 int worker_route_id); |
97 | 110 |
98 SharedWorkerInstance* FindSharedWorkerInstance( | 111 SharedWorkerInstance* FindSharedWorkerInstance( |
99 const GURL& url, | 112 const GURL& url, |
100 const base::string16& name, | 113 const base::string16& name, |
101 const WorkerStoragePartition& worker_partition, | 114 const WorkerStoragePartition& worker_partition, |
102 ResourceContext* resource_context); | 115 ResourceContext* resource_context); |
103 | 116 |
| 117 // Returns the IDs of the renderer processes which are executing |
| 118 // SharedWorkers connected to other renderer processes. |
| 119 const std::set<int> GetRenderersWithWorkerDependency(); |
| 120 |
| 121 void ChangeUpdateWorkerDependencyFuncForTesting( |
| 122 UpdateWorkerDependencyFunc new_func); |
| 123 |
| 124 std::set<int> last_worker_depended_renderers_; |
| 125 UpdateWorkerDependencyFunc update_worker_dependency_; |
| 126 |
104 // Pair of render_process_id and worker_route_id. | 127 // Pair of render_process_id and worker_route_id. |
105 typedef std::pair<int, int> ProcessRouteIdPair; | 128 typedef std::pair<int, int> ProcessRouteIdPair; |
106 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, | 129 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, |
107 SharedWorkerHost> WorkerHostMap; | 130 SharedWorkerHost> WorkerHostMap; |
108 WorkerHostMap worker_hosts_; | 131 WorkerHostMap worker_hosts_; |
109 | 132 |
110 ObserverList<WorkerServiceObserver> observers_; | 133 ObserverList<WorkerServiceObserver> observers_; |
111 | 134 |
112 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); | 135 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); |
113 }; | 136 }; |
114 | 137 |
115 } // namespace content | 138 } // namespace content |
116 | 139 |
117 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ | 140 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
OLD | NEW |