Skip to content

Commit

Permalink
Convert //chromeos from scoped_ptr to std::unique_ptr
Browse files Browse the repository at this point in the history
BUG=554298
TBR=rdevlin.cronin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#386131}
  • Loading branch information
zetafunction authored and Commit bot committed Apr 8, 2016
1 parent 23f24a3 commit 0a6e80c
Show file tree
Hide file tree
Showing 190 changed files with 1,202 additions and 1,116 deletions.
9 changes: 5 additions & 4 deletions chromeos/app_mode/kiosk_oem_manifest_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

#include "chromeos/app_mode/kiosk_oem_manifest_parser.h"

#include <memory>

#include "base/json/json_file_value_serializer.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"

Expand All @@ -31,9 +32,9 @@ bool KioskOemManifestParser::Load(
KioskOemManifestParser::Manifest* manifest) {
int error_code = JSONFileValueDeserializer::JSON_NO_ERROR;
std::string error_msg;
scoped_ptr<JSONFileValueDeserializer> deserializer(
new JSONFileValueDeserializer(kiosk_oem_file));
scoped_ptr<base::Value> value =
std::unique_ptr<JSONFileValueDeserializer> deserializer(
new JSONFileValueDeserializer(kiosk_oem_file));
std::unique_ptr<base::Value> value =
deserializer->Deserialize(&error_code, &error_msg);
base::DictionaryValue* dict = NULL;
if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR ||
Expand Down
2 changes: 1 addition & 1 deletion chromeos/attestation/attestation_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::string GetKeyNameForProfile(AttestationCertificateProfile profile,

AttestationFlow::AttestationFlow(cryptohome::AsyncMethodCaller* async_caller,
CryptohomeClient* cryptohome_client,
scoped_ptr<ServerProxy> server_proxy)
std::unique_ptr<ServerProxy> server_proxy)
: async_caller_(async_caller),
cryptohome_client_(cryptohome_client),
server_proxy_(std::move(server_proxy)),
Expand Down
6 changes: 3 additions & 3 deletions chromeos/attestation/attestation_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#ifndef CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_
#define CHROMEOS_ATTESTATION_ATTESTATION_FLOW_H_

#include <memory>
#include <string>

#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chromeos/attestation/attestation_constants.h"
#include "chromeos/chromeos_export.h"
Expand Down Expand Up @@ -59,7 +59,7 @@ class CHROMEOS_EXPORT AttestationFlow {

AttestationFlow(cryptohome::AsyncMethodCaller* async_caller,
CryptohomeClient* cryptohome_client,
scoped_ptr<ServerProxy> server_proxy);
std::unique_ptr<ServerProxy> server_proxy);
virtual ~AttestationFlow();

// Gets an attestation certificate for a hardware-protected key. If a key for
Expand Down Expand Up @@ -205,7 +205,7 @@ class CHROMEOS_EXPORT AttestationFlow {

cryptohome::AsyncMethodCaller* async_caller_;
CryptohomeClient* cryptohome_client_;
scoped_ptr<ServerProxy> server_proxy_;
std::unique_ptr<ServerProxy> server_proxy_;

base::WeakPtrFactory<AttestationFlow> weak_factory_;

Expand Down
46 changes: 23 additions & 23 deletions chromeos/attestation/attestation_flow_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>
#include <utility>

#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "chromeos/attestation/mock_attestation_flow.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
Expand Down Expand Up @@ -91,7 +91,7 @@ TEST_F(AttestationFlowTest, GetCertificate) {
.Times(1)
.InSequence(flow_order);

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(true);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendEnrollRequest(
Expand Down Expand Up @@ -140,7 +140,7 @@ TEST_F(AttestationFlowTest, GetCertificate) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, account_id,
"fake_origin", true, mock_callback);
Expand All @@ -158,7 +158,7 @@ TEST_F(AttestationFlowTest, GetCertificate_NoEK) {
.WillRepeatedly(Invoke(DBusCallbackFalse));

// We're not expecting any server calls in this case; StrictMock will verify.
scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());

StrictMock<MockObserver> observer;
Expand All @@ -168,7 +168,7 @@ TEST_F(AttestationFlowTest, GetCertificate_NoEK) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand All @@ -185,7 +185,7 @@ TEST_F(AttestationFlowTest, GetCertificate_EKRejected) {
EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
.WillRepeatedly(Invoke(DBusCallbackFalse));

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(false);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendEnrollRequest(
Expand All @@ -199,7 +199,7 @@ TEST_F(AttestationFlowTest, GetCertificate_EKRejected) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand All @@ -222,7 +222,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) {
EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
.WillRepeatedly(Invoke(DBusCallbackFalse));

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(true);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendEnrollRequest(
Expand All @@ -235,7 +235,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand All @@ -262,7 +262,7 @@ TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) {
EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
.WillRepeatedly(Invoke(DBusCallbackTrue));

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(true);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendCertificateRequest(
Expand All @@ -277,7 +277,7 @@ TEST_F(AttestationFlowTest, GetMachineCertificateAlreadyEnrolled) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_MACHINE_CERTIFICATE, EmptyAccountId(),
"", true, mock_callback);
Expand All @@ -297,7 +297,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) {
.WillRepeatedly(Invoke(DBusCallbackTrue));

// We're not expecting any server calls in this case; StrictMock will verify.
scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());

StrictMock<MockObserver> observer;
Expand All @@ -306,7 +306,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand All @@ -325,7 +325,7 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) {
EXPECT_CALL(client, TpmAttestationIsEnrolled(_))
.WillRepeatedly(Invoke(DBusCallbackTrue));

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(false);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendCertificateRequest(
Expand All @@ -338,7 +338,7 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand All @@ -354,7 +354,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) {
.WillRepeatedly(Invoke(DBusCallbackFail));

// We're not expecting any server calls in this case; StrictMock will verify.
scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());

StrictMock<MockObserver> observer;
Expand All @@ -363,7 +363,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand Down Expand Up @@ -394,7 +394,7 @@ TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) {
kEnterpriseUserKey, _))
.WillRepeatedly(WithArgs<3>(Invoke(DBusCallbackFalse)));

scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
proxy->DeferToFake(true);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());
EXPECT_CALL(*proxy, SendCertificateRequest(
Expand All @@ -409,7 +409,7 @@ TEST_F(AttestationFlowTest, GetCertificate_CheckExisting) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
false, mock_callback);
Expand All @@ -433,7 +433,7 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) {
.WillRepeatedly(WithArgs<3>(Invoke(FakeDBusData("fake_cert"))));

// We're not expecting any server calls in this case; StrictMock will verify.
scoped_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new StrictMock<MockServerProxy>());
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(DoDefault());

StrictMock<MockObserver> observer;
Expand All @@ -442,7 +442,7 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
false, mock_callback);
Expand All @@ -452,7 +452,7 @@ TEST_F(AttestationFlowTest, GetCertificate_AlreadyExists) {
TEST_F(AttestationFlowTest, AlternatePCA) {
// Strategy: Create a ServerProxy mock which reports ALTERNATE_PCA and check
// that all calls to the AsyncMethodCaller reflect this PCA type.
scoped_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>());
std::unique_ptr<MockServerProxy> proxy(new NiceMock<MockServerProxy>());
proxy->DeferToFake(true);
EXPECT_CALL(*proxy, GetType()).WillRepeatedly(Return(ALTERNATE_PCA));

Expand All @@ -477,7 +477,7 @@ TEST_F(AttestationFlowTest, AlternatePCA) {
&MockObserver::MockCertificateCallback,
base::Unretained(&observer));

scoped_ptr<ServerProxy> proxy_interface(proxy.release());
std::unique_ptr<ServerProxy> proxy_interface(proxy.release());
AttestationFlow flow(&async_caller, &client, std::move(proxy_interface));
flow.GetCertificate(PROFILE_ENTERPRISE_USER_CERTIFICATE, EmptyAccountId(), "",
true, mock_callback);
Expand Down
5 changes: 3 additions & 2 deletions chromeos/attestation/mock_attestation_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

#include "chromeos/attestation/mock_attestation_flow.h"

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

#include "components/signin/core/account_id/account_id.h"

using testing::_;
Expand Down Expand Up @@ -47,7 +48,7 @@ MockObserver::MockObserver() {}
MockObserver::~MockObserver() {}

MockAttestationFlow::MockAttestationFlow()
: AttestationFlow(NULL, NULL, scoped_ptr<ServerProxy>()) {}
: AttestationFlow(NULL, NULL, std::unique_ptr<ServerProxy>()) {}

MockAttestationFlow::~MockAttestationFlow() {}

Expand Down
2 changes: 1 addition & 1 deletion chromeos/audio/audio_devices_pref_handler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void AudioDevicesPrefHandlerImpl::SetMuteValue(const AudioDevice& device,
void AudioDevicesPrefHandlerImpl::SetDeviceActive(const AudioDevice& device,
bool active,
bool activate_by_user) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
dict->SetBoolean("active", active);
if (active)
dict->SetBoolean("activate_by_user", activate_by_user);
Expand Down
8 changes: 4 additions & 4 deletions chromeos/audio/audio_devices_pref_handler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_
#define CHROMEOS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_IMPL_H_

#include <memory>
#include <string>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/values.h"
#include "chromeos/audio/audio_devices_pref_handler.h"
Expand Down Expand Up @@ -83,9 +83,9 @@ class CHROMEOS_EXPORT AudioDevicesPrefHandlerImpl
// Notifies the AudioPrefObserver for audio policy pref changes.
void NotifyAudioPolicyChange();

scoped_ptr<base::DictionaryValue> device_mute_settings_;
scoped_ptr<base::DictionaryValue> device_volume_settings_;
scoped_ptr<base::DictionaryValue> device_state_settings_;
std::unique_ptr<base::DictionaryValue> device_mute_settings_;
std::unique_ptr<base::DictionaryValue> device_volume_settings_;
std::unique_ptr<base::DictionaryValue> device_state_settings_;

PrefService* local_state_; // not owned

Expand Down
2 changes: 1 addition & 1 deletion chromeos/audio/audio_devices_pref_handler_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AudioDevicesPrefHandlerTest : public testing::Test {

protected:
scoped_refptr<AudioDevicesPrefHandler> audio_pref_handler_;
scoped_ptr<TestingPrefServiceSimple> pref_service_;
std::unique_ptr<TestingPrefServiceSimple> pref_service_;

private:
DISALLOW_COPY_AND_ASSIGN(AudioDevicesPrefHandlerTest);
Expand Down
5 changes: 3 additions & 2 deletions chromeos/audio/cras_audio_handler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#include <stddef.h>
#include <stdint.h>

#include <memory>

#include "base/bind.h"
#include "base/macros.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/thread_task_runner_handle.h"
Expand Down Expand Up @@ -422,7 +423,7 @@ class CrasAudioHandlerTest : public testing::Test {
base::MessageLoopForUI message_loop_;
CrasAudioHandler* cras_audio_handler_; // Not owned.
FakeCrasAudioClient* fake_cras_audio_client_; // Not owned.
scoped_ptr<TestObserver> test_observer_;
std::unique_ptr<TestObserver> test_observer_;
scoped_refptr<AudioDevicesPrefHandlerStub> audio_pref_handler_;

private:
Expand Down
Loading

0 comments on commit 0a6e80c

Please sign in to comment.