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

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

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "components/bookmarks/browser/bookmark_model.h" 18 #include "components/bookmarks/browser/bookmark_model.h"
18 #include "components/bookmarks/common/bookmark_constants.h" 19 #include "components/bookmarks/common/bookmark_constants.h"
19 #include "components/history/core/browser/history_constants.h" 20 #include "components/history/core/browser/history_constants.h"
20 #include "components/history/core/browser/history_database_params.h" 21 #include "components/history/core/browser/history_database_params.h"
21 #include "components/history/core/browser/history_service.h" 22 #include "components/history/core/browser/history_service.h"
22 #include "components/history/core/browser/top_sites.h" 23 #include "components/history/core/browser/top_sites.h"
(...skipping 16 matching lines...) Expand all
39 #include "ios/chrome/browser/history/web_history_service_factory.h" 40 #include "ios/chrome/browser/history/web_history_service_factory.h"
40 #include "ios/chrome/browser/prefs/browser_prefs.h" 41 #include "ios/chrome/browser/prefs/browser_prefs.h"
41 #include "ios/chrome/browser/prefs/ios_chrome_pref_service_factory.h" 42 #include "ios/chrome/browser/prefs/ios_chrome_pref_service_factory.h"
42 #include "ios/chrome/browser/sync/glue/sync_start_util.h" 43 #include "ios/chrome/browser/sync/glue/sync_start_util.h"
43 #include "ios/chrome/browser/web_data_service_factory.h" 44 #include "ios/chrome/browser/web_data_service_factory.h"
44 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 45 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
45 #include "ios/web/public/web_thread.h" 46 #include "ios/web/public/web_thread.h"
46 #include "net/url_request/url_request_test_util.h" 47 #include "net/url_request/url_request_test_util.h"
47 48
48 namespace { 49 namespace {
49 scoped_ptr<KeyedService> BuildHistoryService(web::BrowserState* context) { 50 std::unique_ptr<KeyedService> BuildHistoryService(web::BrowserState* context) {
50 ios::ChromeBrowserState* browser_state = 51 ios::ChromeBrowserState* browser_state =
51 ios::ChromeBrowserState::FromBrowserState(context); 52 ios::ChromeBrowserState::FromBrowserState(context);
52 return make_scoped_ptr(new history::HistoryService( 53 return base::WrapUnique(new history::HistoryService(
53 make_scoped_ptr(new HistoryClientImpl( 54 base::WrapUnique(new HistoryClientImpl(
54 ios::BookmarkModelFactory::GetForBrowserState(browser_state))), 55 ios::BookmarkModelFactory::GetForBrowserState(browser_state))),
55 nullptr)); 56 nullptr));
56 } 57 }
57 58
58 scoped_ptr<KeyedService> BuildBookmarkModel(web::BrowserState* context) { 59 std::unique_ptr<KeyedService> BuildBookmarkModel(web::BrowserState* context) {
59 ios::ChromeBrowserState* browser_state = 60 ios::ChromeBrowserState* browser_state =
60 ios::ChromeBrowserState::FromBrowserState(context); 61 ios::ChromeBrowserState::FromBrowserState(context);
61 scoped_ptr<bookmarks::BookmarkModel> bookmark_model( 62 std::unique_ptr<bookmarks::BookmarkModel> bookmark_model(
62 new bookmarks::BookmarkModel( 63 new bookmarks::BookmarkModel(
63 make_scoped_ptr(new BookmarkClientImpl(browser_state)))); 64 base::WrapUnique(new BookmarkClientImpl(browser_state))));
64 bookmark_model->Load( 65 bookmark_model->Load(
65 browser_state->GetPrefs(), 66 browser_state->GetPrefs(),
66 browser_state->GetStatePath(), browser_state->GetIOTaskRunner(), 67 browser_state->GetStatePath(), browser_state->GetIOTaskRunner(),
67 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)); 68 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI));
68 return std::move(bookmark_model); 69 return std::move(bookmark_model);
69 } 70 }
70 71
71 void NotReachedErrorCallback(WebDataServiceWrapper::ErrorType error_type, 72 void NotReachedErrorCallback(WebDataServiceWrapper::ErrorType error_type,
72 sql::InitStatus status) { 73 sql::InitStatus status) {
73 NOTREACHED(); 74 NOTREACHED();
74 } 75 }
75 76
76 scoped_ptr<KeyedService> BuildWebDataService(web::BrowserState* context) { 77 std::unique_ptr<KeyedService> BuildWebDataService(web::BrowserState* context) {
77 const base::FilePath& browser_state_path = context->GetStatePath(); 78 const base::FilePath& browser_state_path = context->GetStatePath();
78 return make_scoped_ptr(new WebDataServiceWrapper( 79 return base::WrapUnique(new WebDataServiceWrapper(
79 browser_state_path, GetApplicationContext()->GetApplicationLocale(), 80 browser_state_path, GetApplicationContext()->GetApplicationLocale(),
80 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), 81 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
81 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), 82 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB),
82 ios::sync_start_util::GetFlareForSyncableService(browser_state_path), 83 ios::sync_start_util::GetFlareForSyncableService(browser_state_path),
83 &NotReachedErrorCallback)); 84 &NotReachedErrorCallback));
84 } 85 }
85 86
86 base::FilePath CreateTempBrowserStateDir(base::ScopedTempDir* temp_dir) { 87 base::FilePath CreateTempBrowserStateDir(base::ScopedTempDir* temp_dir) {
87 DCHECK(temp_dir); 88 DCHECK(temp_dir);
88 if (!temp_dir->CreateUniqueTempDir()) { 89 if (!temp_dir->CreateUniqueTempDir()) {
(...skipping 29 matching lines...) Expand all
118 otr_browser_state_(nullptr), 119 otr_browser_state_(nullptr),
119 original_browser_state_(original_browser_state) { 120 original_browser_state_(original_browser_state) {
120 // Not calling Init() here as the bi-directional link between original and 121 // Not calling Init() here as the bi-directional link between original and
121 // off-the-record TestChromeBrowserState must be established before this 122 // off-the-record TestChromeBrowserState must be established before this
122 // method can be called. 123 // method can be called.
123 DCHECK(original_browser_state_); 124 DCHECK(original_browser_state_);
124 } 125 }
125 126
126 TestChromeBrowserState::TestChromeBrowserState( 127 TestChromeBrowserState::TestChromeBrowserState(
127 const base::FilePath& path, 128 const base::FilePath& path,
128 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs, 129 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs,
129 const TestingFactories& testing_factories, 130 const TestingFactories& testing_factories,
130 const RefcountedTestingFactories& refcounted_testing_factories) 131 const RefcountedTestingFactories& refcounted_testing_factories)
131 : state_path_(path), 132 : state_path_(path),
132 prefs_(std::move(prefs)), 133 prefs_(std::move(prefs)),
133 testing_prefs_(nullptr), 134 testing_prefs_(nullptr),
134 otr_browser_state_(nullptr), 135 otr_browser_state_(nullptr),
135 original_browser_state_(nullptr) { 136 original_browser_state_(nullptr) {
136 Init(); 137 Init();
137 138
138 for (const auto& pair : testing_factories) { 139 for (const auto& pair : testing_factories) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DCHECK(!build_called_); 404 DCHECK(!build_called_);
404 refcounted_testing_factories_.push_back(std::make_pair(service_factory, cb)); 405 refcounted_testing_factories_.push_back(std::make_pair(service_factory, cb));
405 } 406 }
406 407
407 void TestChromeBrowserState::Builder::SetPath(const base::FilePath& path) { 408 void TestChromeBrowserState::Builder::SetPath(const base::FilePath& path) {
408 DCHECK(!build_called_); 409 DCHECK(!build_called_);
409 state_path_ = path; 410 state_path_ = path;
410 } 411 }
411 412
412 void TestChromeBrowserState::Builder::SetPrefService( 413 void TestChromeBrowserState::Builder::SetPrefService(
413 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs) { 414 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs) {
414 DCHECK(!build_called_); 415 DCHECK(!build_called_);
415 pref_service_ = std::move(prefs); 416 pref_service_ = std::move(prefs);
416 } 417 }
417 418
418 scoped_ptr<TestChromeBrowserState> TestChromeBrowserState::Builder::Build() { 419 std::unique_ptr<TestChromeBrowserState>
420 TestChromeBrowserState::Builder::Build() {
419 DCHECK(!build_called_); 421 DCHECK(!build_called_);
420 return make_scoped_ptr(new TestChromeBrowserState( 422 return base::WrapUnique(new TestChromeBrowserState(
421 state_path_, std::move(pref_service_), testing_factories_, 423 state_path_, std::move(pref_service_), testing_factories_,
422 refcounted_testing_factories_)); 424 refcounted_testing_factories_));
423 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698