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