Skip to content

Commit

Permalink
Convert //components/[a-e]* from scoped_ptr to std::unique_ptr
Browse files Browse the repository at this point in the history
BUG=554298
R=danakj@chromium.org
TBR=jochen@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#389675}
  • Loading branch information
zetafunction authored and Commit bot committed Apr 26, 2016
1 parent 792007b commit a0ee5fb
Show file tree
Hide file tree
Showing 85 changed files with 381 additions and 332 deletions.
4 changes: 2 additions & 2 deletions components/app_modal/javascript_dialog_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ JavaScriptDialogManager* JavaScriptDialogManager::GetInstance() {
}

void JavaScriptDialogManager::SetNativeDialogFactory(
scoped_ptr<JavaScriptNativeDialogFactory> factory) {
std::unique_ptr<JavaScriptNativeDialogFactory> factory) {
native_dialog_factory_ = std::move(factory);
}

void JavaScriptDialogManager::SetExtensionsClient(
scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client) {
std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client) {
extensions_client_ = std::move(extensions_client);
}

Expand Down
11 changes: 6 additions & 5 deletions components/app_modal/javascript_dialog_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
#define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/time/time.h"
#include "components/app_modal/javascript_app_modal_dialog.h"
Expand All @@ -28,13 +29,13 @@ class JavaScriptDialogManager : public content::JavaScriptDialogManager {
// Sets the JavaScriptNativeDialogFactory used to create platform specific
// dialog window instances.
void SetNativeDialogFactory(
scoped_ptr<JavaScriptNativeDialogFactory> factory);
std::unique_ptr<JavaScriptNativeDialogFactory> factory);

// JavaScript dialogs may be opened by an extensions/app, thus they need
// access to extensions functionality. This sets a client interface to
// access //extensions.
void SetExtensionsClient(
scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client);
std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client);

