Skip to content

Commit

Permalink
Convert //chrome/browser from scoped_ptr to std::unique_ptr
Browse files Browse the repository at this point in the history
BUG=554298

Review URL: https://codereview.chromium.org/1902583002

Cr-Commit-Position: refs/heads/master@{#388093}
  • Loading branch information
zetafunction authored and Commit bot committed Apr 19, 2016
1 parent 85719a9 commit 4af4858
Show file tree
Hide file tree
Showing 619 changed files with 2,813 additions and 2,565 deletions.
13 changes: 7 additions & 6 deletions chrome/browser/after_startup_task_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include "chrome/browser/after_startup_task_utils.h"

#include <memory>
#include <utility>

#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/process/process_info.h"
#include "base/rand_util.h"
Expand Down Expand Up @@ -57,13 +58,13 @@ bool IsBrowserStartupComplete() {
return g_startup_complete_flag.Get().IsSet();
}

void RunTask(scoped_ptr<AfterStartupTask> queued_task) {
void RunTask(std::unique_ptr<AfterStartupTask> queued_task) {
// We're careful to delete the caller's |task| on the target runner's thread.
DCHECK(queued_task->task_runner->RunsTasksOnCurrentThread());
queued_task->task.Run();
}

void ScheduleTask(scoped_ptr<AfterStartupTask> queued_task) {
void ScheduleTask(std::unique_ptr<AfterStartupTask> queued_task) {
// Spread their execution over a brief time.
const int kMinDelaySec = 0;
const int kMaxDelaySec = 10;
Expand All @@ -74,7 +75,7 @@ void ScheduleTask(scoped_ptr<AfterStartupTask> queued_task) {
base::TimeDelta::FromSeconds(base::RandInt(kMinDelaySec, kMaxDelaySec)));
}

void QueueTask(scoped_ptr<AfterStartupTask> queued_task) {
void QueueTask(std::unique_ptr<AfterStartupTask> queued_task) {
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
Expand Down Expand Up @@ -106,7 +107,7 @@ void SetBrowserStartupIsComplete() {
g_after_startup_tasks.Get().size());
g_startup_complete_flag.Get().Set();
for (AfterStartupTask* queued_task : g_after_startup_tasks.Get())
ScheduleTask(make_scoped_ptr(queued_task));
ScheduleTask(base::WrapUnique(queued_task));
g_after_startup_tasks.Get().clear();

// The shrink_to_fit() method is not available for all of our build targets.
Expand Down Expand Up @@ -206,7 +207,7 @@ void AfterStartupTaskUtils::PostTask(
return;
}

scoped_ptr<AfterStartupTask> queued_task(
std::unique_ptr<AfterStartupTask> queued_task(
new AfterStartupTask(from_here, task_runner, task));
QueueTask(std::move(queued_task));
}
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/after_startup_task_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

#include "chrome/browser/after_startup_task_utils.h"

#include <memory>

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/task_runner_util.h"
Expand Down
16 changes: 9 additions & 7 deletions chrome/browser/app_controller_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#if defined(__OBJC__)

#import <Cocoa/Cocoa.h>

#include <memory>
#include <vector>

#include "base/files/file_path.h"
#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/prefs/pref_change_registrar.h"
Expand Down Expand Up @@ -43,15 +44,16 @@ class WorkAreaWatcherObserver;
NSApplicationDelegate> {
@private
// Manages the state of the command menu items.
scoped_ptr<CommandUpdater> menuState_;
std::unique_ptr<CommandUpdater> menuState_;

// The profile last used by a Browser. It is this profile that was used to
// build the user-data specific main menu items.
Profile* lastProfile_;

// The ProfileObserver observes the ProfileAttrbutesStorage and gets notified
// when a profile has been deleted.
scoped_ptr<AppControllerProfileObserver> profileAttributesStorageObserver_;
std::unique_ptr<AppControllerProfileObserver>
profileAttributesStorageObserver_;

// Management of the bookmark menu which spans across all windows
// (and Browser*s). |profileBookmarkMenuBridgeMap_| is a cache that owns one
Expand All @@ -61,7 +63,7 @@ class WorkAreaWatcherObserver;
BookmarkMenuBridge* bookmarkMenuBridge_;
std::map<base::FilePath, BookmarkMenuBridge*> profileBookmarkMenuBridgeMap_;

scoped_ptr<HistoryMenuBridge> historyMenuBridge_;
std::unique_ptr<HistoryMenuBridge> historyMenuBridge_;

// Controller that manages main menu items for packaged apps.
base::scoped_nsobject<AppShimMenuController> appShimMenuController_;
Expand Down Expand Up @@ -93,7 +95,7 @@ class WorkAreaWatcherObserver;
// Observers that listen to the work area changes.
base::ObserverList<ui::WorkAreaWatcherObserver> workAreaChangeObservers_;

scoped_ptr<PrefChangeRegistrar> profilePrefRegistrar_;
std::unique_ptr<PrefChangeRegistrar> profilePrefRegistrar_;
PrefChangeRegistrar localPrefRegistrar_;

// Displays a notification when quitting while apps are running.
Expand All @@ -103,14 +105,14 @@ class WorkAreaWatcherObserver;
base::scoped_nsobject<HandoffManager> handoffManager_;

// Observes changes to the active URL.
scoped_ptr<HandoffActiveURLObserverBridge>
std::unique_ptr<HandoffActiveURLObserverBridge>
handoff_active_url_observer_bridge_;

// This will be true after receiving a NSWorkspaceWillPowerOffNotification.
BOOL isPoweringOff_;

// Request to keep the browser alive during that object's lifetime.
scoped_ptr<ScopedKeepAlive> keep_alive_;
std::unique_ptr<ScopedKeepAlive> keep_alive_;
}

@property(readonly, nonatomic) BOOL startupComplete;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/app_icon_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ gfx::Size GetSmallAppIconSize() {
GetSystemMetrics(SM_CYSMICON));
}

scoped_ptr<gfx::ImageFamily> GetAppIconImageFamily() {
std::unique_ptr<gfx::ImageFamily> GetAppIconImageFamily() {
const int icon_id = GetAppIconResourceId();
// Get the icon from chrome.dll (not chrome.exe, which has different resource
// IDs). If chrome.dll is not loaded, we are probably in a unit test, so fall
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/app_icon_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <windows.h>

#include "base/memory/scoped_ptr.h"
#include <memory>

namespace gfx {
class ImageFamily;
Expand All @@ -24,6 +24,6 @@ gfx::Size GetSmallAppIconSize();

// Retrieve the application icon for the current process. This returns all of
// the different sizes of the icon as an ImageFamily.
scoped_ptr<gfx::ImageFamily> GetAppIconImageFamily();
std::unique_ptr<gfx::ImageFamily> GetAppIconImageFamily();

#endif // CHROME_BROWSER_APP_ICON_WIN_H_
11 changes: 6 additions & 5 deletions chrome/browser/autocomplete/autocomplete_classifier_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"

#include "base/memory/ptr_util.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
#include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
Expand Down Expand Up @@ -33,14 +34,14 @@ AutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() {
}

// static
scoped_ptr<KeyedService> AutocompleteClassifierFactory::BuildInstanceFor(
std::unique_ptr<KeyedService> AutocompleteClassifierFactory::BuildInstanceFor(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
return make_scoped_ptr(new AutocompleteClassifier(
make_scoped_ptr(new AutocompleteController(
make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)), NULL,
return base::WrapUnique(new AutocompleteClassifier(
base::WrapUnique(new AutocompleteController(
base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), NULL,
AutocompleteClassifier::kDefaultOmniboxProviders)),
scoped_ptr<AutocompleteSchemeClassifier>(
std::unique_ptr<AutocompleteSchemeClassifier>(
new ChromeAutocompleteSchemeClassifier(profile))));
}

Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/autocomplete/autocomplete_classifier_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_FACTORY_H_
#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CLASSIFIER_FACTORY_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"

Expand All @@ -22,7 +23,7 @@ class AutocompleteClassifierFactory : public BrowserContextKeyedServiceFactory {

static AutocompleteClassifierFactory* GetInstance();

static scoped_ptr<KeyedService> BuildInstanceFor(
static std::unique_ptr<KeyedService> BuildInstanceFor(
content::BrowserContext* context);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stddef.h>

#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
Expand Down Expand Up @@ -137,11 +138,11 @@ ChromeAutocompleteProviderClient::GetShortcutsBackendIfExists() {
return ShortcutsBackendFactory::GetForProfileIfExists(profile_);
}

scoped_ptr<KeywordExtensionsDelegate>
std::unique_ptr<KeywordExtensionsDelegate>
ChromeAutocompleteProviderClient::GetKeywordExtensionsDelegate(
KeywordProvider* keyword_provider) {
#if defined(ENABLE_EXTENSIONS)
return make_scoped_ptr(
return base::WrapUnique(
new KeywordExtensionsDelegateImpl(profile_, keyword_provider));
#else
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ChromeAutocompleteProviderClient : public AutocompleteProviderClient {
const SearchTermsData& GetSearchTermsData() const override;
scoped_refptr<ShortcutsBackend> GetShortcutsBackend() override;
scoped_refptr<ShortcutsBackend> GetShortcutsBackendIfExists() override;
scoped_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate(
std::unique_ptr<KeywordExtensionsDelegate> GetKeywordExtensionsDelegate(
KeywordProvider* keyword_provider) override;
std::string GetAcceptLanguages() const override;
std::string GetEmbedderRepresentationOfAboutScheme() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void KeywordExtensionsDelegateImplTest::SetUp() {
}

void KeywordExtensionsDelegateImplTest::RunTest(bool incognito) {
scoped_ptr<TemplateURLService> empty_model(new TemplateURLService(NULL, 0));
std::unique_ptr<TemplateURLService> empty_model(
new TemplateURLService(NULL, 0));
MockAutocompleteProviderClient client;
client.set_template_url_service(std::move(empty_model));
scoped_refptr<KeywordProvider> keyword_provider =
Expand Down
9 changes: 5 additions & 4 deletions chrome/browser/autocomplete/search_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
#include "base/run_loop.h"
#include "base/strings/string16.h"
Expand Down Expand Up @@ -167,7 +168,7 @@ class SearchProviderTest : public testing::Test,

protected:
// Needed for AutocompleteFieldTrial::ActivateStaticTrials();
scoped_ptr<base::FieldTrialList> field_trial_list_;
std::unique_ptr<base::FieldTrialList> field_trial_list_;

// Default values used for testing.
static const std::string kNotApplicable;
Expand Down Expand Up @@ -257,7 +258,7 @@ class SearchProviderTest : public testing::Test,

net::TestURLFetcherFactory test_factory_;
TestingProfile profile_;
scoped_ptr<ChromeAutocompleteProviderClient> client_;
std::unique_ptr<ChromeAutocompleteProviderClient> client_;
scoped_refptr<SearchProviderForTest> provider_;

// If non-NULL, OnProviderUpdate quits the current |run_loop_|.
Expand Down Expand Up @@ -1090,8 +1091,8 @@ TEST_F(SearchProviderTest, KeywordOrderingAndDescriptions) {
profile_.BlockUntilHistoryProcessesPendingRequests();

AutocompleteController controller(
make_scoped_ptr(new ChromeAutocompleteProviderClient(&profile_)), nullptr,
AutocompleteProvider::TYPE_SEARCH);
base::WrapUnique(new ChromeAutocompleteProviderClient(&profile_)),
nullptr, AutocompleteProvider::TYPE_SEARCH);
controller.Start(AutocompleteInput(
ASCIIToUTF16("k t"), base::string16::npos, std::string(), GURL(),
metrics::OmniboxEventProto::INVALID_SPEC, false, false, true, true, false,
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/autocomplete/shortcuts_backend_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#include "chrome/browser/autocomplete/shortcuts_backend_factory.h"

#include "base/memory/scoped_ptr.h"
#include <memory>

#include "base/memory/ptr_util.h"
#include "chrome/browser/autocomplete/shortcuts_extensions_manager.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
Expand Down Expand Up @@ -90,7 +92,7 @@ scoped_refptr<ShortcutsBackend> ShortcutsBackendFactory::CreateShortcutsBackend(
bool suppress_db) {
scoped_refptr<ShortcutsBackend> backend(new ShortcutsBackend(
TemplateURLServiceFactory::GetForProfile(profile),
make_scoped_ptr(new UIThreadSearchTermsData(profile)),
base::WrapUnique(new UIThreadSearchTermsData(profile)),
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS),
content::BrowserThread::GetMessageLoopProxyForThread(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BackgroundApplicationListModel::Application
void RequestIcon(extension_misc::ExtensionIcons size);

const Extension* extension_;
scoped_ptr<gfx::ImageSkia> icon_;
std::unique_ptr<gfx::ImageSkia> icon_;
BackgroundApplicationListModel* model_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

// TODO(rickcam): Bug 73183: Add unit tests for image loading

#include "chrome/browser/background/background_application_list_model.h"

#include <stddef.h>

#include <cstdlib>
#include <memory>
#include <set>

#include "chrome/browser/background/background_application_list_model.h"

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -150,7 +150,7 @@ TEST_F(BackgroundApplicationListModelTest, MAYBE_ExplicitTest) {
InitializeAndLoadEmptyExtensionService();
ASSERT_TRUE(service()->is_ready());
ASSERT_TRUE(registry()->enabled_extensions().is_empty());
scoped_ptr<BackgroundApplicationListModel> model(
std::unique_ptr<BackgroundApplicationListModel> model(
new BackgroundApplicationListModel(profile_.get()));
ASSERT_EQ(0U, model->size());

Expand Down Expand Up @@ -222,7 +222,7 @@ TEST_F(BackgroundApplicationListModelTest, AddRemovePermissionsTest) {
InitializeAndLoadEmptyExtensionService();
ASSERT_TRUE(service()->is_ready());
ASSERT_TRUE(registry()->enabled_extensions().is_empty());
scoped_ptr<BackgroundApplicationListModel> model(
std::unique_ptr<BackgroundApplicationListModel> model(
new BackgroundApplicationListModel(profile_.get()));
ASSERT_EQ(0U, model->size());

Expand Down Expand Up @@ -378,7 +378,7 @@ TEST_F(BackgroundApplicationListModelTest, RandomTest) {
InitializeAndLoadEmptyExtensionService();
ASSERT_TRUE(service()->is_ready());
ASSERT_TRUE(registry()->enabled_extensions().is_empty());
scoped_ptr<BackgroundApplicationListModel> model(
std::unique_ptr<BackgroundApplicationListModel> model(
new BackgroundApplicationListModel(profile_.get()));
ASSERT_EQ(0U, model->size());

Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/background/background_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

#include <stdint.h>

#include <memory>
#include <string>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
Expand Down Expand Up @@ -109,10 +109,10 @@ class BackgroundContents : public extensions::DeferredStartRenderHost,
Delegate* delegate_;

// Delegate for choosing an ExtensionHostQueue.
scoped_ptr<extensions::ExtensionHostDelegate> extension_host_delegate_;
std::unique_ptr<extensions::ExtensionHostDelegate> extension_host_delegate_;

Profile* profile_;
scoped_ptr<content::WebContents> web_contents_;
std::unique_ptr<content::WebContents> web_contents_;
content::NotificationRegistrar registrar_;
base::ObserverList<extensions::DeferredStartRenderHostObserver>
deferred_start_render_host_observer_list_;
Expand Down
Loading

0 comments on commit 4af4858

Please sign in to comment.