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

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

Issue 8960010: base::Bind: Convert NewRunnableMethod in chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix 55. Created 9 years 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
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/bind.h"
11 #include "base/bind_helpers.h"
10 #include "base/process.h" 12 #include "base/process.h"
11 #include "base/process_util.h" 13 #include "base/process_util.h"
12 #include "base/string16.h" 14 #include "base/string16.h"
13 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
14 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
15 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
16 #include "base/timer.h" 18 #include "base/timer.h"
17 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
18 #include "build/build_config.h" 20 #include "build/build_config.h"
19 #include "chrome/browser/tabs/tab_strip_model.h" 21 #include "chrome/browser/tabs/tab_strip_model.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
175 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_); 177 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_);
176 ZygoteHost::GetInstance()->AdjustRendererOOMScore( 178 ZygoteHost::GetInstance()->AdjustRendererOOMScore(
177 focused_tab_pid_, chrome::kLowestRendererOomScore); 179 focused_tab_pid_, chrome::kLowestRendererOomScore);
178 pid_to_oom_score_[focused_tab_pid_] = chrome::kLowestRendererOomScore; 180 pid_to_oom_score_[focused_tab_pid_] = chrome::kLowestRendererOomScore;
179 } 181 }
180 182
181 void OomPriorityManager::OnFocusTabScoreAdjustmentTimeout() { 183 void OomPriorityManager::OnFocusTabScoreAdjustmentTimeout() {
182 BrowserThread::PostTask( 184 BrowserThread::PostTask(
183 BrowserThread::FILE, FROM_HERE, 185 BrowserThread::FILE, FROM_HERE,
184 NewRunnableMethod( 186 base::Bind(&OomPriorityManager::AdjustFocusedTabScoreOnFileThread,
185 this, &OomPriorityManager::AdjustFocusedTabScoreOnFileThread)); 187 base::Unretained(this)));
186 } 188 }
187 189
188 void OomPriorityManager::Observe(int type, 190 void OomPriorityManager::Observe(int type,
189 const content::NotificationSource& source, 191 const content::NotificationSource& source,
190 const content::NotificationDetails& details) { 192 const content::NotificationDetails& details) {
191 base::ProcessHandle handle = 0; 193 base::ProcessHandle handle = 0;
192 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_); 194 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_);
193 switch (type) { 195 switch (type) {
194 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 196 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
195 handle = 197 handle =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // TabStripModel isn't thread safe): 246 // TabStripModel isn't thread safe):
245 // 1) whether or not a tab is pinned 247 // 1) whether or not a tab is pinned
246 // 2) last time a tab was selected 248 // 2) last time a tab was selected
247 // 3) is the tab currently selected 249 // 3) is the tab currently selected
248 void OomPriorityManager::AdjustOomPriorities() { 250 void OomPriorityManager::AdjustOomPriorities() {
249 if (BrowserList::size() == 0) 251 if (BrowserList::size() == 0)
250 return; 252 return;
251 TabStatsList stats_list = GetTabStatsOnUIThread(); 253 TabStatsList stats_list = GetTabStatsOnUIThread();
252 BrowserThread::PostTask( 254 BrowserThread::PostTask(
253 BrowserThread::FILE, FROM_HERE, 255 BrowserThread::FILE, FROM_HERE,
254 NewRunnableMethod(this, 256 base::Bind(&OomPriorityManager::AdjustOomPrioritiesOnFileThread,
255 &OomPriorityManager::AdjustOomPrioritiesOnFileThread, 257 base::Unretained(this), stats_list));
256 stats_list));
257 } 258 }
258 259
259 OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() { 260 OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() {
260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
261 TabStatsList stats_list; 262 TabStatsList stats_list;
262 stats_list.reserve(32); // 99% of users have < 30 tabs open 263 stats_list.reserve(32); // 99% of users have < 30 tabs open
263 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); 264 for (BrowserList::const_iterator browser_iterator = BrowserList::begin();
264 browser_iterator != BrowserList::end(); ++browser_iterator) { 265 browser_iterator != BrowserList::end(); ++browser_iterator) {
265 Browser* browser = *browser_iterator; 266 Browser* browser = *browser_iterator;
266 const TabStripModel* model = browser->tabstrip_model(); 267 const TabStripModel* model = browser->tabstrip_model();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 ZygoteHost::GetInstance()->AdjustRendererOOMScore( 325 ZygoteHost::GetInstance()->AdjustRendererOOMScore(
325 iterator->renderer_handle, score); 326 iterator->renderer_handle, score);
326 pid_to_oom_score_[iterator->renderer_handle] = score; 327 pid_to_oom_score_[iterator->renderer_handle] = score;
327 } 328 }
328 priority += priority_increment; 329 priority += priority_increment;
329 } 330 }
330 } 331 }
331 } 332 }
332 333
333 } // namespace browser 334 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/oom_priority_manager.h ('k') | chrome/browser/renderer_host/chrome_render_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698