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

Side by Side Diff: chrome/browser/oom_priority_manager.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/notifications/balloon_host.cc ('k') | chrome/browser/pdf_unsupported_feature.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/oom_priority_manager.h" 5 #include "chrome/browser/oom_priority_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/process.h" 10 #include "base/process.h"
11 #include "base/process_util.h" 11 #include "base/process_util.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/tabs/tab_strip_model.h" 19 #include "chrome/browser/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
22 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
23 #include "content/browser/renderer_host/render_process_host.h"
24 #include "content/browser/renderer_host/render_widget_host.h" 23 #include "content/browser/renderer_host/render_widget_host.h"
25 #include "content/browser/tab_contents/tab_contents.h" 24 #include "content/browser/tab_contents/tab_contents.h"
26 #include "content/browser/zygote_host_linux.h" 25 #include "content/browser/zygote_host_linux.h"
27 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_service.h" 27 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/render_process_host.h"
30 30
31 #if !defined(OS_CHROMEOS) 31 #if !defined(OS_CHROMEOS)
32 #error This file only meant to be compiled on ChromeOS 32 #error This file only meant to be compiled on ChromeOS
33 #endif 33 #endif
34 34
35 using base::TimeDelta; 35 using base::TimeDelta;
36 using base::TimeTicks; 36 using base::TimeTicks;
37 using base::ProcessHandle; 37 using base::ProcessHandle;
38 using base::ProcessMetrics; 38 using base::ProcessMetrics;
39 using content::BrowserThread; 39 using content::BrowserThread;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 void OomPriorityManager::Observe(int type, 188 void OomPriorityManager::Observe(int type,
189 const content::NotificationSource& source, 189 const content::NotificationSource& source,
190 const content::NotificationDetails& details) { 190 const content::NotificationDetails& details) {
191 base::ProcessHandle handle = 0; 191 base::ProcessHandle handle = 0;
192 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_); 192 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_);
193 switch (type) { 193 switch (type) {
194 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 194 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
195 handle = 195 handle =
196 content::Details<RenderProcessHost::RendererClosedDetails>(details)-> 196 content::Details<content::RenderProcessHost::RendererClosedDetails>(
197 handle; 197 details)->handle;
198 pid_to_oom_score_.erase(handle); 198 pid_to_oom_score_.erase(handle);
199 break; 199 break;
200 } 200 }
201 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { 201 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
202 handle = content::Source<RenderProcessHost>(source)->GetHandle(); 202 handle = content::Source<content::RenderProcessHost>(source)->
203 GetHandle();
203 pid_to_oom_score_.erase(handle); 204 pid_to_oom_score_.erase(handle);
204 break; 205 break;
205 } 206 }
206 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: { 207 case content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: {
207 bool visible = *content::Details<bool>(details).ptr(); 208 bool visible = *content::Details<bool>(details).ptr();
208 if (visible) { 209 if (visible) {
209 focused_tab_pid_ = content::Source<RenderWidgetHost>(source).ptr()-> 210 focused_tab_pid_ = content::Source<RenderWidgetHost>(source).ptr()->
210 process()->GetHandle(); 211 process()->GetHandle();
211 212
212 // If the currently focused tab already has a lower score, do not 213 // If the currently focused tab already has a lower score, do not
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ZygoteHost::GetInstance()->AdjustRendererOOMScore( 324 ZygoteHost::GetInstance()->AdjustRendererOOMScore(
324 iterator->renderer_handle, score); 325 iterator->renderer_handle, score);
325 pid_to_oom_score_[iterator->renderer_handle] = score; 326 pid_to_oom_score_[iterator->renderer_handle] = score;
326 } 327 }
327 priority += priority_increment; 328 priority += priority_increment;
328 } 329 }
329 } 330 }
330 } 331 }
331 332
332 } // namespace browser 333 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/notifications/balloon_host.cc ('k') | chrome/browser/pdf_unsupported_feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698