diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 15:01:35 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 15:01:35 +0000 |
commit | ea587b01337fd38626923e48258a2b39a631543a (patch) | |
tree | 944b56193e7870f97877836e490556b0983f5b0a /chrome | |
parent | 893934384f65e8676d226396c34625880a46436a (diff) | |
download | chromium_src-ea587b01337fd38626923e48258a2b39a631543a.zip chromium_src-ea587b01337fd38626923e48258a2b39a631543a.tar.gz chromium_src-ea587b01337fd38626923e48258a2b39a631543a.tar.bz2 |
Removed dependency on ChromeThread from JsonPrefStore and moved JsonPrefStore and PrefStore to chrome/common. This is because JsonPrefStore is needed in the service process
BUG=None.
TEST=Updated unit-tests
Review URL: http://codereview.chromium.org/2066015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
22 files changed, 108 insertions, 50 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 4f69109..acc4525 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -40,7 +40,6 @@ #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/first_run.h" #include "chrome/browser/jankometer.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/metrics/histogram_synchronizer.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/net/dns_global.h" @@ -61,6 +60,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/jstemplate_builder.h" #include "chrome/common/main_function_params.h" #include "chrome/common/net/net_resource_provider.h" @@ -440,7 +440,10 @@ PrefService* InitializeLocalState(const CommandLine& parsed_command_line, parsed_command_line.HasSwitch(switches::kParentProfile)) { FilePath parent_profile = parsed_command_line.GetSwitchValuePath(switches::kParentProfile); - PrefService parent_local_state(new JsonPrefStore(parent_profile)); + PrefService parent_local_state( + new JsonPrefStore( + parent_profile, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE))); parent_local_state.RegisterStringPref(prefs::kApplicationLocale, std::wstring()); // Right now, we only inherit the locale setting from the parent profile. diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index f630571..e6f99a1 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -30,7 +30,6 @@ #include "chrome/browser/in_process_webkit/dom_storage_context.h" #include "chrome/browser/intranet_redirect_detector.h" #include "chrome/browser/io_thread.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/metrics/metrics_service.h" #include "chrome/browser/net/dns_global.h" #include "chrome/browser/net/sdch_dictionary_fetcher.h" @@ -49,6 +48,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/extensions/extension_l10n_util.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -408,7 +408,10 @@ void BrowserProcessImpl::CreateLocalState() { FilePath local_state_path; PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); - local_state_.reset(new PrefService(new JsonPrefStore(local_state_path))); + local_state_.reset(new PrefService( + new JsonPrefStore( + local_state_path, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); } void BrowserProcessImpl::CreateIconManager() { diff --git a/chrome/browser/configuration_policy_pref_store.h b/chrome/browser/configuration_policy_pref_store.h index 8335070..b01b429 100644 --- a/chrome/browser/configuration_policy_pref_store.h +++ b/chrome/browser/configuration_policy_pref_store.h @@ -11,7 +11,7 @@ #include "base/scoped_ptr.h" #include "base/values.h" #include "chrome/browser/configuration_policy_store.h" -#include "chrome/browser/pref_store.h" +#include "chrome/common/pref_store.h" #include "testing/gtest/include/gtest/gtest_prod.h" class ConfigurationPolicyProvider; diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc index 2014942..eebdc45 100644 --- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc +++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc @@ -6,9 +6,10 @@ #include "base/file_path.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/new_tab_ui.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/pref_service.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/pref_names.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" @@ -71,7 +72,10 @@ TEST_F(NewTabUITest, ChromeInternalLoadsNTP) { } TEST_F(NewTabUITest, UpdateUserPrefsVersion) { - PrefService prefs(new JsonPrefStore(FilePath())); + PrefService prefs( + new JsonPrefStore( + FilePath(), + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE))); // Does the migration NewTabUI::RegisterUserPrefs(&prefs); diff --git a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc index 08f3406..48530d2 100644 --- a/chrome/browser/dom_ui/shown_sections_handler_unittest.cc +++ b/chrome/browser/dom_ui/shown_sections_handler_unittest.cc @@ -6,8 +6,9 @@ #include "base/file_path.h" #include "base/scoped_ptr.h" -#include "chrome/browser/json_pref_store.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/pref_service.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" @@ -15,7 +16,10 @@ class ShownSectionsHandlerTest : public testing::Test { }; TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) { - PrefService pref(new JsonPrefStore(FilePath())); + PrefService pref( + new JsonPrefStore( + FilePath(), + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE))); // Set an *old* value pref.RegisterIntegerPref(prefs::kNTPShownSections, 0); @@ -33,7 +37,10 @@ TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs) { } TEST_F(ShownSectionsHandlerTest, MigrateUserPrefs1To2) { - PrefService pref(new JsonPrefStore(FilePath())); + PrefService pref( + new JsonPrefStore( + FilePath(), + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE))); // Set an *old* value pref.RegisterIntegerPref(prefs::kNTPShownSections, 0); diff --git a/chrome/browser/dummy_pref_store.h b/chrome/browser/dummy_pref_store.h index ed3da44..a3c1ee4 100644 --- a/chrome/browser/dummy_pref_store.h +++ b/chrome/browser/dummy_pref_store.h @@ -6,7 +6,7 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" -#include "chrome/browser/pref_store.h" +#include "chrome/common/pref_store.h" class DummyPrefStore : public PrefStore { public: diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 78264b3..c74b644 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -18,6 +18,7 @@ #include "base/string_util.h" #include "base/task.h" #include "base/version.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_creator.h" #include "chrome/browser/extensions/extension_error_reporter.h" @@ -241,7 +242,11 @@ ExtensionsServiceTestBase::~ExtensionsServiceTestBase() { void ExtensionsServiceTestBase::InitializeExtensionsService( const FilePath& pref_file, const FilePath& extensions_install_dir) { ExtensionTestingProfile* profile = new ExtensionTestingProfile(); - prefs_.reset(new PrefService(new JsonPrefStore(pref_file))); + prefs_.reset(new PrefService( + new JsonPrefStore( + pref_file, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); + Profile::RegisterUserPrefs(prefs_.get()); browser::RegisterUserPrefs(prefs_.get()); profile_.reset(profile); diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc index e9a1472..716539f 100644 --- a/chrome/browser/extensions/test_extension_prefs.cc +++ b/chrome/browser/extensions/test_extension_prefs.cc @@ -9,10 +9,10 @@ #include "base/message_loop.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extension_prefs.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/pref_service.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" +#include "chrome/common/json_pref_store.h" #include "testing/gtest/include/gtest/gtest.h" TestExtensionPrefs::TestExtensionPrefs() { @@ -37,7 +37,11 @@ void TestExtensionPrefs::RecreateExtensionPrefs() { file_loop.RunAllPending(); } - pref_service_.reset(new PrefService(new JsonPrefStore(preferences_file_))); + pref_service_.reset(new PrefService( + new JsonPrefStore( + preferences_file_, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); + ExtensionPrefs::RegisterUserPrefs(pref_service_.get()); prefs_.reset(new ExtensionPrefs(pref_service_.get(), temp_dir_.path())); } diff --git a/chrome/browser/metrics/metrics_service_uitest.cc b/chrome/browser/metrics/metrics_service_uitest.cc index a943c68..05c1b8d 100644 --- a/chrome/browser/metrics/metrics_service_uitest.cc +++ b/chrome/browser/metrics/metrics_service_uitest.cc @@ -11,10 +11,11 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/platform_thread.h" -#include "chrome/browser/json_pref_store.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/pref_service.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/test/automation/tab_proxy.h" @@ -52,7 +53,10 @@ class MetricsServiceTest : public UITest { FilePath local_state_path = user_data_dir() .Append(chrome::kLocalStateFilename); - return new PrefService(new JsonPrefStore(local_state_path)); + return new PrefService( + new JsonPrefStore( + local_state_path, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE))); } }; diff --git a/chrome/browser/pref_service.h b/chrome/browser/pref_service.h index 4f660ee..c79edd7 100644 --- a/chrome/browser/pref_service.h +++ b/chrome/browser/pref_service.h @@ -15,7 +15,7 @@ #include "base/observer_list.h" #include "base/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/pref_store.h" +#include "chrome/common/pref_store.h" class NotificationObserver; class Preference; diff --git a/chrome/browser/privacy_blacklist/blacklist_unittest.cc b/chrome/browser/privacy_blacklist/blacklist_unittest.cc index a7a3188..049c32d 100644 --- a/chrome/browser/privacy_blacklist/blacklist_unittest.cc +++ b/chrome/browser/privacy_blacklist/blacklist_unittest.cc @@ -9,10 +9,11 @@ #include "base/path_service.h" #include "base/string_util.h" #include "chrome/browser/browser_prefs.h" -#include "chrome/browser/json_pref_store.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/json_pref_store.h" #include "testing/gtest/include/gtest/gtest.h" class BlacklistTest : public testing::Test { @@ -23,7 +24,10 @@ class BlacklistTest : public testing::Test { source_path = source_path.AppendASCII("profiles") .AppendASCII("blacklist_prefs").AppendASCII("Preferences"); - prefs_.reset(new PrefService(new JsonPrefStore(source_path))); + prefs_.reset(new PrefService( + new JsonPrefStore( + source_path, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); Profile::RegisterUserPrefs(prefs_.get()); browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); } diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index c03553f..1a01523 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -41,7 +41,6 @@ #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/in_process_webkit/webkit_context.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -68,6 +67,7 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" @@ -987,7 +987,10 @@ net::TransportSecurityState* PrefService* ProfileImpl::GetPrefs() { if (!prefs_.get()) { - prefs_.reset(new PrefService(new JsonPrefStore(GetPrefFilePath()))); + prefs_.reset(new PrefService( + new JsonPrefStore( + GetPrefFilePath(), + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); // The Profile class and ProfileManager class may read some prefs so // register known prefs as soon as possible. diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index f9e731e..e479cd3 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -51,7 +51,11 @@ class TabContentsTestingProfile : public TestingProfile { source_path = source_path.AppendASCII("profiles") .AppendASCII("chrome_prefs").AppendASCII("Preferences"); - prefs_.reset(new PrefService(new JsonPrefStore(source_path))); + prefs_.reset(new PrefService( + new JsonPrefStore( + source_path, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); + Profile::RegisterUserPrefs(prefs_.get()); browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6a76c2c..8679636 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1593,8 +1593,6 @@ 'browser/js_modal_dialog_mac.mm', 'browser/js_modal_dialog_win.cc', 'browser/jsmessage_box_client.h', - 'browser/json_pref_store.cc', - 'browser/json_pref_store.h', 'browser/keychain_mac.cc', 'browser/keychain_mac.h', 'browser/language_combobox_model.cc', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 4e1d884..d226b5d 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -200,6 +200,8 @@ 'common/gpu_plugin.h', 'common/important_file_writer.cc', 'common/important_file_writer.h', + 'common/json_pref_store.cc', + 'common/json_pref_store.h', 'common/jstemplate_builder.cc', 'common/jstemplate_builder.h', 'common/libxml_utils.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index e6b6a62..e5b4d4e 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -842,7 +842,6 @@ 'browser/in_process_webkit/dom_storage_dispatcher_host_unittest.cc', 'browser/in_process_webkit/webkit_context_unittest.cc', 'browser/in_process_webkit/webkit_thread_unittest.cc', - 'browser/json_pref_store_unittest.cc', 'browser/keychain_mock_mac.cc', 'browser/keychain_mock_mac.h', 'browser/login_prompt_unittest.cc', @@ -987,6 +986,7 @@ 'common/extensions/url_pattern_unittest.cc', 'common/extensions/user_script_unittest.cc', 'common/important_file_writer_unittest.cc', + 'common/json_pref_store_unittest.cc', 'common/json_value_serializer_unittest.cc', 'common/mru_cache_unittest.cc', # TODO(sanjeevr): Move the 2 below files to common_net_unit_tests diff --git a/chrome/browser/json_pref_store.cc b/chrome/common/json_pref_store.cc index 40fd309..9acfcb2d 100644 --- a/chrome/browser/json_pref_store.cc +++ b/chrome/common/json_pref_store.cc @@ -2,13 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/json_pref_store.h" +#include "chrome/common/json_pref_store.h" #include <algorithm> #include "base/file_util.h" #include "base/values.h" -#include "chrome/browser/chrome_thread.h" #include "chrome/common/json_value_serializer.h" namespace { @@ -18,12 +17,12 @@ const FilePath::CharType* kBadExtension = FILE_PATH_LITERAL("bad"); } // namespace -JsonPrefStore::JsonPrefStore(const FilePath& filename) +JsonPrefStore::JsonPrefStore(const FilePath& filename, + base::MessageLoopProxy* file_message_loop_proxy) : path_(filename), prefs_(new DictionaryValue()), read_only_(false), - writer_(filename, - ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)) { + writer_(filename, file_message_loop_proxy) { } JsonPrefStore::~JsonPrefStore() { diff --git a/chrome/browser/json_pref_store.h b/chrome/common/json_pref_store.h index e25d310..70f5dee 100644 --- a/chrome/browser/json_pref_store.h +++ b/chrome/common/json_pref_store.h @@ -2,22 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_JSON_PREF_STORE_H_ -#define CHROME_BROWSER_JSON_PREF_STORE_H_ +#ifndef CHROME_COMMON_JSON_PREF_STORE_H_ +#define CHROME_COMMON_JSON_PREF_STORE_H_ #include <string> #include "base/scoped_ptr.h" -#include "chrome/browser/pref_store.h" +#include "chrome/common/pref_store.h" #include "chrome/common/important_file_writer.h" +namespace base { +class MessageLoopProxy; +} + class DictionaryValue; class FilePath; class JsonPrefStore : public PrefStore, public ImportantFileWriter::DataSerializer { public: - explicit JsonPrefStore(const FilePath& pref_filename); + // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which + // file I/O can be done. + JsonPrefStore(const FilePath& pref_filename, + base::MessageLoopProxy* file_message_loop_proxy); virtual ~JsonPrefStore(); // PrefStore methods: @@ -45,4 +52,5 @@ class JsonPrefStore : public PrefStore, ImportantFileWriter writer_; }; -#endif // CHROME_BROWSER_JSON_PREF_STORE_H_ +#endif // CHROME_COMMON_JSON_PREF_STORE_H_ + diff --git a/chrome/browser/json_pref_store_unittest.cc b/chrome/common/json_pref_store_unittest.cc index de22695..7d00030 100644 --- a/chrome/browser/json_pref_store_unittest.cc +++ b/chrome/common/json_pref_store_unittest.cc @@ -5,13 +5,14 @@ #include "app/test/data/resource.h" #include "base/file_util.h" #include "base/message_loop.h" +#include "base/message_loop_proxy.h" #include "base/path_service.h" #include "base/scoped_ptr.h" #include "base/string_util.h" +#include "base/thread.h" #include "base/utf_string_conversions.h" #include "base/values.h" -#include "chrome/browser/chrome_thread.h" -#include "chrome/browser/json_pref_store.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" @@ -19,6 +20,7 @@ class JsonPrefStoreTest : public testing::Test { protected: virtual void SetUp() { + message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); test_dir_ = test_dir_.AppendASCII("JsonPrefStoreTest"); @@ -42,13 +44,16 @@ class JsonPrefStoreTest : public testing::Test { FilePath test_dir_; // the path to the directory where the test data is stored FilePath data_dir_; + // A message loop that we can use as the file thread message loop. + MessageLoop message_loop_; + scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; }; // Test fallback behavior for a nonexistent file. TEST_F(JsonPrefStoreTest, NonExistentFile) { FilePath bogus_input_file = data_dir_.AppendASCII("read.txt"); ASSERT_FALSE(file_util::PathExists(bogus_input_file)); - JsonPrefStore pref_store(bogus_input_file); + JsonPrefStore pref_store(bogus_input_file, message_loop_proxy_.get()); EXPECT_EQ(PrefStore::PREF_READ_ERROR_NO_FILE, pref_store.ReadPrefs()); EXPECT_FALSE(pref_store.ReadOnly()); EXPECT_TRUE(pref_store.prefs()->empty()); @@ -59,7 +64,7 @@ TEST_F(JsonPrefStoreTest, InvalidFile) { FilePath invalid_file_original = data_dir_.AppendASCII("invalid.json"); FilePath invalid_file = test_dir_.AppendASCII("invalid.json"); ASSERT_TRUE(file_util::CopyFile(invalid_file_original, invalid_file)); - JsonPrefStore pref_store(invalid_file); + JsonPrefStore pref_store(invalid_file, message_loop_proxy_.get()); EXPECT_EQ(PrefStore::PREF_READ_ERROR_JSON_PARSE, pref_store.ReadPrefs()); EXPECT_FALSE(pref_store.ReadOnly()); EXPECT_TRUE(pref_store.prefs()->empty()); @@ -79,7 +84,7 @@ TEST_F(JsonPrefStoreTest, Basic) { // Test that the persistent value can be loaded. FilePath input_file = test_dir_.AppendASCII("write.json"); ASSERT_TRUE(file_util::PathExists(input_file)); - JsonPrefStore pref_store(input_file); + JsonPrefStore pref_store(input_file, message_loop_proxy_.get()); ASSERT_EQ(PrefStore::PREF_READ_ERROR_NONE, pref_store.ReadPrefs()); ASSERT_FALSE(pref_store.ReadOnly()); DictionaryValue* prefs = pref_store.prefs(); @@ -135,9 +140,6 @@ TEST_F(JsonPrefStoreTest, Basic) { EXPECT_EQ(214748364842LL, StringToInt64(WideToUTF16Hack(string_value))); // Serialize and compare to expected output. - // SavePersistentPrefs uses ImportantFileWriter which needs a file thread. - MessageLoop message_loop; - ChromeThread file_thread(ChromeThread::FILE, &message_loop); FilePath output_file = input_file; FilePath golden_output_file = data_dir_.AppendASCII("write.golden.json"); ASSERT_TRUE(file_util::PathExists(golden_output_file)); diff --git a/chrome/browser/pref_store.h b/chrome/common/pref_store.h index 9f72631..959c412 100644 --- a/chrome/browser/pref_store.h +++ b/chrome/common/pref_store.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_PREF_STORE_H_ -#define CHROME_BROWSER_PREF_STORE_H_ +#ifndef CHROME_COMMON_PREF_STORE_H_ +#define CHROME_COMMON_PREF_STORE_H_ class DictionaryValue; @@ -45,4 +45,5 @@ class PrefStore { virtual void ScheduleWritePrefs() { } }; -#endif // CHROME_BROWSER_PREF_STORE_H_ +#endif // CHROME_COMMON_PREF_STORE_H_ + diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index eba821a..5d509de 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -48,12 +48,13 @@ #include "base/test/test_file_util.h" #include "base/time.h" #include "chrome/app/chrome_version_info.h" -#include "chrome/browser/json_pref_store.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/pref_service.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -528,7 +529,9 @@ class PageLoadTest : public UITest { .Append(chrome::kLocalStateFilename); PrefService* local_state(new PrefService( - new JsonPrefStore(local_state_path))); + new JsonPrefStore( + local_state_path, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); return local_state; } diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index 43c713c..70e3085 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -12,6 +12,7 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_prefs.h" #include "chrome/browser/browser_theme_provider.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/find_bar_state.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" @@ -19,10 +20,10 @@ #include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/history/history.h" #include "chrome/browser/in_process_webkit/webkit_context.h" -#include "chrome/browser/json_pref_store.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/common/json_pref_store.h" #include "chrome/common/net/url_request_context_getter.h" #include "net/base/cookie_monster.h" @@ -148,7 +149,10 @@ class TestingProfile : public Profile { if (!prefs_.get()) { FilePath prefs_filename = path_.Append(FILE_PATH_LITERAL("TestPreferences")); - prefs_.reset(new PrefService(new JsonPrefStore(prefs_filename))); + prefs_.reset(new PrefService( + new JsonPrefStore( + prefs_filename, + ChromeThread::GetMessageLoopProxyForThread(ChromeThread::FILE)))); Profile::RegisterUserPrefs(prefs_.get()); browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); } |