diff options
author | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-18 10:21:48 +0000 |
---|---|---|
committer | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-18 10:21:48 +0000 |
commit | f2df311eeacd60442fe2f697da9f7e19fc34706b (patch) | |
tree | 9d0e3d08568a3d8f44c2db33f95b9c5854e80a05 /chrome/browser/prefs | |
parent | a92b7ea0346250312708856c6af3842cce0061dc (diff) | |
download | chromium_src-f2df311eeacd60442fe2f697da9f7e19fc34706b.zip chromium_src-f2df311eeacd60442fe2f697da9f7e19fc34706b.tar.gz chromium_src-f2df311eeacd60442fe2f697da9f7e19fc34706b.tar.bz2 |
Add policies to control the disk cache size.
Two new policies added:
DiskCacheSize (general cache size)
MediaCacheSize (cache size for media files)
BUG=100549
TEST=unit_tests *Policy*
Review URL: http://codereview.chromium.org/8572006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-rw-r--r-- | chrome/browser/prefs/command_line_pref_store.cc | 24 | ||||
-rw-r--r-- | chrome/browser/prefs/command_line_pref_store.h | 9 |
2 files changed, 32 insertions, 1 deletions
diff --git a/chrome/browser/prefs/command_line_pref_store.cc b/chrome/browser/prefs/command_line_pref_store.cc index af4f39d..4f2e2b3 100644 --- a/chrome/browser/prefs/command_line_pref_store.cc +++ b/chrome/browser/prefs/command_line_pref_store.cc @@ -5,6 +5,7 @@ #include "chrome/browser/prefs/command_line_pref_store.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/values.h" #include "chrome/browser/prefs/proxy_config_dictionary.h" @@ -20,6 +21,7 @@ const CommandLinePrefStore::StringSwitchToPreferenceMapEntry { switches::kAuthNegotiateDelegateWhitelist, prefs::kAuthNegotiateDelegateWhitelist }, { switches::kGSSAPILibraryName, prefs::kGSSAPILibraryName }, + { switches::kDiskCacheDir, prefs::kDiskCacheDir }, }; const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry @@ -46,6 +48,12 @@ const CommandLinePrefStore::BooleanSwitchToPreferenceMapEntry { switches::kDisableTLS1, prefs::kTLS1Enabled, false }, }; +const CommandLinePrefStore::IntegerSwitchToPreferenceMapEntry + CommandLinePrefStore::integer_switch_map_[] = { + { switches::kDiskCacheSize, prefs::kDiskCacheSize }, + { switches::kMediaCacheSize, prefs::kMediaCacheSize }, + }; + CommandLinePrefStore::CommandLinePrefStore(const CommandLine* command_line) : command_line_(command_line) { ApplySimpleSwitches(); @@ -66,6 +74,22 @@ void CommandLinePrefStore::ApplySimpleSwitches() { } } + for (size_t i = 0; i < arraysize(integer_switch_map_); ++i) { + if (command_line_->HasSwitch(integer_switch_map_[i].switch_name)) { + std::string str_value = command_line_->GetSwitchValueASCII( + integer_switch_map_[i].switch_name); + int int_value = 0; + if (!base::StringToInt(str_value, &int_value)) { + LOG(ERROR) << "The value " << str_value << " of " + << integer_switch_map_[i].switch_name + << " can not be converted to integer, ignoring!"; + continue; + } + Value* value = Value::CreateIntegerValue(int_value); + SetValue(integer_switch_map_[i].preference_path, value); + } + } + for (size_t i = 0; i < arraysize(boolean_switch_map_); ++i) { if (command_line_->HasSwitch(boolean_switch_map_[i].switch_name)) { Value* value = Value::CreateBooleanValue( diff --git a/chrome/browser/prefs/command_line_pref_store.h b/chrome/browser/prefs/command_line_pref_store.h index 5555b18..2b1a1b1 100644 --- a/chrome/browser/prefs/command_line_pref_store.h +++ b/chrome/browser/prefs/command_line_pref_store.h @@ -30,6 +30,11 @@ class CommandLinePrefStore : public ValueMapPrefStore { const char* preference_path; }; + struct IntegerSwitchToPreferenceMapEntry { + const char* switch_name; + const char* preference_path; + }; + // |set_value| indicates what the preference should be set to if the switch // is present. struct BooleanSwitchToPreferenceMapEntry { @@ -37,7 +42,6 @@ class CommandLinePrefStore : public ValueMapPrefStore { const char* preference_path; bool set_value; }; - static const BooleanSwitchToPreferenceMapEntry boolean_switch_map_[]; // Using the string and boolean maps, apply command-line switches to their // corresponding preferences in this pref store. @@ -52,7 +56,10 @@ class CommandLinePrefStore : public ValueMapPrefStore { // Weak reference. const CommandLine* command_line_; + // Mappings of command line switches to prefs. + static const BooleanSwitchToPreferenceMapEntry boolean_switch_map_[]; static const StringSwitchToPreferenceMapEntry string_switch_map_[]; + static const IntegerSwitchToPreferenceMapEntry integer_switch_map_[]; DISALLOW_COPY_AND_ASSIGN(CommandLinePrefStore); }; |