private:
friend struct base::DefaultSingletonTraits<JavaScriptDialogManager>;
Expand Down Expand Up @@ -81,8 +82,8 @@ class JavaScriptDialogManager : public content::JavaScriptDialogManager {
// is a void* because the pointer is just a cookie and is never dereferenced.
JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_;

scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_;
scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_;
std::unique_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_;
std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client_;

// Record a single create and close timestamp to track the time between
// dialogs. (Since Javascript dialogs are modal, this is even accurate!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#ifndef COMPONENTS_APP_MODAL_VIEWS_JAVASCRIPT_APP_MODAL_DIALOG_VIEWS_H_
#define COMPONENTS_APP_MODAL_VIEWS_JAVASCRIPT_APP_MODAL_DIALOG_VIEWS_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "components/app_modal/native_app_modal_dialog.h"
#include "ui/views/window/dialog_delegate.h"

Expand Down Expand Up @@ -52,7 +53,7 @@ class JavaScriptAppModalDialogViews : public NativeAppModalDialog,

private:
// A pointer to the AppModalDialog that owns us.
scoped_ptr<JavaScriptAppModalDialog> parent_;
std::unique_ptr<JavaScriptAppModalDialog> parent_;

// The message box view whose commands we handle.
views::MessageBoxView* message_box_view_;
Expand Down
5 changes: 3 additions & 2 deletions components/arc/arc_bridge_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/posix/eintr_wrapper.h"
#include "base/task_runner_util.h"
#include "base/thread_task_runner_handle.h"
Expand Down Expand Up @@ -337,8 +338,8 @@ ArcBridgeBootstrap::ArcBridgeBootstrap() {}
ArcBridgeBootstrap::~ArcBridgeBootstrap() {}

// static
scoped_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() {
return make_scoped_ptr(new ArcBridgeBootstrapImpl());
std::unique_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() {
return base::WrapUnique(new ArcBridgeBootstrapImpl());
}

} // namespace arc
5 changes: 3 additions & 2 deletions components/arc/arc_bridge_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#ifndef COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_
#define COMPONENTS_ARC_ARC_BRIDGE_BOOTSTRAP_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "components/arc/common/arc_bridge.mojom.h"
Expand All @@ -26,7 +27,7 @@ class ArcBridgeBootstrap {
};

// Creates a default instance of ArcBridgeBootstrap.
static scoped_ptr<ArcBridgeBootstrap> Create();
static std::unique_ptr<ArcBridgeBootstrap> Create();
virtual ~ArcBridgeBootstrap();

// This must be called before calling Start() or Stop(). |delegate| is owned
Expand Down
1 change: 0 additions & 1 deletion components/arc/arc_bridge_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "base/files/scoped_file.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "components/arc/common/arc_bridge.mojom.h"
Expand Down
2 changes: 1 addition & 1 deletion components/arc/arc_bridge_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace arc {

ArcBridgeServiceImpl::ArcBridgeServiceImpl(
scoped_ptr<ArcBridgeBootstrap> bootstrap)
std::unique_ptr<ArcBridgeBootstrap> bootstrap)
: bootstrap_(std::move(bootstrap)),
binding_(this),
session_started_(false),
Expand Down
5 changes: 3 additions & 2 deletions components/arc/arc_bridge_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_
#define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_

#include <memory>
#include <string>
#include <vector>

Expand All @@ -26,7 +27,7 @@ namespace arc {
class ArcBridgeServiceImpl : public ArcBridgeService,
public ArcBridgeBootstrap::Delegate {
public:
explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap);
explicit ArcBridgeServiceImpl(std::unique_ptr<ArcBridgeBootstrap> bootstrap);
~ArcBridgeServiceImpl() override;

void SetDetectedAvailability(bool available) override;
Expand Down Expand Up @@ -55,7 +56,7 @@ class ArcBridgeServiceImpl : public ArcBridgeService,
// the ARC instance crashes. This is not called during shutdown.
void OnChannelClosed();

scoped_ptr<ArcBridgeBootstrap> bootstrap_;
std::unique_ptr<ArcBridgeBootstrap> bootstrap_;

// Mojo endpoints.
mojo::Binding<mojom::ArcBridgeHost> binding_;
Expand Down
9 changes: 6 additions & 3 deletions components/arc/arc_bridge_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>

#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/arc/arc_bridge_service_impl.h"
Expand Down Expand Up @@ -41,8 +44,8 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {
ArcBridgeService::State state() const { return state_; }

protected:
scoped_ptr<ArcBridgeServiceImpl> service_;
scoped_ptr<FakeArcBridgeInstance> instance_;
std::unique_ptr<ArcBridgeServiceImpl> service_;
std::unique_ptr<FakeArcBridgeInstance> instance_;

private:
void SetUp() override {
Expand All @@ -53,7 +56,7 @@ class ArcBridgeTest : public testing::Test, public ArcBridgeService::Observer {

instance_.reset(new FakeArcBridgeInstance());
service_.reset(new ArcBridgeServiceImpl(
make_scoped_ptr(new FakeArcBridgeBootstrap(instance_.get()))));
base::WrapUnique(new FakeArcBridgeBootstrap(instance_.get()))));

service_->AddObserver(this);
}
Expand Down
25 changes: 13 additions & 12 deletions components/arc/arc_service_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "components/arc/arc_service_manager.h"

#include "base/memory/ptr_util.h"
#include "base/sequenced_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "components/arc/arc_bridge_bootstrap.h"
Expand Down Expand Up @@ -44,16 +45,16 @@ ArcServiceManager::ArcServiceManager() {
ArcBridgeBootstrap::Create()));
}

