Commit 4af48586 authored by dcheng's avatar dcheng Committed by Commit bot

Convert //chrome/browser from scoped_ptr to std::unique_ptr

BUG=554298

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

Cr-Commit-Position: refs/heads/master@{#388093}
parent 85719a9f
......@@ -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"
......@@ -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;
......@@ -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,
......@@ -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.
......@@ -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));
}
......
......@@ -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"
......
......@@ -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"
......@@ -43,7 +44,7 @@ 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.
......@@ -51,7 +52,8 @@ class WorkAreaWatcherObserver;
// 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
......@@ -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_;
......@@ -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.
......@@ -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;
......
......@@ -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
......
......@@ -7,7 +7,7 @@
#include <windows.h>
#include "base/memory/scoped_ptr.h"
#include <memory>
namespace gfx {
class ImageFamily;
......@@ -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_
......@@ -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"
......@@ -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))));
}
......
......@@ -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"
......@@ -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:
......
......@@ -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"
......@@ -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;
......
......@@ -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;
......
......@@ -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 =
......
......@@ -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"
......@@ -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;
......@@ -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_|.
......@@ -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,
......
......@@ -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"
......@@ -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(
......
......@@ -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_;
};
......
......@@ -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"
......@@ -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());
......@@ -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());