| 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 "chromeos/chromeos_switches.h" | 5 #include "chromeos/chromeos_switches.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 | 9 |
| 10 // TODO(rsorokin): alphabetize all of these switches so they | 10 // TODO(rsorokin): alphabetize all of these switches so they |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 bool MemoryPressureHandlingEnabled() { | 341 bool MemoryPressureHandlingEnabled() { |
| 342 if ((base::CommandLine::ForCurrentProcess()->HasSwitch( | 342 if ((base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 343 chromeos::switches::kDisableMemoryPressureSystemChromeOS)) || | 343 chromeos::switches::kDisableMemoryPressureSystemChromeOS)) || |
| 344 (base::FieldTrialList::FindFullName(kMemoryPressureExperimentName) == | 344 (base::FieldTrialList::FindFullName(kMemoryPressureExperimentName) == |
| 345 kMemoryPressureHandlingOff)) | 345 kMemoryPressureHandlingOff)) |
| 346 return false; | 346 return false; |
| 347 return true; | 347 return true; |
| 348 } | 348 } |
| 349 | 349 |
| 350 base::MemoryPressureObserverChromeOS::MemoryPressureThresholds | 350 MemoryPressureThresholds GetMemoryPressureThresholds() { |
| 351 GetMemoryPressureThresholds() { | |
| 352 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 351 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 353 kMemoryPressureThresholds)) { | 352 kMemoryPressureThresholds)) { |
| 354 const std::string group_name = | 353 const std::string group_name = |
| 355 base::FieldTrialList::FindFullName(kMemoryPressureExperimentName); | 354 base::FieldTrialList::FindFullName(kMemoryPressureExperimentName); |
| 356 if (group_name == kConservativeThreshold) | 355 if (group_name == kConservativeThreshold) |
| 357 return base::MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; | 356 return THRESHOLD_CONSERVATIVE; |
| 358 if (group_name == kAggressiveCacheDiscardThreshold) | 357 if (group_name == kAggressiveCacheDiscardThreshold) |
| 359 return base::MemoryPressureObserverChromeOS:: | 358 return THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| 360 THRESHOLD_AGGRESSIVE_CACHE_DISCARD; | |
| 361 if (group_name == kAggressiveTabDiscardThreshold) | 359 if (group_name == kAggressiveTabDiscardThreshold) |
| 362 return base::MemoryPressureObserverChromeOS:: | 360 return THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| 363 THRESHOLD_AGGRESSIVE_TAB_DISCARD; | |
| 364 if (group_name == kAggressiveThreshold) | 361 if (group_name == kAggressiveThreshold) |
| 365 return base::MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; | 362 return THRESHOLD_AGGRESSIVE; |
| 366 return base::MemoryPressureObserverChromeOS::THRESHOLD_DEFAULT; | 363 return THRESHOLD_DEFAULT; |
| 367 } | 364 } |
| 368 | 365 |
| 369 const std::string option = | 366 const std::string option = |
| 370 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 367 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 371 kMemoryPressureThresholds); | 368 kMemoryPressureThresholds); |
| 372 if (option == kConservativeThreshold) | 369 if (option == kConservativeThreshold) |
| 373 return base::MemoryPressureObserverChromeOS::THRESHOLD_CONSERVATIVE; | 370 return THRESHOLD_CONSERVATIVE; |
| 374 if (option == kAggressiveCacheDiscardThreshold) | 371 if (option == kAggressiveCacheDiscardThreshold) |
| 375 return base::MemoryPressureObserverChromeOS:: | 372 return THRESHOLD_AGGRESSIVE_CACHE_DISCARD; |
| 376 THRESHOLD_AGGRESSIVE_CACHE_DISCARD; | |
| 377 if (option == kAggressiveTabDiscardThreshold) | 373 if (option == kAggressiveTabDiscardThreshold) |
| 378 return base::MemoryPressureObserverChromeOS:: | 374 return THRESHOLD_AGGRESSIVE_TAB_DISCARD; |
| 379 THRESHOLD_AGGRESSIVE_TAB_DISCARD; | |
| 380 if (option == kAggressiveThreshold) | 375 if (option == kAggressiveThreshold) |
| 381 return base::MemoryPressureObserverChromeOS::THRESHOLD_AGGRESSIVE; | 376 return THRESHOLD_AGGRESSIVE; |
| 382 | 377 |
| 383 return base::MemoryPressureObserverChromeOS::THRESHOLD_DEFAULT; | 378 return THRESHOLD_DEFAULT; |
| 384 } | 379 } |
| 385 | 380 |
| 386 } // namespace switches | 381 } // namespace switches |
| 387 } // namespace chromeos | 382 } // namespace chromeos |
| OLD | NEW |