Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: content/browser/shared_worker/shared_worker_service_impl.h

Issue 187533002: Add SharedWorkerServiceImpl::CheckWorkerDependency(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ExternalClient
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/shared_worker/shared_worker_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
88 private: 90 private:
89 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>; 91 friend struct DefaultSingletonTraits<SharedWorkerServiceImpl>;
90 92
93 class CONTENT_EXPORT ScopedWorkerDependencyChecker {
94 public:
95 ScopedWorkerDependencyChecker(SharedWorkerServiceImpl* service_impl)
kinuko 2014/03/05 08:03:47 nit: explicit
horo 2014/03/05 08:16:58 Done.
96 : service_impl_(service_impl) {}
97 ~ScopedWorkerDependencyChecker() { service_impl_->CheckWorkerDependency(); }
98
99 private:
100 SharedWorkerServiceImpl* service_impl_;
101 DISALLOW_COPY_AND_ASSIGN(ScopedWorkerDependencyChecker);
102 };
103
91 SharedWorkerServiceImpl(); 104 SharedWorkerServiceImpl();
92 virtual ~SharedWorkerServiceImpl(); 105 virtual ~SharedWorkerServiceImpl();
93 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> GetWorkerDependedRenderers();
kinuko 2014/03/05 08:03:47 GetRenderersWithWorkerDependency? 'worker-depende
horo 2014/03/05 08:16:58 Done.
120
121 // Checks the worker dependency of renderer processes and calls
122 // IncrementWorkerRefCount and DecrementWorkerRefCount of
123 // RenderProcessHostImpl on UI thread if necessary.
124 void CheckWorkerDependency();
125
126 std::set<int> last_worker_depended_renderers_;
127
104 // Pair of render_process_id and worker_route_id. 128 // Pair of render_process_id and worker_route_id.
105 typedef std::pair<int, int> ProcessRouteIdPair; 129 typedef std::pair<int, int> ProcessRouteIdPair;
106 typedef base::ScopedPtrHashMap<ProcessRouteIdPair, 130 typedef base::ScopedPtrHashMap<ProcessRouteIdPair,
107 SharedWorkerHost> WorkerHostMap; 131 SharedWorkerHost> WorkerHostMap;
108 WorkerHostMap worker_hosts_; 132 WorkerHostMap worker_hosts_;
109 133
110 ObserverList<WorkerServiceObserver> observers_; 134 ObserverList<WorkerServiceObserver> observers_;
111 135
112 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl); 136 DISALLOW_COPY_AND_ASSIGN(SharedWorkerServiceImpl);
113 }; 137 };
114 138
115 } // namespace content 139 } // namespace content
116 140
117 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_ 141 #endif // CONTENT_BROWSER_SHARED_WORKER_SHARED_WORKER_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/shared_worker/shared_worker_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698