| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 476 |
| 477 void TabManager::OnAutoDiscardableStateChange(content::WebContents* contents, | 477 void TabManager::OnAutoDiscardableStateChange(content::WebContents* contents, |
| 478 bool is_auto_discardable) { | 478 bool is_auto_discardable) { |
| 479 FOR_EACH_OBSERVER( | 479 FOR_EACH_OBSERVER( |
| 480 TabManagerObserver, observers_, | 480 TabManagerObserver, observers_, |
| 481 OnAutoDiscardableStateChange(contents, is_auto_discardable)); | 481 OnAutoDiscardableStateChange(contents, is_auto_discardable)); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // static | 484 // static |
| 485 void TabManager::PurgeMemoryAndDiscardTab() { | 485 void TabManager::PurgeMemoryAndDiscardTab() { |
| 486 if (g_browser_process && g_browser_process->GetTabManager()) { | 486 TabManager* manager = g_browser_process->GetTabManager(); |
| 487 TabManager* manager = g_browser_process->GetTabManager(); | 487 manager->PurgeBrowserMemory(); |
| 488 manager->PurgeBrowserMemory(); | 488 manager->DiscardTab(); |
| 489 manager->DiscardTab(); | |
| 490 } | |
| 491 } | 489 } |
| 492 | 490 |
| 493 // static | 491 // static |
| 494 bool TabManager::IsInternalPage(const GURL& url) { | 492 bool TabManager::IsInternalPage(const GURL& url) { |
| 495 // There are many chrome:// UI URLs, but only look for the ones that users | 493 // There are many chrome:// UI URLs, but only look for the ones that users |
| 496 // are likely to have open. Most of the benefit is the from NTP URL. | 494 // are likely to have open. Most of the benefit is the from NTP URL. |
| 497 const char* const kInternalPagePrefixes[] = { | 495 const char* const kInternalPagePrefixes[] = { |
| 498 chrome::kChromeUIDownloadsURL, chrome::kChromeUIHistoryURL, | 496 chrome::kChromeUIDownloadsURL, chrome::kChromeUIHistoryURL, |
| 499 chrome::kChromeUINewTabURL, chrome::kChromeUISettingsURL, | 497 chrome::kChromeUINewTabURL, chrome::kChromeUISettingsURL, |
| 500 }; | 498 }; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 // platform. | 936 // platform. |
| 939 std::string allow_multiple_discards = variations::GetVariationParamValue( | 937 std::string allow_multiple_discards = variations::GetVariationParamValue( |
| 940 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 938 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| 941 return (allow_multiple_discards != "true"); | 939 return (allow_multiple_discards != "true"); |
| 942 #else | 940 #else |
| 943 return false; | 941 return false; |
| 944 #endif | 942 #endif |
| 945 } | 943 } |
| 946 | 944 |
| 947 } // namespace memory | 945 } // namespace memory |
| OLD | NEW |