Chromium Code Reviews| 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 #include "chrome/browser/chromeos/oom_priority_manager.h" | 5 #include "chrome/browser/chromeos/oom_priority_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 OomMemoryDetails* details = new OomMemoryDetails(); | 223 OomMemoryDetails* details = new OomMemoryDetails(); |
| 224 details->StartFetch(MemoryDetails::SKIP_USER_METRICS); | 224 details->StartFetch(MemoryDetails::SKIP_USER_METRICS); |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool OomPriorityManager::DiscardTabById(int64 target_web_contents_id) { | 227 bool OomPriorityManager::DiscardTabById(int64 target_web_contents_id) { |
| 228 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); | 228 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); |
| 229 browser_iterator != BrowserList::end(); ++browser_iterator) { | 229 browser_iterator != BrowserList::end(); ++browser_iterator) { |
| 230 Browser* browser = *browser_iterator; | 230 Browser* browser = *browser_iterator; |
| 231 TabStripModel* model = browser->tab_strip_model(); | 231 TabStripModel* model = browser->tab_strip_model(); |
| 232 for (int idx = 0; idx < model->count(); idx++) { | 232 for (int idx = 0; idx < model->count(); idx++) { |
| 233 // Can't discard tabs that are already discarded. | 233 // Can't discard tabs that are already discarded or selected. |
| 234 if (model->IsTabDiscarded(idx)) | 234 if (model->IsTabDiscarded(idx) || model->IsTabSelected(idx)) |
|
sky
2012/09/24 13:56:11
Is it the selected tab, or the active tab we care
simonhong_
2012/09/24 15:15:46
Done.
| |
| 235 continue; | 235 continue; |
| 236 WebContents* web_contents = model->GetTabContentsAt(idx)->web_contents(); | 236 WebContents* web_contents = model->GetTabContentsAt(idx)->web_contents(); |
| 237 int64 web_contents_id = IdFromTabContents(web_contents); | 237 int64 web_contents_id = IdFromTabContents(web_contents); |
| 238 if (web_contents_id == target_web_contents_id) { | 238 if (web_contents_id == target_web_contents_id) { |
| 239 LOG(WARNING) << "Discarding tab " << idx | 239 LOG(WARNING) << "Discarding tab " << idx |
| 240 << " id " << target_web_contents_id; | 240 << " id " << target_web_contents_id; |
| 241 // Record statistics before discarding because we want to capture the | 241 // Record statistics before discarding because we want to capture the |
| 242 // memory state that lead to the discard. | 242 // memory state that lead to the discard. |
| 243 RecordDiscardStatistics(); | 243 RecordDiscardStatistics(); |
| 244 model->DiscardTabContentsAt(idx); | 244 model->DiscardTabContentsAt(idx); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( | 511 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( |
| 512 iterator->renderer_handle, score); | 512 iterator->renderer_handle, score); |
| 513 pid_to_oom_score_[iterator->renderer_handle] = score; | 513 pid_to_oom_score_[iterator->renderer_handle] = score; |
| 514 } | 514 } |
| 515 priority += priority_increment; | 515 priority += priority_increment; |
| 516 } | 516 } |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 } // namespace chromeos | 520 } // namespace chromeos |
| OLD | NEW |