| 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/memory/tab_manager.h" | 5 #include "chrome/browser/memory/tab_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 720 |
| 721 TabManager::WebContentsData* TabManager::GetWebContentsData( | 721 TabManager::WebContentsData* TabManager::GetWebContentsData( |
| 722 content::WebContents* contents) const { | 722 content::WebContents* contents) const { |
| 723 WebContentsData::CreateForWebContents(contents); | 723 WebContentsData::CreateForWebContents(contents); |
| 724 auto web_contents_data = WebContentsData::FromWebContents(contents); | 724 auto web_contents_data = WebContentsData::FromWebContents(contents); |
| 725 web_contents_data->set_test_tick_clock(test_tick_clock_); | 725 web_contents_data->set_test_tick_clock(test_tick_clock_); |
| 726 return web_contents_data; | 726 return web_contents_data; |
| 727 } | 727 } |
| 728 | 728 |
| 729 // static | 729 // static |
| 730 bool TabManager::CompareTabStats(TabStats first, TabStats second) { | 730 bool TabManager::CompareTabStats(const TabStats& first, |
| 731 const TabStats& second) { |
| 731 // Being currently selected is most important to protect. | 732 // Being currently selected is most important to protect. |
| 732 if (first.is_selected != second.is_selected) | 733 if (first.is_selected != second.is_selected) |
| 733 return first.is_selected; | 734 return first.is_selected; |
| 734 | 735 |
| 735 // Non auto-discardable tabs are more important to protect. | 736 // Non auto-discardable tabs are more important to protect. |
| 736 if (first.is_auto_discardable != second.is_auto_discardable) | 737 if (first.is_auto_discardable != second.is_auto_discardable) |
| 737 return !first.is_auto_discardable; | 738 return !first.is_auto_discardable; |
| 738 | 739 |
| 739 // Protect tabs with pending form entries. | 740 // Protect tabs with pending form entries. |
| 740 if (first.has_form_entry != second.has_form_entry) | 741 if (first.has_form_entry != second.has_form_entry) |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 bool TabManager::IsTabAutoDiscardable(content::WebContents* contents) const { | 925 bool TabManager::IsTabAutoDiscardable(content::WebContents* contents) const { |
| 925 return GetWebContentsData(contents)->IsAutoDiscardable(); | 926 return GetWebContentsData(contents)->IsAutoDiscardable(); |
| 926 } | 927 } |
| 927 | 928 |
| 928 void TabManager::SetTabAutoDiscardableState(content::WebContents* contents, | 929 void TabManager::SetTabAutoDiscardableState(content::WebContents* contents, |
| 929 bool state) { | 930 bool state) { |
| 930 GetWebContentsData(contents)->SetAutoDiscardableState(state); | 931 GetWebContentsData(contents)->SetAutoDiscardableState(state); |
| 931 } | 932 } |
| 932 | 933 |
| 933 } // namespace memory | 934 } // namespace memory |
| OLD | NEW |