Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/extensions/extension_service_test_base.cc

Issue 1112573002: [chrome/browser/extensions] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed other nits Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/extensions/extension_service_test_base.h" 5 #include "chrome/browser/extensions/extension_service_test_base.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/thread_task_runner_handle.h"
12 #include "chrome/browser/extensions/extension_error_reporter.h" 13 #include "chrome/browser/extensions/extension_error_reporter.h"
13 #include "chrome/browser/extensions/extension_garbage_collector_factory.h" 14 #include "chrome/browser/extensions/extension_garbage_collector_factory.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/test_extension_system.h" 16 #include "chrome/browser/extensions/test_extension_system.h"
16 #include "chrome/browser/extensions/updater/extension_updater.h" 17 #include "chrome/browser/extensions/updater/extension_updater.h"
17 #include "chrome/browser/prefs/browser_prefs.h" 18 #include "chrome/browser/prefs/browser_prefs.h"
18 #include "chrome/browser/prefs/pref_service_mock_factory.h" 19 #include "chrome/browser/prefs/pref_service_mock_factory.h"
19 #include "chrome/browser/prefs/pref_service_syncable.h" 20 #include "chrome/browser/prefs/pref_service_syncable.h"
20 #include "chrome/common/chrome_constants.h" 21 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
(...skipping 18 matching lines...) Expand all
40 // Create a testing profile according to |params|. 41 // Create a testing profile according to |params|.
41 scoped_ptr<TestingProfile> BuildTestingProfile( 42 scoped_ptr<TestingProfile> BuildTestingProfile(
42 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) { 43 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) {
43 TestingProfile::Builder profile_builder; 44 TestingProfile::Builder profile_builder;
44 // Create a PrefService that only contains user defined preference values. 45 // Create a PrefService that only contains user defined preference values.
45 PrefServiceMockFactory factory; 46 PrefServiceMockFactory factory;
46 // If pref_file is empty, TestingProfile automatically creates 47 // If pref_file is empty, TestingProfile automatically creates
47 // TestingPrefServiceSyncable instance. 48 // TestingPrefServiceSyncable instance.
48 if (!params.pref_file.empty()) { 49 if (!params.pref_file.empty()) {
49 factory.SetUserPrefsFile(params.pref_file, 50 factory.SetUserPrefsFile(params.pref_file,
50 base::MessageLoopProxy::current().get()); 51 base::ThreadTaskRunnerHandle::Get().get());
51 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 52 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
52 new user_prefs::PrefRegistrySyncable); 53 new user_prefs::PrefRegistrySyncable);
53 scoped_ptr<PrefServiceSyncable> prefs( 54 scoped_ptr<PrefServiceSyncable> prefs(
54 factory.CreateSyncable(registry.get())); 55 factory.CreateSyncable(registry.get()));
55 chrome::RegisterUserProfilePrefs(registry.get()); 56 chrome::RegisterUserProfilePrefs(registry.get());
56 profile_builder.SetPrefService(prefs.Pass()); 57 profile_builder.SetPrefService(prefs.Pass());
57 } 58 }
58 59
59 if (params.profile_is_supervised) 60 if (params.profile_is_supervised)
60 profile_builder.SetSupervisedUserId("asdf"); 61 profile_builder.SetSupervisedUserId("asdf");
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 base::CommandLine::ForCurrentProcess(), params.extensions_install_dir); 215 base::CommandLine::ForCurrentProcess(), params.extensions_install_dir);
215 prefs->SetAlertSystemFirstRun(); 216 prefs->SetAlertSystemFirstRun();
216 } 217 }
217 218
218 service_ = 219 service_ =
219 system->CreateExtensionService(base::CommandLine::ForCurrentProcess(), 220 system->CreateExtensionService(base::CommandLine::ForCurrentProcess(),
220 params.extensions_install_dir, 221 params.extensions_install_dir,
221 params.autoupdate_enabled); 222 params.autoupdate_enabled);
222 223
223 service_->SetFileTaskRunnerForTesting( 224 service_->SetFileTaskRunnerForTesting(
224 base::MessageLoopProxy::current().get()); 225 base::ThreadTaskRunnerHandle::Get().get());
225 service_->set_extensions_enabled(true); 226 service_->set_extensions_enabled(true);
226 service_->set_show_extensions_prompts(false); 227 service_->set_show_extensions_prompts(false);
227 service_->set_install_updates_when_idle_for_test(false); 228 service_->set_install_updates_when_idle_for_test(false);
228 229
229 // When we start up, we want to make sure there is no external provider, 230 // When we start up, we want to make sure there is no external provider,
230 // since the ExtensionService on Windows will use the Registry as a default 231 // since the ExtensionService on Windows will use the Registry as a default
231 // provider and if there is something already registered there then it will 232 // provider and if there is something already registered there then it will
232 // interfere with the tests. Those tests that need an external provider 233 // interfere with the tests. Those tests that need an external provider
233 // will register one specifically. 234 // will register one specifically.
234 service_->ClearProvidersForTesting(); 235 service_->ClearProvidersForTesting();
235 236
236 #if defined(OS_CHROMEOS) 237 #if defined(OS_CHROMEOS)
237 InstallLimiter::Get(profile_.get())->DisableForTest(); 238 InstallLimiter::Get(profile_.get())->DisableForTest();
238 #endif 239 #endif
239 } 240 }
240 241
241 } // namespace extensions 242 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698