Skip to content

Commit

Permalink
Global conversion of Pass()→std::move(): CrOS edition
Browse files Browse the repository at this point in the history
(╯^□^)╯︵ ❄☃❄

BUG=557422
R=avi@chromium.org
TBR=jam@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#367249}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 31, 2015
1 parent 49d16ff commit cf738a9
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ void DownloadItemNotification::UpdateNotificationData(
UpdateNotificationIcon();

std::vector<message_center::ButtonInfo> notification_actions;
scoped_ptr<std::vector<DownloadCommands::Command>> actions(
GetExtraActions().Pass());
scoped_ptr<std::vector<DownloadCommands::Command>> actions(GetExtraActions());

button_actions_.reset(new std::vector<DownloadCommands::Command>);
for (auto it = actions->begin(); it != actions->end(); it++) {
Expand Down Expand Up @@ -643,7 +642,7 @@ DownloadItemNotification::GetExtraActions() const {
actions->push_back(DownloadCommands::DISCARD);
actions->push_back(DownloadCommands::KEEP);
}
return actions.Pass();
return actions;
}

switch (item_->GetState()) {
Expand All @@ -667,7 +666,7 @@ DownloadItemNotification::GetExtraActions() const {
case content::DownloadItem::MAX_DOWNLOAD_STATE:
NOTREACHED();
}
return actions.Pass();
return actions;
}

base::string16 DownloadItemNotification::GetTitle() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chrome/browser/download/notification/download_item_notification.h"

#include <stddef.h>
#include <utility>

#include "base/macros.h"
#include "base/message_loop/message_loop.h"
Expand Down Expand Up @@ -74,8 +75,8 @@ class DownloadItemNotificationTest : public testing::Test {
profile_ = profile_manager_->CreateTestingProfile("test-user");

scoped_ptr<NotificationUIManager> ui_manager(new StubNotificationUIManager);
TestingBrowserProcess::GetGlobal()->
SetNotificationUIManager(ui_manager.Pass());
TestingBrowserProcess::GetGlobal()->SetNotificationUIManager(
std::move(ui_manager));

download_notification_manager_.reset(
new DownloadNotificationManagerForProfile(profile_, nullptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#include <stddef.h>
#include <utility>

#include "base/command_line.h"
#include "base/macros.h"
Expand Down Expand Up @@ -338,7 +339,7 @@ class DownloadNotificationTest : public DownloadNotificationTestBase {
test_delegate->GetDownloadIdReceiverCallback().Run(
content::DownloadItem::kInvalidId + 1);
DownloadServiceFactory::GetForBrowserContext(profile)
->SetDownloadManagerDelegateForTesting(test_delegate.Pass());
->SetDownloadManagerDelegateForTesting(std::move(test_delegate));

DownloadNotificationTestBase::SetUpOnMainThread();
}
Expand All @@ -359,7 +360,8 @@ class DownloadNotificationTest : public DownloadNotificationTestBase {
incognito_test_delegate.reset(
new TestChromeDownloadManagerDelegate(incognito_profile));
DownloadServiceFactory::GetForBrowserContext(incognito_profile)
->SetDownloadManagerDelegateForTesting(incognito_test_delegate.Pass());
->SetDownloadManagerDelegateForTesting(
std::move(incognito_test_delegate));
}

TestChromeDownloadManagerDelegate* GetIncognitoDownloadManagerDelegate()
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/metrics/perf/perf_provider_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "chrome/browser/metrics/perf/perf_provider_chromeos.h"

#include <stddef.h>

#include <algorithm>
#include <map>
#include <string>
#include <utility>

#include "base/bind.h"
#include "base/callback.h"
Expand Down Expand Up @@ -592,7 +592,7 @@ void PerfProvider::DoPeriodicCollection() {
scoped_ptr<SampledProfile> sampled_profile(new SampledProfile);
sampled_profile->set_trigger_event(SampledProfile::PERIODIC_COLLECTION);

CollectIfNecessary(sampled_profile.Pass());
CollectIfNecessary(std::move(sampled_profile));
}

void PerfProvider::CollectPerfDataAfterResume(
Expand All @@ -604,7 +604,7 @@ void PerfProvider::CollectPerfDataAfterResume(
sampled_profile->set_suspend_duration_ms(sleep_duration.InMilliseconds());
sampled_profile->set_ms_after_resume(time_after_resume.InMilliseconds());

CollectIfNecessary(sampled_profile.Pass());
CollectIfNecessary(std::move(sampled_profile));
}

void PerfProvider::CollectPerfDataAfterSessionRestore(
Expand All @@ -616,7 +616,7 @@ void PerfProvider::CollectPerfDataAfterSessionRestore(
sampled_profile->set_ms_after_restore(time_after_restore.InMilliseconds());
sampled_profile->set_num_tabs_restored(num_tabs_restored);

CollectIfNecessary(sampled_profile.Pass());
CollectIfNecessary(std::move(sampled_profile));
last_session_restore_collection_time_ = base::TimeTicks::Now();
}

Expand Down
73 changes: 23 additions & 50 deletions chrome/browser/metrics/perf/perf_provider_chromeos_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "chrome/browser/metrics/perf/perf_provider_chromeos.h"

#include <stdint.h>

#include <string>
#include <utility>
#include <vector>

#include "base/macros.h"
Expand Down Expand Up @@ -115,7 +115,7 @@ class TestIncognitoObserver : public WindowedIncognitoObserver {
bool incognito_launched) {
scoped_ptr<TestIncognitoObserver> observer(new TestIncognitoObserver);
observer->set_incognito_launched(incognito_launched);
return observer.Pass();
return std::move(observer);
}

private:
Expand Down Expand Up @@ -203,9 +203,7 @@ TEST_F(PerfProviderTest, NoPerfData) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
std::vector<uint8_t>());

std::vector<SampledProfile> stored_profiles;
Expand All @@ -218,10 +216,8 @@ TEST_F(PerfProviderTest, PerfDataProtoOnly) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

std::vector<SampledProfile> stored_profiles;
EXPECT_TRUE(perf_provider_->GetSampledProfiles(&stored_profiles));
Expand All @@ -243,9 +239,7 @@ TEST_F(PerfProviderTest, PerfStatProtoOnly) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
SerializeMessageToVector(perf_stat_proto_));

std::vector<SampledProfile> stored_profiles;
Expand All @@ -268,8 +262,7 @@ TEST_F(PerfProviderTest, BothPerfDataProtoAndPerfStatProto) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
SerializeMessageToVector(perf_stat_proto_));

Expand All @@ -284,10 +277,8 @@ TEST_F(PerfProviderTest, InvalidPerfOutputResult) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfFailure,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfFailure,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

// Should not have been stored.
std::vector<SampledProfile> stored_profiles;
Expand All @@ -302,19 +293,15 @@ TEST_F(PerfProviderTest, MultipleCalls) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

sampled_profile.reset(new SampledProfile);
sampled_profile->set_trigger_event(SampledProfile::RESTORE_SESSION);
sampled_profile->set_ms_after_restore(3000);
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
SerializeMessageToVector(perf_stat_proto_));

sampled_profile.reset(new SampledProfile);
Expand All @@ -323,18 +310,14 @@ TEST_F(PerfProviderTest, MultipleCalls) {
sampled_profile->set_ms_after_resume(1500);
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

sampled_profile.reset(new SampledProfile);
sampled_profile->set_trigger_event(SampledProfile::PERIODIC_COLLECTION);
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
SerializeMessageToVector(perf_stat_proto_));

std::vector<SampledProfile> stored_profiles;
Expand Down Expand Up @@ -385,10 +368,8 @@ TEST_F(PerfProviderTest, IncognitoWindowOpened) {

perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

std::vector<SampledProfile> stored_profiles1;
EXPECT_TRUE(perf_provider_->GetSampledProfiles(&stored_profiles1));
Expand All @@ -407,9 +388,7 @@ TEST_F(PerfProviderTest, IncognitoWindowOpened) {
sampled_profile->set_ms_after_restore(3000);
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
SerializeMessageToVector(perf_stat_proto_));

std::vector<SampledProfile> stored_profiles2;
Expand All @@ -430,10 +409,8 @@ TEST_F(PerfProviderTest, IncognitoWindowOpened) {
// An incognito window opens.
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(true),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

std::vector<SampledProfile> stored_profiles_empty;
EXPECT_FALSE(perf_provider_->GetSampledProfiles(&stored_profiles_empty));
Expand All @@ -443,9 +420,7 @@ TEST_F(PerfProviderTest, IncognitoWindowOpened) {
// Incognito window is still open.
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(true),
sampled_profile.Pass(),
kPerfSuccess,
std::vector<uint8_t>(),
std::move(sampled_profile), kPerfSuccess, std::vector<uint8_t>(),
SerializeMessageToVector(perf_stat_proto_));

EXPECT_FALSE(perf_provider_->GetSampledProfiles(&stored_profiles_empty));
Expand All @@ -457,10 +432,8 @@ TEST_F(PerfProviderTest, IncognitoWindowOpened) {
// Incognito window closes.
perf_provider_->ParseOutputProtoIfValid(
TestIncognitoObserver::CreateWithIncognitoLaunched(false),
sampled_profile.Pass(),
kPerfSuccess,
SerializeMessageToVector(perf_data_proto_),
std::vector<uint8_t>());
std::move(sampled_profile), kPerfSuccess,
SerializeMessageToVector(perf_data_proto_), std::vector<uint8_t>());

std::vector<SampledProfile> stored_profiles3;
EXPECT_TRUE(perf_provider_->GetSampledProfiles(&stored_profiles3));
Expand Down
10 changes: 6 additions & 4 deletions chrome/browser/net/nss_context_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "chrome/browser/net/nss_context.h"

#include <utility>

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/supports_user_data.h"
Expand All @@ -28,7 +30,7 @@ class NSSCertDatabaseChromeOSManager : public base::SupportsUserData::Data {
base::Bind(&NSSCertDatabaseChromeOSManager::DidGetPrivateSlot,
weak_ptr_factory_.GetWeakPtr())));
if (private_slot)
DidGetPrivateSlot(private_slot.Pass());
DidGetPrivateSlot(std::move(private_slot));
}

~NSSCertDatabaseChromeOSManager() override {
Expand All @@ -53,7 +55,7 @@ class NSSCertDatabaseChromeOSManager : public base::SupportsUserData::Data {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
nss_cert_database_.reset(new net::NSSCertDatabaseChromeOS(
crypto::GetPublicSlotForChromeOSUser(username_hash_),
private_slot.Pass()));
std::move(private_slot)));

ReadyCallbackList callback_list;
callback_list.swap(ready_callback_list_);
Expand Down Expand Up @@ -99,7 +101,7 @@ void CallWithNSSCertDatabase(

void SetSystemSlot(crypto::ScopedPK11Slot system_slot,
net::NSSCertDatabaseChromeOS* db) {
db->SetSystemSlot(system_slot.Pass());
db->SetSystemSlot(std::move(system_slot));
}

void SetSystemSlotOfDBForResourceContext(content::ResourceContext* context,
Expand Down Expand Up @@ -142,5 +144,5 @@ void EnableNSSSystemKeySlotForResourceContext(
base::Bind(&SetSystemSlotOfDBForResourceContext, context);
crypto::ScopedPK11Slot system_slot = crypto::GetSystemNSSKeySlot(callback);
if (system_slot)
callback.Run(system_slot.Pass());
callback.Run(std::move(system_slot));
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <limits.h>
#include <stddef.h>
#include <utility>

#include "base/bind.h"
#include "base/macros.h"
Expand Down Expand Up @@ -802,12 +803,12 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
// http://crbug.com/346229
handlers->AddHandler(
make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
power_management_idle_legacy_policies.Pass(),
std::move(power_management_idle_legacy_policies),
make_scoped_ptr(
new PowerManagementIdleSettingsPolicyHandler(chrome_schema)))));
handlers->AddHandler(
make_scoped_ptr(new LegacyPoliciesDeprecatingPolicyHandler(
screen_lock_legacy_policies.Pass(),
std::move(screen_lock_legacy_policies),
make_scoped_ptr(new ScreenLockDelayPolicyHandler(chrome_schema)))));
handlers->AddHandler(
make_scoped_ptr(new ExternalDataPolicyHandler(key::kUserAvatarImage)));
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/policy/policy_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <string>
#include <utility>
#include <vector>

#include "ash/display/display_manager.h"
Expand Down Expand Up @@ -713,7 +713,7 @@ class PolicyTest : public InProcessBrowserTest {
// is tied to the test instead.
chrome_screenshot_grabber->screenshot_grabber()->AddObserver(&observer_);
ash::Shell::GetInstance()->accelerator_controller()->SetScreenshotDelegate(
chrome_screenshot_grabber.Pass());
std::move(chrome_screenshot_grabber));

SetScreenshotPolicy(enabled);
ash::Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled(
Expand Down
Loading

0 comments on commit cf738a9

Please sign in to comment.