AddService(make_scoped_ptr(new ArcAudioBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcBluetoothBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcClipboardBridge(arc_bridge_service())));
AddService(base::WrapUnique(new ArcAudioBridge(arc_bridge_service())));
AddService(base::WrapUnique(new ArcBluetoothBridge(arc_bridge_service())));
AddService(base::WrapUnique(new ArcClipboardBridge(arc_bridge_service())));
AddService(
make_scoped_ptr(new ArcCrashCollectorBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcImeService(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcIntentHelperBridge(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcMetricsService(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcNetHostImpl(arc_bridge_service())));
AddService(make_scoped_ptr(new ArcPowerBridge(arc_bridge_service())));
base::WrapUnique(new ArcCrashCollectorBridge(arc_bridge_service())));
AddService(base::WrapUnique(new ArcImeService(arc_bridge_service())));
AddService(base::WrapUnique(new ArcIntentHelperBridge(arc_bridge_service())));
AddService(base::WrapUnique(new ArcMetricsService(arc_bridge_service())));
AddService(base::WrapUnique(new ArcNetHostImpl(arc_bridge_service())));
AddService(base::WrapUnique(new ArcPowerBridge(arc_bridge_service())));
}

ArcServiceManager::~ArcServiceManager() {
Expand All @@ -77,7 +78,7 @@ ArcBridgeService* ArcServiceManager::arc_bridge_service() {
return arc_bridge_service_.get();
}

void ArcServiceManager::AddService(scoped_ptr<ArcService> service) {
void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) {
DCHECK(thread_checker_.CalledOnValidThread());

services_.emplace_back(std::move(service));
Expand All @@ -87,7 +88,7 @@ void ArcServiceManager::OnPrimaryUserProfilePrepared(
const AccountId& account_id) {
DCHECK(thread_checker_.CalledOnValidThread());

AddService(make_scoped_ptr(
AddService(base::WrapUnique(
new ArcNotificationManager(arc_bridge_service(), account_id)));
}

Expand All @@ -97,7 +98,7 @@ void ArcServiceManager::Shutdown() {

//static
void ArcServiceManager::SetArcBridgeServiceForTesting(
scoped_ptr<ArcBridgeService> arc_bridge_service) {
std::unique_ptr<ArcBridgeService> arc_bridge_service) {
if (g_arc_bridge_service_for_testing) {
delete g_arc_bridge_service_for_testing;
}
Expand Down
10 changes: 5 additions & 5 deletions components/arc/arc_service_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_
#define COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_

#include <memory>
#include <vector>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "components/signin/core/account_id/account_id.h"

Expand All @@ -29,7 +29,7 @@ class ArcServiceManager {
ArcBridgeService* arc_bridge_service();

// Adds a service to the managed services list.
void AddService(scoped_ptr<ArcService> service);
void AddService(std::unique_ptr<ArcService> service);

// Gets the global instance of the ARC Service Manager. This can only be
// called on the thread that this class was created on.
Expand All @@ -44,12 +44,12 @@ class ArcServiceManager {
// Set ArcBridgeService instance for testing. Call before ArcServiceManager
// creation. ArcServiceManager owns |arc_bridge_service|.
static void SetArcBridgeServiceForTesting(
scoped_ptr<ArcBridgeService> arc_bridge_service);
std::unique_ptr<ArcBridgeService> arc_bridge_service);

private:
base::ThreadChecker thread_checker_;
scoped_ptr<ArcBridgeService> arc_bridge_service_;
std::vector<scoped_ptr<ArcService>> services_;
std::unique_ptr<ArcBridgeService> arc_bridge_service_;
std::vector<std::unique_ptr<ArcService>> services_;

DISALLOW_COPY_AND_ASSIGN(ArcServiceManager);
};
Expand Down
2 changes: 1 addition & 1 deletion components/arc/bluetooth/arc_bluetooth_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ void ArcBluetoothBridge::OnPoweredError(
}

void ArcBluetoothBridge::OnDiscoveryStarted(
scoped_ptr<BluetoothDiscoverySession> session) {
std::unique_ptr<BluetoothDiscoverySession> session) {
if (!HasBluetoothInstance())
return;

Expand Down
5 changes: 3 additions & 2 deletions components/arc/bluetooth/arc_bluetooth_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <stdint.h>

#include <memory>
#include <string>
#include <vector>

Expand Down Expand Up @@ -143,7 +144,7 @@ class ArcBluetoothBridge
void OnPoweredError(
const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
void OnDiscoveryStarted(
scoped_ptr<device::BluetoothDiscoverySession> session);
std::unique_ptr<device::BluetoothDiscoverySession> session);
void OnDiscoveryStopped();
void OnDiscoveryError();
void OnPairing(mojom::BluetoothAddressPtr addr) const;
Expand All @@ -170,7 +171,7 @@ class ArcBluetoothBridge
mojo::Binding<mojom::BluetoothHost> binding_;

scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
scoped_ptr<device::BluetoothDiscoverySession> discovery_session_;
std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;

// WeakPtrFactory to use for callbacks.
base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_;
Expand Down
2 changes: 1 addition & 1 deletion components/arc/ime/arc_ime_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ArcImeService::~ArcImeService() {
}

void ArcImeService::SetImeBridgeForTesting(
scoped_ptr<ArcImeBridge> test_ime_bridge) {
std::unique_ptr<ArcImeBridge> test_ime_bridge) {
ime_bridge_ = std::move(test_ime_bridge);
}

Expand Down
7 changes: 4 additions & 3 deletions components/arc/ime/arc_ime_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#ifndef COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_
#define COMPONENTS_ARC_IME_ARC_IME_SERVICE_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "components/arc/arc_service.h"
#include "components/arc/ime/arc_ime_bridge.h"
#include "ui/aura/client/focus_change_observer.h"
Expand Down Expand Up @@ -43,7 +44,7 @@ class ArcImeService : public ArcService,
~ArcImeService() override;

// Injects the custom IPC bridge object for testing purpose only.
void SetImeBridgeForTesting(scoped_ptr<ArcImeBridge> test_ime_bridge);
void SetImeBridgeForTesting(std::unique_ptr<ArcImeBridge> test_ime_bridge);

// Injects the custom IME for testing purpose only.
void SetInputMethodForTesting(ui::InputMethod* test_input_method);
Expand Down Expand Up @@ -99,7 +100,7 @@ class ArcImeService : public ArcService,
private:
ui::InputMethod* GetInputMethod();

scoped_ptr<ArcImeBridge> ime_bridge_;
std::unique_ptr<ArcImeBridge> ime_bridge_;
ui::TextInputType ime_type_;
gfx::Rect cursor_rect_;
bool has_composition_text_;
Expand Down
14 changes: 8 additions & 6 deletions components/arc/ime/arc_ime_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/arc/ime/arc_ime_service.h"

#include <memory>
#include <utility>

#include "base/memory/scoped_ptr.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/arc/ime/arc_ime_service.h"
#include "components/arc/test/fake_arc_bridge_service.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/composition_text.h"
Expand Down Expand Up @@ -71,15 +73,15 @@ class ArcImeServiceTest : public testing::Test {
ArcImeServiceTest() {}

protected:
scoped_ptr<FakeArcBridgeService> fake_arc_bridge_service_;
scoped_ptr<FakeInputMethod> fake_input_method_;
scoped_ptr<ArcImeService> instance_;
std::unique_ptr<FakeArcBridgeService> fake_arc_bridge_service_;
std::unique_ptr<FakeInputMethod> fake_input_method_;
std::unique_ptr<ArcImeService> instance_;

private:
void SetUp() override {
fake_arc_bridge_service_.reset(new FakeArcBridgeService);
instance_.reset(new ArcImeService(fake_arc_bridge_service_.get()));
instance_->SetImeBridgeForTesting(make_scoped_ptr(new FakeArcImeBridge));
instance_->SetImeBridgeForTesting(base::WrapUnique(new FakeArcImeBridge));

fake_input_method_.reset(new FakeInputMethod);
instance_->SetInputMethodForTesting(fake_input_method_.get());
Expand Down
Loading

0 comments on commit a0ee5fb

Please sign in to comment.