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

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: Resolving ng browser unittest issues 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"
11 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "chrome/browser/extensions/extension_error_reporter.h" 12 #include "chrome/browser/extensions/extension_error_reporter.h"
13 #include "chrome/browser/extensions/extension_garbage_collector_factory.h" 13 #include "chrome/browser/extensions/extension_garbage_collector_factory.h"
14 #include "chrome/browser/extensions/extension_service.h" 14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/test_extension_system.h" 15 #include "chrome/browser/extensions/test_extension_system.h"
16 #include "chrome/browser/extensions/updater/extension_updater.h" 16 #include "chrome/browser/extensions/updater/extension_updater.h"
17 #include "chrome/browser/prefs/browser_prefs.h" 17 #include "chrome/browser/prefs/browser_prefs.h"
18 #include "chrome/browser/prefs/pref_service_mock_factory.h" 18 #include "chrome/browser/prefs/pref_service_mock_factory.h"
19 #include "chrome/browser/prefs/pref_service_syncable.h" 19 #include "chrome/browser/prefs/pref_service_syncable.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
(...skipping 18 matching lines...) Expand all
40 // Create a testing profile according to |params|. 40 // Create a testing profile according to |params|.
41 scoped_ptr<TestingProfile> BuildTestingProfile( 41 scoped_ptr<TestingProfile> BuildTestingProfile(
42 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) { 42 const ExtensionServiceTestBase::ExtensionServiceInitParams& params) {
43 TestingProfile::Builder profile_builder; 43 TestingProfile::Builder profile_builder;
44 // Create a PrefService that only contains user defined preference values. 44 // Create a PrefService that only contains user defined preference values.
45 PrefServiceMockFactory factory; 45 PrefServiceMockFactory factory;
46 // If pref_file is empty, TestingProfile automatically creates 46 // If pref_file is empty, TestingProfile automatically creates
47 // TestingPrefServiceSyncable instance. 47 // TestingPrefServiceSyncable instance.
48 if (!params.pref_file.empty()) { 48 if (!params.pref_file.empty()) {
49 factory.SetUserPrefsFile(params.pref_file, 49 factory.SetUserPrefsFile(params.pref_file,
50 base::MessageLoopProxy::current().get()); 50 base::ThreadTaskRunnerHandle::Get().get());
51 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 51 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
52 new user_prefs::PrefRegistrySyncable); 52 new user_prefs::PrefRegistrySyncable);
53 scoped_ptr<PrefServiceSyncable> prefs( 53 scoped_ptr<PrefServiceSyncable> prefs(
54 factory.CreateSyncable(registry.get())); 54 factory.CreateSyncable(registry.get()));
55 chrome::RegisterUserProfilePrefs(registry.get()); 55 chrome::RegisterUserProfilePrefs(registry.get());
56 profile_builder.SetPrefService(prefs.Pass()); 56 profile_builder.SetPrefService(prefs.Pass());
57 } 57 }
58 58
59 if (params.profile_is_supervised) 59 if (params.profile_is_supervised)
60 profile_builder.SetSupervisedUserId("asdf"); 60 profile_builder.SetSupervisedUserId("asdf");
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 base::CommandLine::ForCurrentProcess(), params.extensions_install_dir); 214 base::CommandLine::ForCurrentProcess(), params.extensions_install_dir);
215 prefs->SetAlertSystemFirstRun(); 215 prefs->SetAlertSystemFirstRun();
216 } 216 }
217 217
218 service_ = 218 service_ =
219 system->CreateExtensionService(base::CommandLine::ForCurrentProcess(), 219 system->CreateExtensionService(base::CommandLine::ForCurrentProcess(),
220 params.extensions_install_dir, 220 params.extensions_install_dir,
221 params.autoupdate_enabled); 221 params.autoupdate_enabled);
222 222
223 service_->SetFileTaskRunnerForTesting( 223 service_->SetFileTaskRunnerForTesting(
224 base::MessageLoopProxy::current().get()); 224 base::ThreadTaskRunnerHandle::Get().get());
225 service_->set_extensions_enabled(true); 225 service_->set_extensions_enabled(true);
226 service_->set_show_extensions_prompts(false); 226 service_->set_show_extensions_prompts(false);
227 service_->set_install_updates_when_idle_for_test(false); 227 service_->set_install_updates_when_idle_for_test(false);
228 228
229 // When we start up, we want to make sure there is no external provider, 229 // 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 230 // 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 231 // provider and if there is something already registered there then it will
232 // interfere with the tests. Those tests that need an external provider 232 // interfere with the tests. Those tests that need an external provider
233 // will register one specifically. 233 // will register one specifically.
234 service_->ClearProvidersForTesting(); 234 service_->ClearProvidersForTesting();
235 235
236 #if defined(OS_CHROMEOS) 236 #if defined(OS_CHROMEOS)
237 InstallLimiter::Get(profile_.get())->DisableForTest(); 237 InstallLimiter::Get(profile_.get())->DisableForTest();
238 #endif 238 #endif
239 } 239 }
240 240
241 } // namespace extensions 241 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/blacklist_unittest.cc ('k') | chrome/browser/extensions/extension_web_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698