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/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" | 10 #include "base/bind.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 namespace { | 47 namespace { |
48 | 48 |
49 // The default interval in seconds after which to adjust the oom_score_adj | 49 // The default interval in seconds after which to adjust the oom_score_adj |
50 // value. | 50 // value. |
51 const int kAdjustmentIntervalSeconds = 10; | 51 const int kAdjustmentIntervalSeconds = 10; |
52 | 52 |
53 // The default interval in milliseconds to wait before setting the score of | 53 // The default interval in milliseconds to wait before setting the score of |
54 // currently focused tab. | 54 // currently focused tab. |
55 const int kFocusedTabScoreAdjustIntervalMs = 500; | 55 const int kFocusedTabScoreAdjustIntervalMs = 500; |
56 | 56 |
57 // Returns a unique ID for a TabContents. Do not cast back to a pointer, as | 57 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as |
58 // the TabContents could be deleted if the user closed the tab. | 58 // the WebContents could be deleted if the user closed the tab. |
59 int64 IdFromTabContents(WebContents* web_contents) { | 59 int64 IdFromTabContents(WebContents* web_contents) { |
60 return reinterpret_cast<int64>(web_contents); | 60 return reinterpret_cast<int64>(web_contents); |
61 } | 61 } |
62 | 62 |
63 // Discards a tab with the given unique ID. Returns true if discard occurred. | 63 // Discards a tab with the given unique ID. Returns true if discard occurred. |
64 bool DiscardTabById(int64 target_web_contents_id) { | 64 bool DiscardTabById(int64 target_web_contents_id) { |
65 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); | 65 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); |
66 browser_iterator != BrowserList::end(); ++browser_iterator) { | 66 browser_iterator != BrowserList::end(); ++browser_iterator) { |
67 Browser* browser = *browser_iterator; | 67 Browser* browser = *browser_iterator; |
68 TabStripModel* model = browser->tabstrip_model(); | 68 TabStripModel* model = browser->tabstrip_model(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( | 346 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( |
347 iterator->renderer_handle, score); | 347 iterator->renderer_handle, score); |
348 pid_to_oom_score_[iterator->renderer_handle] = score; | 348 pid_to_oom_score_[iterator->renderer_handle] = score; |
349 } | 349 } |
350 priority += priority_increment; | 350 priority += priority_increment; |
351 } | 351 } |
352 } | 352 } |
353 } | 353 } |
354 | 354 |
355 } // namespace browser | 355 } // namespace browser |
OLD | NEW |