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

Side by Side Diff: ios/chrome/browser/browser_state/test_chrome_browser_state.mm

Issue 2256193002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 5 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.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/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ios/chrome/browser/sync/glue/sync_start_util.h" 45 #include "ios/chrome/browser/sync/glue/sync_start_util.h"
46 #include "ios/chrome/browser/web_data_service_factory.h" 46 #include "ios/chrome/browser/web_data_service_factory.h"
47 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 47 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
48 #include "ios/web/public/web_thread.h" 48 #include "ios/web/public/web_thread.h"
49 #include "net/url_request/url_request_test_util.h" 49 #include "net/url_request/url_request_test_util.h"
50 50
51 namespace { 51 namespace {
52 std::unique_ptr<KeyedService> BuildHistoryService(web::BrowserState* context) { 52 std::unique_ptr<KeyedService> BuildHistoryService(web::BrowserState* context) {
53 ios::ChromeBrowserState* browser_state = 53 ios::ChromeBrowserState* browser_state =
54 ios::ChromeBrowserState::FromBrowserState(context); 54 ios::ChromeBrowserState::FromBrowserState(context);
55 return base::WrapUnique(new history::HistoryService( 55 return base::MakeUnique<history::HistoryService>(
56 base::WrapUnique(new HistoryClientImpl( 56 base::WrapUnique(new HistoryClientImpl(
57 ios::BookmarkModelFactory::GetForBrowserState(browser_state))), 57 ios::BookmarkModelFactory::GetForBrowserState(browser_state))),
58 nullptr)); 58 nullptr);
59 } 59 }
60 60
61 std::unique_ptr<KeyedService> BuildBookmarkModel(web::BrowserState* context) { 61 std::unique_ptr<KeyedService> BuildBookmarkModel(web::BrowserState* context) {
62 ios::ChromeBrowserState* browser_state = 62 ios::ChromeBrowserState* browser_state =
63 ios::ChromeBrowserState::FromBrowserState(context); 63 ios::ChromeBrowserState::FromBrowserState(context);
64 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model( 64 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model(
65 new bookmarks::BookmarkModel( 65 new bookmarks::BookmarkModel(
66 base::WrapUnique(new BookmarkClientImpl(browser_state)))); 66 base::MakeUnique<BookmarkClientImpl>(browser_state)));
67 bookmark_model->Load( 67 bookmark_model->Load(
68 browser_state->GetPrefs(), 68 browser_state->GetPrefs(),
69 browser_state->GetStatePath(), browser_state->GetIOTaskRunner(), 69 browser_state->GetStatePath(), browser_state->GetIOTaskRunner(),
70 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)); 70 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI));
71 return std::move(bookmark_model); 71 return std::move(bookmark_model);
72 } 72 }
73 73
74 void NotReachedErrorCallback(WebDataServiceWrapper::ErrorType, 74 void NotReachedErrorCallback(WebDataServiceWrapper::ErrorType,
75 sql::InitStatus, 75 sql::InitStatus,
76 const std::string&) { 76 const std::string&) {
77 NOTREACHED(); 77 NOTREACHED();
78 } 78 }
79 79
80 std::unique_ptr<KeyedService> BuildWebDataService(web::BrowserState* context) { 80 std::unique_ptr<KeyedService> BuildWebDataService(web::BrowserState* context) {
81 const base::FilePath& browser_state_path = context->GetStatePath(); 81 const base::FilePath& browser_state_path = context->GetStatePath();
82 return base::WrapUnique(new WebDataServiceWrapper( 82 return base::MakeUnique<WebDataServiceWrapper>(
83 browser_state_path, GetApplicationContext()->GetApplicationLocale(), 83 browser_state_path, GetApplicationContext()->GetApplicationLocale(),
84 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), 84 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
85 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), 85 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB),
86 ios::sync_start_util::GetFlareForSyncableService(browser_state_path), 86 ios::sync_start_util::GetFlareForSyncableService(browser_state_path),
87 &NotReachedErrorCallback)); 87 &NotReachedErrorCallback);
88 } 88 }
89 89
90 base::FilePath CreateTempBrowserStateDir(base::ScopedTempDir* temp_dir) { 90 base::FilePath CreateTempBrowserStateDir(base::ScopedTempDir* temp_dir) {
91 DCHECK(temp_dir); 91 DCHECK(temp_dir);
92 if (!temp_dir->CreateUniqueTempDir()) { 92 if (!temp_dir->CreateUniqueTempDir()) {
93 // Fallback logic in case we fail to create unique temporary directory. 93 // Fallback logic in case we fail to create unique temporary directory.
94 LOG(ERROR) << "Failed to create unique temporary directory."; 94 LOG(ERROR) << "Failed to create unique temporary directory.";
95 base::FilePath system_tmp_dir; 95 base::FilePath system_tmp_dir;
96 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); 96 bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir);
97 97
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 pref_service_ = std::move(prefs); 419 pref_service_ = std::move(prefs);
420 } 420 }
421 421
422 std::unique_ptr<TestChromeBrowserState> 422 std::unique_ptr<TestChromeBrowserState>
423 TestChromeBrowserState::Builder::Build() { 423 TestChromeBrowserState::Builder::Build() {
424 DCHECK(!build_called_); 424 DCHECK(!build_called_);
425 return base::WrapUnique(new TestChromeBrowserState( 425 return base::WrapUnique(new TestChromeBrowserState(
426 state_path_, std::move(pref_service_), testing_factories_, 426 state_path_, std::move(pref_service_), testing_factories_,
427 refcounted_testing_factories_)); 427 refcounted_testing_factories_));
428 } 428 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698