| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 return false; | 343 return false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Do not discard a tab that was explicitly disallowed to. | 346 // Do not discard a tab that was explicitly disallowed to. |
| 347 if (!IsTabAutoDiscardable(web_contents)) | 347 if (!IsTabAutoDiscardable(web_contents)) |
| 348 return false; | 348 return false; |
| 349 | 349 |
| 350 return true; | 350 return true; |
| 351 } | 351 } |
| 352 | 352 |
| 353 void TabManager::DiscardTab() { | 353 bool TabManager::DiscardTab() { |
| 354 #if defined(OS_CHROMEOS) | 354 #if defined(OS_CHROMEOS) |
| 355 // Call Chrome OS specific low memory handling process. | 355 // Call Chrome OS specific low memory handling process. |
| 356 if (base::FeatureList::IsEnabled(features::kArcMemoryManagement)) { | 356 if (base::FeatureList::IsEnabled(features::kArcMemoryManagement)) { |
| 357 delegate_->LowMemoryKill(GetUnsortedTabStats()); | 357 delegate_->LowMemoryKill(GetUnsortedTabStats()); |
| 358 return; | 358 return false; |
| 359 } | 359 } |
| 360 #endif | 360 #endif |
| 361 DiscardTabImpl(); | 361 return DiscardTabImpl() != nullptr; |
| 362 } | 362 } |
| 363 | 363 |
| 364 WebContents* TabManager::DiscardTabById(int64_t target_web_contents_id) { | 364 WebContents* TabManager::DiscardTabById(int64_t target_web_contents_id) { |
| 365 TabStripModel* model; | 365 TabStripModel* model; |
| 366 int index = FindTabStripModelById(target_web_contents_id, &model); | 366 int index = FindTabStripModelById(target_web_contents_id, &model); |
| 367 | 367 |
| 368 if (index == -1) | 368 if (index == -1) |
| 369 return nullptr; | 369 return nullptr; |
| 370 | 370 |
| 371 VLOG(1) << "Discarding tab " << index << " id " << target_web_contents_id; | 371 VLOG(1) << "Discarding tab " << index << " id " << target_web_contents_id; |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 // platform. | 1031 // platform. |
| 1032 std::string allow_multiple_discards = variations::GetVariationParamValue( | 1032 std::string allow_multiple_discards = variations::GetVariationParamValue( |
| 1033 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); | 1033 features::kAutomaticTabDiscarding.name, "AllowMultipleDiscards"); |
| 1034 return (allow_multiple_discards != "true"); | 1034 return (allow_multiple_discards != "true"); |
| 1035 #else | 1035 #else |
| 1036 return false; | 1036 return false; |
| 1037 #endif | 1037 #endif |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 } // namespace memory | 1040 } // namespace memory |
| OLD | NEW |