Commit 0c8d4aa8 authored by danakj's avatar danakj Committed by Commit bot

base: Use std::move() instead of Pass() for real movable types.

Some of our movable types have real move-constructors/assignment
operators now. We can use std::move() for these types instead of Pass().

There's still some move-only types that are implemented using an
"Rvalue" type emulation, so we have to keep Pass() for those still.

R=thestig@chromium.org
BUG=557422

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

Cr-Commit-Position: refs/heads/master@{#361583}
parent 7296f934
......@@ -82,7 +82,7 @@ class ScopedPtrHashMap {
ScopedPtr ret(it->second);
it->second = NULL;
return ret.Pass();
return ret;
}
ScopedPtr take(const Key& k) {
......@@ -100,7 +100,7 @@ class ScopedPtrHashMap {
ScopedPtr ret(it->second);
data_.erase(it);
return ret.Pass();
return ret;
}
ScopedPtr take_and_erase(const Key& k) {
......
......@@ -116,7 +116,7 @@ class ScopedPtrMap {
ScopedPtr ret(position->second);
// Key-based lookup (cannot use const_iterator overload in C++03 library).
data_.erase(position->first);
return ret.Pass();
return ret;
}
// Like |erase()|, but returns the element instead of deleting it.
......@@ -127,7 +127,7 @@ class ScopedPtrMap {
ScopedPtr ret(it->second);
data_.erase(it);
return ret.Pass();
return ret;
}
private:
......
......@@ -167,12 +167,12 @@ TEST(ScopedPtrMapTest, Compare) {
// Test the move constructor.
ScopedPtrMap<int, scoped_ptr<int>, std::greater<int>> scoped_map2(
scoped_map1.Pass());
std::move(scoped_map1));
EXPECT_EQ(2u, scoped_map2.size());
EXPECT_TRUE(scoped_map1.empty());
// Test move assignment.
scoped_map1 = scoped_map2.Pass();
scoped_map1 = std::move(scoped_map2);
EXPECT_EQ(2u, scoped_map1.size());
EXPECT_TRUE(scoped_map2.empty());
......@@ -203,7 +203,7 @@ TEST(ScopedPtrMapTest, MoveConstruct) {
EXPECT_FALSE(scoped_map.empty());
ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> scoped_map_copy(
scoped_map.Pass());
std::move(scoped_map));
EXPECT_TRUE(scoped_map.empty());
EXPECT_FALSE(scoped_map_copy.empty());
EXPECT_EQ(elem, scoped_map_copy.find(0)->second);
......@@ -223,7 +223,7 @@ TEST(ScopedPtrMapTest, MoveAssign) {
EXPECT_FALSE(scoped_map.empty());
ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>> scoped_map_assign;
scoped_map_assign = scoped_map.Pass();
scoped_map_assign = std::move(scoped_map);
EXPECT_TRUE(scoped_map.empty());
EXPECT_FALSE(scoped_map_assign.empty());
EXPECT_EQ(elem, scoped_map_assign.find(0)->second);
......
......@@ -228,7 +228,7 @@ scoped_ptr<char*[]> AlterEnvironment(const char* const* const env,
result[i] = &storage_data[result_indices[i]];
result[result_indices.size()] = 0; // Null terminator.
return result.Pass();
return result;
}
#endif // OS_POSIX
......
......@@ -129,7 +129,7 @@ TEST_F(EnvironmentTest, AlterEnvironment) {
EnvironmentMap changes;
scoped_ptr<char*[]> e;
e = AlterEnvironment(empty, changes).Pass();
e = AlterEnvironment(empty, changes);
EXPECT_TRUE(e[0] == NULL);
changes["A"] = "1";
......
......@@ -4,6 +4,8 @@
#include "base/feature_list.h"
#include <utility>
#include "base/format_macros.h"
#include "base/metrics/field_trial.h"
#include "base/strings/stringprintf.h"
......@@ -35,7 +37,7 @@ class FeatureListTest : public testing::Test {
void RegisterFeatureListInstance(scoped_ptr<FeatureList> feature_list) {
FeatureList::ClearInstanceForTesting();
feature_list_ = feature_list.get();
FeatureList::SetInstance(feature_list.Pass());
FeatureList::SetInstance(std::move(feature_list));
}
void ClearFeatureListInstance() {
FeatureList::ClearInstanceForTesting();
......@@ -82,7 +84,7 @@ TEST_F(FeatureListTest, InitializeFromCommandLine) {
scoped_ptr<FeatureList> feature_list(new FeatureList);
feature_list->InitializeFromCommandLine(test_case.enable_features,
test_case.disable_features);
RegisterFeatureListInstance(feature_list.Pass());
RegisterFeatureListInstance(std::move(feature_list));
EXPECT_EQ(test_case.expected_feature_on_state,
FeatureList::IsEnabled(kFeatureOnByDefault))
......@@ -143,7 +145,7 @@ TEST_F(FeatureListTest, FieldTrialOverrides) {
test_case.trial1_state, trial1);
feature_list->RegisterFieldTrialOverride(kFeatureOffByDefaultName,
test_case.trial2_state, trial2);
RegisterFeatureListInstance(feature_list.Pass());
RegisterFeatureListInstance(std::move(feature_list));
// Initially, neither trial should be active.
EXPECT_FALSE(FieldTrialList::IsTrialActive(trial1->trial_name()));
......@@ -178,7 +180,7 @@ TEST_F(FeatureListTest, CommandLineTakesPrecedenceOverFieldTrial) {
FieldTrial* trial = FieldTrialList::CreateFieldTrial("TrialExample2", "A");
feature_list->RegisterFieldTrialOverride(
kFeatureOffByDefaultName, FeatureList::OVERRIDE_DISABLE_FEATURE, trial);
RegisterFeatureListInstance(feature_list.Pass());
RegisterFeatureListInstance(std::move(feature_list));
EXPECT_FALSE(FieldTrialList::IsTrialActive(trial->trial_name()));
// Command-line should take precedence.
......@@ -233,7 +235,7 @@ TEST_F(FeatureListTest, IsFeatureOverriddenFromCommandLine) {
kFeatureOnByDefaultName, FeatureList::OVERRIDE_DISABLE_FEATURE));
EXPECT_FALSE(feature_list->IsFeatureOverriddenFromCommandLine(
kFeatureOnByDefaultName, FeatureList::OVERRIDE_ENABLE_FEATURE));
RegisterFeatureListInstance(feature_list.Pass());
RegisterFeatureListInstance(std::move(feature_list));
// Check the expected feature states for good measure.
EXPECT_TRUE(FeatureList::IsEnabled(kFeatureOffByDefault));
......@@ -293,7 +295,7 @@ TEST_F(FeatureListTest, AssociateReportingFieldTrial) {
EXPECT_EQ(test_case.expected_enable_trial_created, enable_trial != nullptr);
EXPECT_EQ(test_case.expected_disable_trial_created,
disable_trial != nullptr);
RegisterFeatureListInstance(feature_list.Pass());
RegisterFeatureListInstance(std::move(feature_list));
EXPECT_FALSE(FieldTrialList::IsTrialActive(kTrialName));
if (disable_trial) {
......
......@@ -62,9 +62,8 @@ class BASE_EXPORT FilePathWatcher {
return task_runner_;
}
void set_task_runner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
task_runner_ = task_runner.Pass();
void set_task_runner(scoped_refptr<base::SingleThreadTaskRunner> runner) {
task_runner_ = std::move(runner);
}
// Must be called before the PlatformDelegate is deleted.
......
......@@ -5,8 +5,8 @@
#include "base/files/important_file_writer.h"
#include <stdio.h>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/critical_closure.h"
......@@ -191,7 +191,7 @@ void ImportantFileWriter::DoScheduledWrite() {
DCHECK(serializer_);
scoped_ptr<std::string> data(new std::string);
if (serializer_->SerializeData(data.get())) {
WriteNow(data.Pass());
WriteNow(std::move(data));
} else {
DLOG(WARNING) << "failed to serialize data to be saved in "
<< path_.value();
......
......@@ -18,7 +18,7 @@ scoped_ptr<uint8[]> CreateTestBuffer(size_t size, size_t offset) {
scoped_ptr<uint8[]> buf(new uint8[size]);
for (size_t i = 0; i < size; ++i)
buf.get()[i] = static_cast<uint8>((offset + i) % 253);
return buf.Pass();
return buf;
}
// Check that the watermark sequence is consistent with the |offset| provided.
......
......@@ -57,10 +57,10 @@ TEST(JSONWriterTest, NestedTypes) {
scoped_ptr<ListValue> list(new ListValue());
scoped_ptr<DictionaryValue> inner_dict(new DictionaryValue());
inner_dict->SetInteger("inner int", 10);
list->Append(inner_dict.Pass());
list->Append(std::move(inner_dict));
list->Append(make_scoped_ptr(new ListValue()));
list->AppendBoolean(true);
root_dict.Set("list", list.Pass());
root_dict.Set("list", std::move(list));
// Test the pretty-printer.
EXPECT_TRUE(JSONWriter::Write(root_dict, &output_js));
......@@ -92,7 +92,7 @@ TEST(JSONWriterTest, KeysWithPeriods) {
period_dict.SetIntegerWithoutPathExpansion("c", 2);
scoped_ptr<DictionaryValue> period_dict2(new DictionaryValue());
period_dict2->SetIntegerWithoutPathExpansion("g.h.i.j", 1);
period_dict.SetWithoutPathExpansion("d.e.f", period_dict2.Pass());
period_dict.SetWithoutPathExpansion("d.e.f", std::move(period_dict2));
EXPECT_TRUE(JSONWriter::Write(period_dict, &output_js));
EXPECT_EQ("{\"a.b\":3,\"c\":2,\"d.e.f\":{\"g.h.i.j\":1}}", output_js);
......
......@@ -331,13 +331,13 @@ class scoped_refptr {
}
scoped_refptr<T>& operator=(scoped_refptr<T>&& r) {
scoped_refptr<T>(r.Pass()).swap(*this);
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
template <typename U>
scoped_refptr<T>& operator=(scoped_refptr<U>&& r) {
scoped_refptr<T>(r.Pass()).swap(*this);
scoped_refptr<T>(std::move(r)).swap(*this);
return *this;
}
......
......@@ -180,26 +180,6 @@ TEST(RefCountedUnitTest, ConvertibleEquality) {
EXPECT_EQ(p2, p1);
}
TEST(RefCountedUnitTest, SelfMoveAssignment) {
ScopedRefPtrCountBase::reset_count();
{
ScopedRefPtrCountBase *raw = new ScopedRefPtrCountBase();
scoped_refptr<ScopedRefPtrCountBase> p(raw);
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
p = p.Pass();
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(raw, p.get());
// p goes out of scope.
}
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(1, ScopedRefPtrCountBase::destructor_count());
}
TEST(RefCountedUnitTest, MoveAssignment1) {
ScopedRefPtrCountBase::reset_count();
......@@ -212,7 +192,7 @@ TEST(RefCountedUnitTest, MoveAssignment1) {
{
scoped_refptr<ScopedRefPtrCountBase> p2;
p2 = p1.Pass();
p2 = std::move(p1);
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(nullptr, p1.get());
......@@ -243,7 +223,7 @@ TEST(RefCountedUnitTest, MoveAssignment2) {
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
p1 = p2.Pass();
p1 = std::move(p2);
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(raw, p1.get());
......@@ -274,7 +254,7 @@ TEST(RefCountedUnitTest, MoveAssignmentSameInstance1) {
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
p1 = p2.Pass();
p1 = std::move(p2);
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(raw, p1.get());
......@@ -305,7 +285,7 @@ TEST(RefCountedUnitTest, MoveAssignmentSameInstance2) {
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
p2 = p1.Pass();
p2 = std::move(p1);
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(nullptr, p1.get());
......@@ -337,7 +317,7 @@ TEST(RefCountedUnitTest, MoveAssignmentDifferentInstances) {
EXPECT_EQ(2, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
p1 = p2.Pass();
p1 = std::move(p2);
EXPECT_EQ(2, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(1, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(raw2, p1.get());
......@@ -374,7 +354,7 @@ TEST(RefCountedUnitTest, MoveAssignmentDerived) {
EXPECT_EQ(1, ScopedRefPtrCountDerived::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountDerived::destructor_count());
p1 = p2.Pass();
p1 = std::move(p2);
EXPECT_EQ(2, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(1, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(1, ScopedRefPtrCountDerived::constructor_count());
......@@ -407,7 +387,7 @@ TEST(RefCountedUnitTest, MoveConstructor) {
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
{
scoped_refptr<ScopedRefPtrCountBase> p2(p1.Pass());
scoped_refptr<ScopedRefPtrCountBase> p2(std::move(p1));
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(nullptr, p1.get());
......@@ -437,7 +417,7 @@ TEST(RefCountedUnitTest, MoveConstructorDerived) {
EXPECT_EQ(0, ScopedRefPtrCountDerived::destructor_count());
{
scoped_refptr<ScopedRefPtrCountBase> p2(p1.Pass());
scoped_refptr<ScopedRefPtrCountBase> p2(std::move(p1));
EXPECT_EQ(1, ScopedRefPtrCountBase::constructor_count());
EXPECT_EQ(0, ScopedRefPtrCountBase::destructor_count());
EXPECT_EQ(1, ScopedRefPtrCountDerived::constructor_count());
......
......@@ -37,42 +37,43 @@
// in that they are "movable but not copyable." You can use the scopers in
// the parameter and return types of functions to signify ownership transfer
// in to and out of a function. When calling a function that has a scoper
// as the argument type, it must be called with the result of an analogous
// scoper's Pass() function or another function that generates a temporary;
// passing by copy will NOT work. Here is an example using scoped_ptr:
// as the argument type, it must be called with an rvalue of a scoper, which
// can be created by using std::move(), or the result of another function that
// generates a temporary; passing by copy will NOT work. Here is an example
// using scoped_ptr:
//
// void TakesOwnership(scoped_ptr<Foo> arg) {
// // Do something with arg
// // Do something with arg.
// }
// scoped_ptr<Foo> CreateFoo() {
// // No need for calling Pass() because we are constructing a temporary
// // for the return value.
// // No need for calling std::move() for returning a move-only value, or
// // when you already have an rvalue as we do here.
// return scoped_ptr<Foo>(new Foo("new"));
// }
// scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
// return arg.Pass();
// return arg;
// }
//
// {
// scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay").
// TakesOwnership(std::move(ptr)); // ptr no longer owns Foo("yay").
// scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
// scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
// PassThru(ptr2.Pass()); // ptr2 is correspondingly nullptr.
// PassThru(std::move(ptr2)); // ptr2 is correspondingly nullptr.
// }
//
// Notice that if you do not call Pass() when returning from PassThru(), or
// Notice that if you do not call std::move() when returning from PassThru(), or
// when invoking TakesOwnership(), the code will not compile because scopers
// are not copyable; they only implement move semantics which require calling
// the Pass() function to signify a destructive transfer of state. CreateFoo()
// is different though because we are constructing a temporary on the return
// line and thus can avoid needing to call Pass().
// the std::move() function to signify a destructive transfer of state.
// CreateFoo() is different though because we are constructing a temporary on
// the return line and thus can avoid needing to call std::move().
//
// Pass() properly handles upcast in initialization, i.e. you can use a
// scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
// The conversion move-constructor properly handles upcast in initialization,
// i.e. you can use a scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
//
// scoped_ptr<Foo> foo(new Foo());
// scoped_ptr<FooParent> parent(foo.Pass());
// scoped_ptr<FooParent> parent(std::move(foo));
#ifndef BASE_MEMORY_SCOPED_PTR_H_
#define BASE_MEMORY_SCOPED_PTR_H_
......
......@@ -84,7 +84,7 @@ int OverloadedNewAndDelete::g_new_count = 0;
int OverloadedNewAndDelete::g_delete_count = 0;
scoped_ptr<ConDecLogger> PassThru(scoped_ptr<ConDecLogger> logger) {
return logger.Pass();
return logger;
}
void GrabAndDrop(scoped_ptr<ConDecLogger> logger) {
......@@ -178,7 +178,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper.get());
scoped_ptr<ConDecLoggerParent> scoper_parent(scoper.Pass());
scoped_ptr<ConDecLoggerParent> scoper_parent(std::move(scoper));
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper_parent.get());
EXPECT_FALSE(scoper.get());
......@@ -196,7 +196,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_TRUE(scoper.get());
scoped_ptr<ConDecLoggerParent> scoper_parent;
scoper_parent = scoper.Pass();
scoper_parent = std::move(scoper);
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper_parent.get());
EXPECT_FALSE(scoper.get());
......@@ -209,7 +209,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper.get());
scoped_ptr<const ConDecLogger> scoper_const(scoper.Pass());
scoped_ptr<const ConDecLogger> scoper_const(std::move(scoper));
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper_const.get());
EXPECT_FALSE(scoper.get());
......@@ -227,7 +227,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_TRUE(scoper.get());
scoped_ptr<const ConDecLogger> scoper_const;
scoper_const = scoper.Pass();
scoper_const = std::move(scoper);
EXPECT_EQ(1, constructed);
EXPECT_TRUE(scoper_const.get());
EXPECT_FALSE(scoper.get());
......@@ -251,7 +251,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_EQ(0, alternate_deletes);
// Test this compiles and correctly overwrites the deleter state.
scoper = scoper_child.Pass();
scoper = std::move(scoper_child);
EXPECT_TRUE(scoper);
EXPECT_FALSE(scoper_child);
EXPECT_EQ(1, deletes);
......@@ -267,7 +267,8 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
EXPECT_TRUE(scoper_child);
EXPECT_EQ(1, deletes);
EXPECT_EQ(1, alternate_deletes);
scoped_ptr<double, CountingDeleter> scoper_construct(scoper_child.Pass());
scoped_ptr<double, CountingDeleter> scoper_construct(
std::move(scoper_child));
EXPECT_TRUE(scoper_construct);
EXPECT_FALSE(scoper_child);
EXPECT_EQ(1, deletes);
......@@ -363,13 +364,13 @@ TEST(ScopedPtrTest, ScopedPtrWithArray) {
}
EXPECT_EQ(kNumLoggers, constructed);
// Test Pass() with constructor;
scoped_ptr<ConDecLogger[]> scoper2(scoper.Pass());
// Test moving with constructor;
scoped_ptr<ConDecLogger[]> scoper2(std::move(scoper));
EXPECT_EQ(kNumLoggers, constructed);
// Test Pass() with assignment;
// Test moving with assignment;
scoped_ptr<ConDecLogger[]> scoper3;
scoper3 = scoper2.Pass();
scoper3 = std::move(scoper2);
EXPECT_EQ(kNumLoggers, constructed);
EXPECT_FALSE(scoper);
EXPECT_FALSE(scoper2);
......@@ -378,27 +379,29 @@ TEST(ScopedPtrTest, ScopedPtrWithArray) {
EXPECT_EQ(0, constructed);
}
TEST(ScopedPtrTest, PassBehavior) {
TEST(ScopedPtrTest, MoveBehavior) {
int constructed = 0;
{
ConDecLogger* logger = new ConDecLogger(&constructed);
scoped_ptr<ConDecLogger> scoper(logger);
EXPECT_EQ(1, constructed);
// Test Pass() with constructor;
scoped_ptr<ConDecLogger> scoper2(scoper.Pass());
// Test moving with constructor;
scoped_ptr<ConDecLogger> scoper2(std::move(scoper));
EXPECT_EQ(1, constructed);
// Test Pass() with assignment;
// Test moving with assignment;
scoped_ptr<ConDecLogger> scoper3;
scoper3 = scoper2.Pass();
scoper3 = std::move(scoper2);
EXPECT_EQ(1, constructed);
EXPECT_FALSE(scoper.get());
EXPECT_FALSE(scoper2.get());
EXPECT_TRUE(scoper3.get());
}
// Test uncaught Pass() does not have side effects.
// Test uncaught Pass() does not have side effects, because Pass()
// is implemented by std::move().
// TODO(danakj): Remove this test case when we remove Pass().
{
ConDecLogger* logger = new ConDecLogger(&constructed);
scoped_ptr<ConDecLogger> scoper(logger);
......@@ -419,7 +422,7 @@ TEST(ScopedPtrTest, PassBehavior) {
EXPECT_EQ(1, constructed);
// Should auto-destruct logger by end of scope.
GrabAndDrop(scoper.Pass());
GrabAndDrop(std::move(scoper));
EXPECT_FALSE(scoper.get());
}
EXPECT_EQ(0, constructed);
......@@ -434,7 +437,7 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) {
scoped_ptr<ConDecLogger> scoper(logger);
EXPECT_EQ(1, constructed);
PassThru(scoper.Pass());
PassThru(std::move(scoper));
EXPECT_FALSE(scoper.get());
}
EXPECT_EQ(0, constructed);
......@@ -446,7 +449,7 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) {
EXPECT_EQ(1, constructed);
// Should auto-destruct logger by end of scope.
PassThru(scoper.Pass());
PassThru(std::move(scoper));
EXPECT_FALSE(scoper.get());
}
EXPECT_EQ(0, constructed);
......@@ -537,8 +540,8 @@ TEST(ScopedPtrTest, CustomDeleter) {
// Pass the second deleter through a constructor and an operator=. Then
// reinitialize the empty scopers to ensure that each one is deleting
// properly.
scoped_ptr<double, CountingDeleter> scoper3(scoper2.Pass());
scoper = scoper3.Pass();
scoped_ptr<double, CountingDeleter> scoper3(std::move(scoper2));
scoper = std::move(scoper3);
EXPECT_EQ(1, deletes);
scoper2.reset(&dummy_value2);
......@@ -575,7 +578,7 @@ TEST(ScopedPtrTest, CustomDeleter) {
}
// Sanity check test for overloaded new and delete operators. Does not do full
// coverage of reset/release/Pass() operations as that is redundant with the
// coverage of reset/release/move operations as that is redundant with the
// above.
TEST(ScopedPtrTest, OverloadedNewAndDelete) {
{
......@@ -583,7 +586,7 @@ TEST(ScopedPtrTest, OverloadedNewAndDelete) {
scoped_ptr<OverloadedNewAndDelete> scoper(new OverloadedNewAndDelete());
EXPECT_TRUE(scoper.get());
scoped_ptr<OverloadedNewAndDelete> scoper2(scoper.Pass());
scoped_ptr<OverloadedNewAndDelete> scoper2(std::move(scoper));
}
EXPECT_EQ(1, OverloadedNewAndDelete::delete_count());
EXPECT_EQ(1, OverloadedNewAndDelete::new_count());
......@@ -632,9 +635,9 @@ TEST(ScopedPtrTest, Conversion) {
scoped_ptr<Sub> sub1(new Sub);
scoped_ptr<Sub> sub2(new Sub);
// Upcast with Pass() works.
scoped_ptr<Super> super1 = sub1.Pass();
super1 = sub2.Pass();
// Upcast with move works.
scoped_ptr<Super> super1 = std::move(sub1);
super1 = std::move(sub2);
// Upcast with an rvalue works.
scoped_ptr<Super> super2 = SubClassReturn();
......
......@@ -331,7 +331,7 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
}
requested_size_ = options.size;
return PrepareMapFile(fp.Pass(), readonly_fd.Pass());
return PrepareMapFile(std::move(fp), std::move(readonly_fd));
}
bool SharedMemory::MapAt(off_t offset, size_t bytes) {
......
......@@ -231,8 +231,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachBasedSharedMemory) {
SetUpChild("MachBasedSharedMemoryClient");
scoped_ptr<SharedMemory> shared_memory(
CreateSharedMemory(s_memory_size).Pass());
scoped_ptr<SharedMemory> shared_memory(CreateSharedMemory(s_memory_size));
// Send the underlying memory object to the client process.
SendMachPort(client_port_.get(), shared_memory->handle().GetMemoryObject(),
......@@ -383,8 +382,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachReadOnly) {
if (mac::IsOSSnowLeopard())
return;
scoped_ptr<SharedMemory> shared_memory(
CreateSharedMemory(s_memory_size).Pass());
scoped_ptr<SharedMemory> shared_memory(CreateSharedMemory(s_memory_size));
SharedMemoryHandle shm2 = shared_memory->handle().Duplicate();
ASSERT_TRUE(shm2.IsValid());
......@@ -402,8 +400,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachShareToProcess) {
mach_msg_type_number_t active_name_count = GetActiveNameCount();
{
scoped_ptr<SharedMemory> shared_memory(
CreateSharedMemory(s_memory_size).Pass());
scoped_ptr<SharedMemory> shared_memory(CreateSharedMemory(s_memory_size));
SharedMemoryHandle shm2;
ASSERT_TRUE(shared_memory->ShareToProcess(GetCurrentProcId(), &shm2));
......@@ -425,8 +422,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachShareToProcessReadonly) {
if (mac::IsOSSnowLeopard())
return;
scoped_ptr<SharedMemory> shared_memory(
CreateSharedMemory(s_memory_size).Pass());
scoped_ptr<SharedMemory> shared_memory(CreateSharedMemory(s_memory_size));
// Check the protection levels.
int current_prot, max_prot;
......@@ -472,8 +468,7 @@ TEST_F(SharedMemoryMacMultiProcessTest, MachShareToProcessReadonlyLeak) {
mach_msg_type_number_t active_name_count = GetActiveNameCount();
{
scoped_ptr<SharedMemory> shared_memory(
CreateSharedMemory(s_memory_size).Pass());
scoped_ptr<SharedMemory> shared_memory(CreateSharedMemory(s_memory_size));
SharedMemoryHandle shm2;
ASSERT_TRUE(
......
......@@ -311,7 +311,7 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
return false;
}
return PrepareMapFile(fp.Pass(), readonly_fd.Pass());
return PrepareMapFile(std::move(fp), std::move(readonly_fd));
}
// Our current implementation of shmem is with mmap()ing of files.
......@@ -343,7 +343,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) {
DPLOG(ERROR) << "open(\"" << path.value() << "\", O_RDONLY) failed";
return false;
}
return PrepareMapFile(fp.Pass(), readonly_fd.Pass());
return PrepareMapFile(std::move(fp), std::move(readonly_fd));
}
#endif // !defined(OS_ANDROID)
......
......@@ -5,6 +5,7 @@
#include "base/message_loop/message_loop.h"
#include <algorithm>
#include <utility>
#include "base/bind.h"
#include "base/compiler_specific.h"
......@@ -417,7 +418,7 @@ void MessageLoop::SetTaskRunner(
DCHECK_EQ(this, current());
DCHECK(task_runner->BelongsToCurrentThread());
DCHECK(!unbound_task_runner_);
task_runner_ = task_runner.Pass();
task_runner_ = std::move(task_runner);
SetThreadTaskRunnerHandle();
}