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

Side by Side Diff: content/browser/worker_host/worker_service_impl.h

Issue 14137016: Lower the priority of shared workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move register out of constructor. Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_WORKER_HOST_WORKER_SERVICE_H_ 5 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "content/browser/worker_host/worker_process_host.h" 13 #include "content/browser/worker_host/worker_process_host.h"
14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/worker_service.h" 16 #include "content/public/browser/worker_service.h"
16 17
17 class GURL; 18 class GURL;
18 struct ViewHostMsg_CreateWorker_Params; 19 struct ViewHostMsg_CreateWorker_Params;
19 20
20 namespace content { 21 namespace content {
21 class ResourceContext; 22 class ResourceContext;
22 class WorkerServiceObserver; 23 class WorkerServiceObserver;
23 class WorkerStoragePartition; 24 class WorkerStoragePartition;
25 class WorkerPrioritySetter;
24 26
25 class CONTENT_EXPORT WorkerServiceImpl 27 class CONTENT_EXPORT WorkerServiceImpl
26 : public NON_EXPORTED_BASE(WorkerService) { 28 : public NON_EXPORTED_BASE(WorkerService) {
27 public: 29 public:
28 // Returns the WorkerServiceImpl singleton. 30 // Returns the WorkerServiceImpl singleton.
29 static WorkerServiceImpl* GetInstance(); 31 static WorkerServiceImpl* GetInstance();
30 32
31 // WorkerService implementation: 33 // WorkerService implementation:
32 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE; 34 virtual bool TerminateWorker(int process_id, int route_id) OVERRIDE;
33 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE; 35 virtual std::vector<WorkerInfo> GetWorkers() OVERRIDE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 bool GetRendererForWorker(int worker_process_id, 67 bool GetRendererForWorker(int worker_process_id,
66 int* render_process_id, 68 int* render_process_id,
67 int* render_view_id) const; 69 int* render_view_id) const;
68 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( 70 const WorkerProcessHost::WorkerInstance* FindWorkerInstance(
69 int worker_process_id); 71 int worker_process_id);
70 72
71 void NotifyWorkerDestroyed( 73 void NotifyWorkerDestroyed(
72 WorkerProcessHost* process, 74 WorkerProcessHost* process,
73 int worker_route_id); 75 int worker_route_id);
74 76
77 void NotifyWorkerProcessCreated();
78
75 // Used when we run each worker in a separate process. 79 // Used when we run each worker in a separate process.
76 static const int kMaxWorkersWhenSeparate; 80 static const int kMaxWorkersWhenSeparate;
77 static const int kMaxWorkersPerTabWhenSeparate; 81 static const int kMaxWorkersPerTabWhenSeparate;
78 82
79 private: 83 private:
80 friend struct DefaultSingletonTraits<WorkerServiceImpl>; 84 friend struct DefaultSingletonTraits<WorkerServiceImpl>;
81 85
82 WorkerServiceImpl(); 86 WorkerServiceImpl();
83 virtual ~WorkerServiceImpl(); 87 virtual ~WorkerServiceImpl();
84 88
(...skipping 30 matching lines...) Expand all
115 const string16& name, 119 const string16& name,
116 const WorkerStoragePartition& worker_partition, 120 const WorkerStoragePartition& worker_partition,
117 ResourceContext* resource_context); 121 ResourceContext* resource_context);
118 122
119 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance( 123 WorkerProcessHost::WorkerInstance* FindSharedWorkerInstance(
120 const GURL& url, 124 const GURL& url,
121 const string16& name, 125 const string16& name,
122 const WorkerStoragePartition& worker_partition, 126 const WorkerStoragePartition& worker_partition,
123 ResourceContext* resource_context); 127 ResourceContext* resource_context);
124 128
125 NotificationRegistrar registrar_; 129 scoped_refptr<WorkerPrioritySetter> priority_setter_;
130
126 int next_worker_route_id_; 131 int next_worker_route_id_;
127 132
128 WorkerProcessHost::Instances queued_workers_; 133 WorkerProcessHost::Instances queued_workers_;
129 134
130 // These are shared workers that have been looked up, but not created yet. 135 // These are shared workers that have been looked up, but not created yet.
131 // We need to keep a list of these to synchronously detect shared worker 136 // We need to keep a list of these to synchronously detect shared worker
132 // URL mismatches when two pages launch shared workers simultaneously. 137 // URL mismatches when two pages launch shared workers simultaneously.
133 WorkerProcessHost::Instances pending_shared_workers_; 138 WorkerProcessHost::Instances pending_shared_workers_;
134 139
135 ObserverList<WorkerServiceObserver> observers_; 140 ObserverList<WorkerServiceObserver> observers_;
136 141
137 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); 142 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl);
138 }; 143 };
139 144
140 } // namespace content 145 } // namespace content
141 146
142 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ 147 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698