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

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 2341693002: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Change std::string() back to "" to fix compile Created 4 years, 3 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 (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 "chrome/test/base/testing_profile.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 protected: 193 protected:
194 ~TestExtensionURLRequestContextGetter() override {} 194 ~TestExtensionURLRequestContextGetter() override {}
195 195
196 private: 196 private:
197 std::unique_ptr<net::URLRequestContext> context_; 197 std::unique_ptr<net::URLRequestContext> context_;
198 }; 198 };
199 199
200 std::unique_ptr<KeyedService> BuildHistoryService( 200 std::unique_ptr<KeyedService> BuildHistoryService(
201 content::BrowserContext* context) { 201 content::BrowserContext* context) {
202 return base::WrapUnique(new history::HistoryService( 202 return base::MakeUnique<history::HistoryService>(
203 base::WrapUnique(new ChromeHistoryClient( 203 base::MakeUnique<ChromeHistoryClient>(
204 BookmarkModelFactory::GetForBrowserContext(context))), 204 BookmarkModelFactory::GetForBrowserContext(context)),
205 base::WrapUnique(new history::ContentVisitDelegate(context)))); 205 base::MakeUnique<history::ContentVisitDelegate>(context));
206 } 206 }
207 207
208 std::unique_ptr<KeyedService> BuildInMemoryURLIndex( 208 std::unique_ptr<KeyedService> BuildInMemoryURLIndex(
209 content::BrowserContext* context) { 209 content::BrowserContext* context) {
210 Profile* profile = Profile::FromBrowserContext(context); 210 Profile* profile = Profile::FromBrowserContext(context);
211 std::unique_ptr<InMemoryURLIndex> in_memory_url_index( 211 std::unique_ptr<InMemoryURLIndex> in_memory_url_index(
212 new InMemoryURLIndex(BookmarkModelFactory::GetForBrowserContext(profile), 212 new InMemoryURLIndex(BookmarkModelFactory::GetForBrowserContext(profile),
213 HistoryServiceFactory::GetForProfile( 213 HistoryServiceFactory::GetForProfile(
214 profile, ServiceAccessType::IMPLICIT_ACCESS), 214 profile, ServiceAccessType::IMPLICIT_ACCESS),
215 TemplateURLServiceFactory::GetForProfile(profile), 215 TemplateURLServiceFactory::GetForProfile(profile),
216 content::BrowserThread::GetBlockingPool(), 216 content::BrowserThread::GetBlockingPool(),
217 profile->GetPath(), SchemeSet())); 217 profile->GetPath(), SchemeSet()));
218 in_memory_url_index->Init(); 218 in_memory_url_index->Init();
219 return std::move(in_memory_url_index); 219 return std::move(in_memory_url_index);
220 } 220 }
221 221
222 std::unique_ptr<KeyedService> BuildBookmarkModel( 222 std::unique_ptr<KeyedService> BuildBookmarkModel(
223 content::BrowserContext* context) { 223 content::BrowserContext* context) {
224 Profile* profile = Profile::FromBrowserContext(context); 224 Profile* profile = Profile::FromBrowserContext(context);
225 std::unique_ptr<BookmarkModel> bookmark_model( 225 std::unique_ptr<BookmarkModel> bookmark_model(
226 new BookmarkModel(base::WrapUnique(new ChromeBookmarkClient( 226 new BookmarkModel(base::MakeUnique<ChromeBookmarkClient>(
227 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))))); 227 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))));
228 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(), 228 bookmark_model->Load(profile->GetPrefs(), profile->GetPath(),
229 profile->GetIOTaskRunner(), 229 profile->GetIOTaskRunner(),
230 content::BrowserThread::GetTaskRunnerForThread( 230 content::BrowserThread::GetTaskRunnerForThread(
231 content::BrowserThread::UI)); 231 content::BrowserThread::UI));
232 return std::move(bookmark_model); 232 return std::move(bookmark_model);
233 } 233 }
234 234
235 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, 235 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
236 sql::InitStatus status, 236 sql::InitStatus status,
237 const std::string& diagnostics) { 237 const std::string& diagnostics) {
238 NOTREACHED(); 238 NOTREACHED();
239 } 239 }
240 240
241 std::unique_ptr<KeyedService> BuildWebDataService( 241 std::unique_ptr<KeyedService> BuildWebDataService(
242 content::BrowserContext* context) { 242 content::BrowserContext* context) {
243 const base::FilePath& context_path = context->GetPath(); 243 const base::FilePath& context_path = context->GetPath();
244 return base::WrapUnique(new WebDataServiceWrapper( 244 return base::MakeUnique<WebDataServiceWrapper>(
245 context_path, g_browser_process->GetApplicationLocale(), 245 context_path, g_browser_process->GetApplicationLocale(),
246 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), 246 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
247 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), 247 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
248 sync_start_util::GetFlareForSyncableService(context_path), 248 sync_start_util::GetFlareForSyncableService(context_path),
249 &TestProfileErrorCallback)); 249 &TestProfileErrorCallback);
250 } 250 }
251 251
252 #if BUILDFLAG(ANDROID_JAVA_UI) 252 #if BUILDFLAG(ANDROID_JAVA_UI)
253 std::unique_ptr<KeyedService> BuildOfflinePageModel( 253 std::unique_ptr<KeyedService> BuildOfflinePageModel(
254 content::BrowserContext* context) { 254 content::BrowserContext* context) {
255 return base::MakeUnique<offline_pages::StubOfflinePageModel>(); 255 return base::MakeUnique<offline_pages::StubOfflinePageModel>();
256 } 256 }
257 #endif 257 #endif
258 258
259 } // namespace 259 } // namespace
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 void TestingProfile::SetGuestSession(bool guest) { 659 void TestingProfile::SetGuestSession(bool guest) {
660 guest_session_ = guest; 660 guest_session_ = guest;
661 } 661 }
662 662
663 base::FilePath TestingProfile::GetPath() const { 663 base::FilePath TestingProfile::GetPath() const {
664 return profile_path_; 664 return profile_path_;
665 } 665 }
666 666
667 std::unique_ptr<content::ZoomLevelDelegate> 667 std::unique_ptr<content::ZoomLevelDelegate>
668 TestingProfile::CreateZoomLevelDelegate(const base::FilePath& partition_path) { 668 TestingProfile::CreateZoomLevelDelegate(const base::FilePath& partition_path) {
669 return base::WrapUnique(new ChromeZoomLevelPrefs( 669 return base::MakeUnique<ChromeZoomLevelPrefs>(
670 GetPrefs(), GetPath(), partition_path, 670 GetPrefs(), GetPath(), partition_path,
671 zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr())); 671 zoom::ZoomEventManager::GetForBrowserContext(this)->GetWeakPtr());
672 } 672 }
673 673
674 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { 674 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() {
675 return base::ThreadTaskRunnerHandle::Get(); 675 return base::ThreadTaskRunnerHandle::Get();
676 } 676 }
677 677
678 syncable_prefs::TestingPrefServiceSyncable* 678 syncable_prefs::TestingPrefServiceSyncable*
679 TestingProfile::GetTestingPrefService() { 679 TestingProfile::GetTestingPrefService() {
680 DCHECK(prefs_); 680 DCHECK(prefs_);
681 DCHECK(testing_prefs_); 681 DCHECK(testing_prefs_);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // Note: Owned by |original_profile|. 1089 // Note: Owned by |original_profile|.
1090 return new TestingProfile(path_, delegate_, 1090 return new TestingProfile(path_, delegate_,
1091 #if defined(ENABLE_EXTENSIONS) 1091 #if defined(ENABLE_EXTENSIONS)
1092 extension_policy_, 1092 extension_policy_,
1093 #endif 1093 #endif
1094 std::move(pref_service_), original_profile, 1094 std::move(pref_service_), original_profile,
1095 guest_session_, supervised_user_id_, 1095 guest_session_, supervised_user_id_,
1096 std::move(policy_service_), testing_factories_, 1096 std::move(policy_service_), testing_factories_,
1097 profile_name_); 1097 profile_name_);
1098 } 1098 }
OLDNEW
« no previous file with comments | « chrome/test/base/test_browser_window.cc ('k') | chrome/test/chromedriver/chrome/devtools_client_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698