OLD | NEW |
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" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool GetRendererForWorker(int worker_process_id, | 65 bool GetRendererForWorker(int worker_process_id, |
66 int* render_process_id, | 66 int* render_process_id, |
67 int* render_view_id) const; | 67 int* render_view_id) const; |
68 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( | 68 const WorkerProcessHost::WorkerInstance* FindWorkerInstance( |
69 int worker_process_id); | 69 int worker_process_id); |
70 | 70 |
71 void NotifyWorkerDestroyed( | 71 void NotifyWorkerDestroyed( |
72 WorkerProcessHost* process, | 72 WorkerProcessHost* process, |
73 int worker_route_id); | 73 int worker_route_id); |
74 | 74 |
75 // Used when multiple workers can run in the same process. | |
76 static const int kMaxWorkerProcessesWhenSharing; | |
77 | |
78 // Used when we run each worker in a separate process. | 75 // Used when we run each worker in a separate process. |
79 static const int kMaxWorkersWhenSeparate; | 76 static const int kMaxWorkersWhenSeparate; |
80 static const int kMaxWorkersPerTabWhenSeparate; | 77 static const int kMaxWorkersPerTabWhenSeparate; |
81 | 78 |
82 private: | 79 private: |
83 friend struct DefaultSingletonTraits<WorkerServiceImpl>; | 80 friend struct DefaultSingletonTraits<WorkerServiceImpl>; |
84 | 81 |
85 WorkerServiceImpl(); | 82 WorkerServiceImpl(); |
86 virtual ~WorkerServiceImpl(); | 83 virtual ~WorkerServiceImpl(); |
87 | 84 |
88 // Given a WorkerInstance, create an associated worker process. | 85 // Given a WorkerInstance, create an associated worker process. |
89 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); | 86 bool CreateWorkerFromInstance(WorkerProcessHost::WorkerInstance instance); |
90 | 87 |
91 // Returns a WorkerProcessHost object if one exists for the given domain, or | |
92 // NULL if there are no such workers yet. | |
93 WorkerProcessHost* GetProcessForDomain(const GURL& url); | |
94 | |
95 // Returns a WorkerProcessHost based on a strategy of creating one worker per | |
96 // core. | |
97 WorkerProcessHost* GetProcessToFillUpCores(); | |
98 | |
99 // Returns the WorkerProcessHost from the existing set that has the least | |
100 // number of worker instance running. | |
101 WorkerProcessHost* GetLeastLoadedWorker(); | |
102 | |
103 // Checks if we can create a worker process based on the process limit when | 88 // Checks if we can create a worker process based on the process limit when |
104 // we're using a strategy of one process per core. | 89 // we're using a strategy of one process per core. |
105 bool CanCreateWorkerProcess( | 90 bool CanCreateWorkerProcess( |
106 const WorkerProcessHost::WorkerInstance& instance); | 91 const WorkerProcessHost::WorkerInstance& instance); |
107 | 92 |
108 // Checks if the tab associated with the passed RenderView can create a | 93 // Checks if the tab associated with the passed RenderView can create a |
109 // worker process based on the process limit when we're using a strategy of | 94 // worker process based on the process limit when we're using a strategy of |
110 // one worker per process. | 95 // one worker per process. |
111 bool TabCanCreateWorkerProcess( | 96 bool TabCanCreateWorkerProcess( |
112 int render_process_id, int render_route_id, bool* hit_total_worker_limit); | 97 int render_process_id, int render_route_id, bool* hit_total_worker_limit); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 WorkerProcessHost::Instances pending_shared_workers_; | 133 WorkerProcessHost::Instances pending_shared_workers_; |
149 | 134 |
150 ObserverList<WorkerServiceObserver> observers_; | 135 ObserverList<WorkerServiceObserver> observers_; |
151 | 136 |
152 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); | 137 DISALLOW_COPY_AND_ASSIGN(WorkerServiceImpl); |
153 }; | 138 }; |
154 | 139 |
155 } // namespace content | 140 } // namespace content |
156 | 141 |
157 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ | 142 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_SERVICE_H_ |
OLD | NEW |