Chromium Code Reviews| Index: content/browser/shared_worker/shared_worker_service_impl.h |
| diff --git a/content/browser/shared_worker/shared_worker_service_impl.h b/content/browser/shared_worker/shared_worker_service_impl.h |
| index fd199894dedda196572c545976c37a06cc68eb1e..31f505c89847d962a906f54b0239ea0926276f9c 100644 |
| --- a/content/browser/shared_worker/shared_worker_service_impl.h |
| +++ b/content/browser/shared_worker/shared_worker_service_impl.h |
| @@ -5,6 +5,8 @@ |
| #ifndef CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
| #define CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ |
| +#include <set> |
| + |
| #include "base/compiler_specific.h" |
| #include "base/containers/scoped_ptr_hash_map.h" |
| #include "base/memory/singleton.h" |
| @@ -87,10 +89,27 @@ class CONTENT_EXPORT SharedWorkerServiceImpl |
| private: |
| friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; |
| + friend class SharedWorkerServiceImplTest; |
| + |
| + typedef void (*UpdateWorkerDependencyFunc)(const std::vector<int>, |
| + const std::vector<int>); |
|
kinuko
2014/03/10 04:25:43
const vector<int>& ?
horo
2014/03/10 11:48:31
Done.
|
| + |
| + class CONTENT_EXPORT ScopedWorkerDependencyChecker { |
|
kinuko
2014/03/10 04:25:43
Does this class need to be exported? In a quick l
horo
2014/03/10 11:48:31
Done.
Moved to .cc.
|
| + public: |
| + explicit ScopedWorkerDependencyChecker(SharedWorkerServiceImpl* service) |
| + : service_(service) {} |
| + ~ScopedWorkerDependencyChecker() { service_->CheckWorkerDependency(); } |
| + |
| + private: |
| + SharedWorkerServiceImpl* service_; |
| + DISALLOW_COPY_AND_ASSIGN(ScopedWorkerDependencyChecker); |
| + }; |
| SharedWorkerServiceImpl(); |
| virtual ~SharedWorkerServiceImpl(); |
| + void ResetForTesting(); |
| + |
| SharedWorkerHost* FindSharedWorkerHost( |
| SharedWorkerMessageFilter* filter, |
| int worker_route_id); |
| @@ -101,6 +120,21 @@ class CONTENT_EXPORT SharedWorkerServiceImpl |
| const WorkerStoragePartition& worker_partition, |
| ResourceContext* resource_context); |
| + // Returns the IDs of the renderer processes which are executing |
| + // SharedWorkers connected to other renderer processes. |
| + const std::set<int> GetRenderersWithWorkerDependency(); |
| + |
| + // Checks the worker dependency of renderer processes and calls |
| + // IncrementWorkerRefCount and DecrementWorkerRefCount of |
| + // RenderProcessHostImpl on UI thread if necessary. |
| + void CheckWorkerDependency(); |
| + |
| + void ChangeUpdateWorkerDependencyFuncForTesting( |
| + UpdateWorkerDependencyFunc new_func); |
| + |
| + std::set<int> last_worker_depended_renderers_; |
| + UpdateWorkerDependencyFunc update_worker_dependency_; |
| + |
| // Pair of render_process_id and worker_route_id. |
| typedef std::pair<int, int> ProcessRouteIdPair; |
| typedef base::ScopedPtrHashMap<ProcessRouteIdPair, |