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}
CrOS-Libchrome-Original-Commit: 0c8d4aa8ba54f463cc22ce21bf1088edd3d1e207
diff --git a/base/containers/scoped_ptr_hash_map.h b/base/containers/scoped_ptr_hash_map.h
index 116070a..bc635f4 100644
--- a/base/containers/scoped_ptr_hash_map.h
+++ b/base/containers/scoped_ptr_hash_map.h
@@ -82,7 +82,7 @@
ScopedPtr ret(it->second);
it->second = NULL;
- return ret.Pass();
+ return ret;
}
ScopedPtr take(const Key& k) {
@@ -100,7 +100,7 @@
ScopedPtr ret(it->second);
data_.erase(it);
- return ret.Pass();
+ return ret;
}
ScopedPtr take_and_erase(const Key& k) {
diff --git a/base/containers/scoped_ptr_map.h b/base/containers/scoped_ptr_map.h
index dfa26f4..822cbfd 100644
--- a/base/containers/scoped_ptr_map.h
+++ b/base/containers/scoped_ptr_map.h
@@ -116,7 +116,7 @@
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 @@
ScopedPtr ret(it->second);
data_.erase(it);
- return ret.Pass();
+ return ret;
}
private:
diff --git a/base/containers/scoped_ptr_map_unittest.cc b/base/containers/scoped_ptr_map_unittest.cc
index 086c4fe..6f867a9 100644
--- a/base/containers/scoped_ptr_map_unittest.cc
+++ b/base/containers/scoped_ptr_map_unittest.cc
@@ -167,12 +167,12 @@
// 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 @@
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 @@
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);
diff --git a/base/environment.cc b/base/environment.cc
index 11b2bc3..ca24ac7 100644
--- a/base/environment.cc
+++ b/base/environment.cc
@@ -228,7 +228,7 @@
result[i] = &storage_data[result_indices[i]];
result[result_indices.size()] = 0; // Null terminator.
- return result.Pass();
+ return result;
}
#endif // OS_POSIX
diff --git a/base/environment_unittest.cc b/base/environment_unittest.cc
index f0577a8..c955e79 100644
--- a/base/environment_unittest.cc
+++ b/base/environment_unittest.cc
@@ -129,7 +129,7 @@
EnvironmentMap changes;
scoped_ptr<char*[]> e;
- e = AlterEnvironment(empty, changes).Pass();
+ e = AlterEnvironment(empty, changes);
EXPECT_TRUE(e[0] == NULL);
changes["A"] = "1";
diff --git a/base/feature_list_unittest.cc b/base/feature_list_unittest.cc
index cb8f744..53536d2 100644
--- a/base/feature_list_unittest.cc
+++ b/base/feature_list_unittest.cc
@@ -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 @@
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 @@
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_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 @@
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 @@
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 @@
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) {
diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h
index 4f132af..834acbc 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -62,9 +62,8 @@
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.
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc
index 1529107..4af7137 100644
--- a/base/files/important_file_writer.cc
+++ b/base/files/important_file_writer.cc
@@ -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 @@
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();
diff --git a/base/files/memory_mapped_file_unittest.cc b/base/files/memory_mapped_file_unittest.cc
index 05b941c..1812d88 100644
--- a/base/files/memory_mapped_file_unittest.cc
+++ b/base/files/memory_mapped_file_unittest.cc
@@ -18,7 +18,7 @@
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.
diff --git a/base/json/json_writer_unittest.cc b/base/json/json_writer_unittest.cc
index 0daeafc..a6f1a18 100644
--- a/base/json/json_writer_unittest.cc
+++ b/base/json/json_writer_unittest.cc
@@ -57,10 +57,10 @@
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 @@
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);
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
index 5f94b4c..26c6551 100644
--- a/base/memory/ref_counted.h
+++ b/base/memory/ref_counted.h
@@ -331,13 +331,13 @@
}
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;
}
diff --git a/base/memory/ref_counted_unittest.cc b/base/memory/ref_counted_unittest.cc
index 6f8e599..dbc6f33 100644
--- a/base/memory/ref_counted_unittest.cc
+++ b/base/memory/ref_counted_unittest.cc
@@ -180,26 +180,6 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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());
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index 51750d3..0120f89 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -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_
diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
index 60a050e..b26182a 100644
--- a/base/memory/scoped_ptr_unittest.cc
+++ b/base/memory/scoped_ptr_unittest.cc
@@ -84,7 +84,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
}
// 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 @@
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 @@
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();
diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc
index e1e5bf2..28c103f 100644
--- a/base/memory/shared_memory_posix.cc
+++ b/base/memory/shared_memory_posix.cc
@@ -311,7 +311,7 @@
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 @@
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)
diff --git a/base/message_loop/message_loop.cc b/base/message_loop/message_loop.cc
index a44f468..a0c5f61 100644
--- a/base/message_loop/message_loop.cc
+++ b/base/message_loop/message_loop.cc
@@ -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 @@
DCHECK_EQ(this, current());
DCHECK(task_runner->BelongsToCurrentThread());
DCHECK(!unbound_task_runner_);
- task_runner_ = task_runner.Pass();
+ task_runner_ = std::move(task_runner);
SetThreadTaskRunnerHandle();
}
diff --git a/base/message_loop/message_loop_test.cc b/base/message_loop/message_loop_test.cc
index a544a70..f821220 100644
--- a/base/message_loop/message_loop_test.cc
+++ b/base/message_loop/message_loop_test.cc
@@ -4,6 +4,8 @@
#include "base/message_loop/message_loop_test.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
@@ -87,7 +89,7 @@
void RunTest_PostTask(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Add tests to message loop
scoped_refptr<Foo> foo(new Foo());
std::string a("a"), b("b"), c("c"), d("d");
@@ -117,7 +119,7 @@
void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that PostDelayedTask results in a delayed task.
@@ -140,7 +142,7 @@
void RunTest_PostDelayedTask_InDelayOrder(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that two tasks with different delays run in the right order.
int num_tasks = 2;
@@ -165,7 +167,7 @@
void RunTest_PostDelayedTask_InPostOrder(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that two tasks with the same delay run in the order in which they
// were posted.
@@ -195,7 +197,7 @@
void RunTest_PostDelayedTask_InPostOrder_2(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that a delayed task still runs after a normal tasks even if the
// normal tasks take a long time to run.
@@ -222,7 +224,7 @@
void RunTest_PostDelayedTask_InPostOrder_3(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that a delayed task still runs after a pile of normal tasks. The key
// difference between this test and the previous one is that here we return
@@ -250,7 +252,7 @@
void RunTest_PostDelayedTask_SharedTimer(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// Test that the interval of the timer, used to run the next delayed task, is
// set to a value corresponding to when the next delayed task should run.
@@ -317,7 +319,7 @@
bool b_was_deleted = false;
{
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
loop.PostTask(
FROM_HERE, Bind(&RecordDeletionProbe::Run,
new RecordDeletionProbe(NULL, &a_was_deleted)));
@@ -337,7 +339,7 @@
bool c_was_deleted = false;
{
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
// The scoped_refptr for each of the below is held either by the chained
// RecordDeletionProbe, or the bound RecordDeletionProbe::Run() callback.
RecordDeletionProbe* a = new RecordDeletionProbe(NULL, &a_was_deleted);
@@ -364,7 +366,7 @@
void RunTest_Nesting(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
int depth = 100;
MessageLoop::current()->PostTask(FROM_HERE,
@@ -472,7 +474,7 @@
}
void RunTest_RecursiveDenial1(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
TaskList order;
@@ -519,7 +521,7 @@
void RunTest_RecursiveDenial3(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
TaskList order;
@@ -560,7 +562,7 @@
void RunTest_RecursiveSupport1(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
MessageLoop::current()->PostTask(
@@ -593,7 +595,7 @@
// Tests that non nestable tasks run in FIFO if there are no nested loops.
void RunTest_NonNestableWithNoNesting(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -635,7 +637,7 @@
void RunTest_NonNestableInNestedLoop(MessagePumpFactory factory,
bool use_delayed) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -703,7 +705,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_QuitNow(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -738,7 +740,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitTop(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -768,7 +770,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitNested(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -798,7 +800,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitBogus(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -831,7 +833,7 @@
// Tests RunLoopQuit only quits the corresponding MessageLoop::Run.
void RunTest_RunLoopQuitDeep(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -900,7 +902,7 @@
// Tests RunLoopQuit works before RunWithID.
void RunTest_RunLoopQuitOrderBefore(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -921,7 +923,7 @@
// Tests RunLoopQuit works during RunWithID.
void RunTest_RunLoopQuitOrderDuring(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -948,7 +950,7 @@
// Tests RunLoopQuit works after RunWithID.
void RunTest_RunLoopQuitOrderAfter(MessagePumpFactory factory) {
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
TaskList order;
@@ -1006,7 +1008,7 @@
void RunTest_RecursivePosts(MessagePumpFactory factory) {
const int kNumTimes = 1 << 17;
scoped_ptr<MessagePump> pump(factory());
- MessageLoop loop(pump.Pass());
+ MessageLoop loop(std::move(pump));
loop.PostTask(FROM_HERE, Bind(&PostNTasksThenQuit, kNumTimes));
loop.Run();
}
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index b37bc4c..1bbcab7 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -293,7 +293,7 @@
}
scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
- return SnapshotSampleVector().Pass();
+ return SnapshotSampleVector();
}
void Histogram::AddSamples(const HistogramSamples& samples) {
@@ -394,7 +394,7 @@
scoped_ptr<SampleVector> Histogram::SnapshotSampleVector() const {
scoped_ptr<SampleVector> samples(new SampleVector(bucket_ranges()));
samples->Add(*samples_);
- return samples.Pass();
+ return samples;
}
void Histogram::WriteAsciiImpl(bool graph_it,
diff --git a/base/metrics/histogram_base.cc b/base/metrics/histogram_base.cc
index 92da79f..e9d4898 100644
--- a/base/metrics/histogram_base.cc
+++ b/base/metrics/histogram_base.cc
@@ -5,6 +5,7 @@
#include "base/metrics/histogram_base.h"
#include <climits>
+#include <utility>
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
@@ -114,8 +115,8 @@
root.SetInteger("count", count);
root.SetDouble("sum", static_cast<double>(sum));
root.SetInteger("flags", flags());
- root.Set("params", parameters.Pass());
- root.Set("buckets", buckets.Pass());
+ root.Set("params", std::move(parameters));
+ root.Set("buckets", std::move(buckets));
root.SetInteger("pid", GetCurrentProcId());
serializer.Serialize(root);
}
diff --git a/base/metrics/sparse_histogram.cc b/base/metrics/sparse_histogram.cc
index 39c276d..7955c57 100644
--- a/base/metrics/sparse_histogram.cc
+++ b/base/metrics/sparse_histogram.cc
@@ -4,6 +4,8 @@
#include "base/metrics/sparse_histogram.h"
+#include <utility>
+
#include "base/metrics/sample_map.h"
#include "base/metrics/statistics_recorder.h"
#include "base/pickle.h"
@@ -67,7 +69,7 @@
base::AutoLock auto_lock(lock_);
snapshot->Add(samples_);
- return snapshot.Pass();
+ return std::move(snapshot);
}
void SparseHistogram::AddSamples(const HistogramSamples& samples) {
diff --git a/base/move_unittest.cc b/base/move_unittest.cc
index 1f4ce84..da0be63 100644
--- a/base/move_unittest.cc
+++ b/base/move_unittest.cc
@@ -24,7 +24,7 @@
Container(const Container& other) = default;
Container& operator=(const Container& other) = default;
- Container(Container&& other) { value_ = other.value_.Pass(); }
+ Container(Container&& other) { value_ = std::move(other.value_); }
Container& operator=(Container&& other) {
value_ = other.value_.Pass();
diff --git a/base/power_monitor/power_monitor.cc b/base/power_monitor/power_monitor.cc
index 98c9c68..1033299 100644
--- a/base/power_monitor/power_monitor.cc
+++ b/base/power_monitor/power_monitor.cc
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "base/power_monitor/power_monitor.h"
+
+#include <utility>
+
#include "base/power_monitor/power_monitor_source.h"
namespace base {
@@ -11,7 +14,7 @@
PowerMonitor::PowerMonitor(scoped_ptr<PowerMonitorSource> source)
: observers_(new ObserverListThreadSafe<PowerObserver>()),
- source_(source.Pass()) {
+ source_(std::move(source)) {
DCHECK(!g_power_monitor);
g_power_monitor = this;
}
diff --git a/base/prefs/default_pref_store.cc b/base/prefs/default_pref_store.cc
index efb4a75..b08ef7a 100644
--- a/base/prefs/default_pref_store.cc
+++ b/base/prefs/default_pref_store.cc
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "base/prefs/default_pref_store.h"
+
+#include <utility>
+
#include "base/logging.h"
using base::Value;
@@ -29,7 +32,7 @@
void DefaultPrefStore::SetDefaultValue(const std::string& key,
scoped_ptr<Value> value) {
DCHECK(!GetValue(key, NULL));
- prefs_.SetValue(key, value.Pass());
+ prefs_.SetValue(key, std::move(value));
}
void DefaultPrefStore::ReplaceDefaultValue(const std::string& key,
@@ -37,7 +40,7 @@
const Value* old_value = NULL;
GetValue(key, &old_value);
bool notify = !old_value->Equals(value.get());
- prefs_.SetValue(key, value.Pass());
+ prefs_.SetValue(key, std::move(value));
if (notify)
FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
}
diff --git a/base/prefs/json_pref_store.cc b/base/prefs/json_pref_store.cc
index 22036de..637ec70 100644
--- a/base/prefs/json_pref_store.cc
+++ b/base/prefs/json_pref_store.cc
@@ -5,6 +5,7 @@
#include "base/prefs/json_pref_store.h"
#include <algorithm>
+#include <utility>
#include "base/bind.h"
#include "base/callback.h"
@@ -126,7 +127,7 @@
if (read_result->error == PersistentPrefStore::PREF_READ_ERROR_NONE)
RecordJsonDataSizeHistogram(path, deserializer.get_last_read_size());
- return read_result.Pass();
+ return read_result;
}
} // namespace
@@ -149,8 +150,7 @@
: JsonPrefStore(pref_filename,
base::FilePath(),
sequenced_task_runner,
- pref_filter.Pass()) {
-}
+ std::move(pref_filter)) {}
JsonPrefStore::JsonPrefStore(
const base::FilePath& pref_filename,
@@ -163,7 +163,7 @@
prefs_(new base::DictionaryValue()),
read_only_(false),
writer_(pref_filename, sequenced_task_runner),
- pref_filter_(pref_filter.Pass()),
+ pref_filter_(std::move(pref_filter)),
initialized_(false),
filtering_in_progress_(false),
pending_lossy_write_(false),
@@ -225,7 +225,7 @@
base::Value* old_value = nullptr;
prefs_->Get(key, &old_value);
if (!old_value || !value->Equals(old_value)) {
- prefs_->Set(key, value.Pass());
+ prefs_->Set(key, std::move(value));
ReportValueChanged(key, flags);
}
}
@@ -239,7 +239,7 @@
base::Value* old_value = nullptr;
prefs_->Get(key, &old_value);
if (!old_value || !value->Equals(old_value)) {
- prefs_->Set(key, value.Pass());
+ prefs_->Set(key, std::move(value));
ScheduleWrite(flags);
}
}
@@ -377,9 +377,10 @@
&JsonPrefStore::FinalizeFileRead, AsWeakPtr(),
initialization_successful));
pref_filter_->FilterOnLoad(post_filter_on_load_callback,
- unfiltered_prefs.Pass());
+ std::move(unfiltered_prefs));
} else {
- FinalizeFileRead(initialization_successful, unfiltered_prefs.Pass(), false);
+ FinalizeFileRead(initialization_successful, std::move(unfiltered_prefs),
+ false);
}
}
@@ -419,7 +420,7 @@
return;
}
- prefs_ = prefs.Pass();
+ prefs_ = std::move(prefs);
initialized_ = true;
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index 5195a18..d850292 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -4,6 +4,8 @@
#include "base/prefs/json_pref_store.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@@ -73,12 +75,12 @@
const PostFilterOnLoadCallback& post_filter_on_load_callback,
scoped_ptr<base::DictionaryValue> pref_store_contents) {
post_filter_on_load_callback_ = post_filter_on_load_callback;
- intercepted_prefs_ = pref_store_contents.Pass();
+ intercepted_prefs_ = std::move(pref_store_contents);
}
void InterceptingPrefFilter::ReleasePrefs() {
EXPECT_FALSE(post_filter_on_load_callback_.is_null());
- post_filter_on_load_callback_.Run(intercepted_prefs_.Pass(), false);
+ post_filter_on_load_callback_.Run(std::move(intercepted_prefs_), false);
post_filter_on_load_callback_.Reset();
}
@@ -348,7 +350,7 @@
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
dict->SetString("key", "value");
- pref_store->SetValue("dict", dict.Pass(),
+ pref_store->SetValue("dict", std::move(dict),
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
pref_store->RemoveValue("dict.key",
@@ -392,8 +394,9 @@
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, message_loop_.task_runner(),
+ std::move(intercepting_pref_filter));
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE,
pref_store->ReadPrefs());
@@ -437,8 +440,9 @@
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, message_loop_.task_runner(),
+ std::move(intercepting_pref_filter));
MockPrefStoreObserver mock_observer;
pref_store->AddObserver(&mock_observer);
diff --git a/base/prefs/overlay_user_pref_store.cc b/base/prefs/overlay_user_pref_store.cc
index d76b537..f386cef 100644
--- a/base/prefs/overlay_user_pref_store.cc
+++ b/base/prefs/overlay_user_pref_store.cc
@@ -4,6 +4,8 @@
#include "base/prefs/overlay_user_pref_store.h"
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
@@ -66,11 +68,11 @@
scoped_ptr<base::Value> value,
uint32 flags) {
if (!ShallBeStoredInOverlay(key)) {
- underlay_->SetValue(GetUnderlayKey(key), value.Pass(), flags);
+ underlay_->SetValue(GetUnderlayKey(key), std::move(value), flags);
return;
}
- if (overlay_.SetValue(key, value.Pass()))
+ if (overlay_.SetValue(key, std::move(value)))
ReportValueChanged(key, flags);
}
@@ -78,11 +80,11 @@
scoped_ptr<base::Value> value,
uint32 flags) {
if (!ShallBeStoredInOverlay(key)) {
- underlay_->SetValueSilently(GetUnderlayKey(key), value.Pass(), flags);
+ underlay_->SetValueSilently(GetUnderlayKey(key), std::move(value), flags);
return;
}
- overlay_.SetValue(key, value.Pass());
+ overlay_.SetValue(key, std::move(value));
}
void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32 flags) {
diff --git a/base/prefs/pref_member.cc b/base/prefs/pref_member.cc
index 64c3d6a..934237d 100644
--- a/base/prefs/pref_member.cc
+++ b/base/prefs/pref_member.cc
@@ -4,6 +4,8 @@
#include "base/prefs/pref_member.h"
+#include <utility>
+
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/location.h"
@@ -56,7 +58,7 @@
// Load the value from preferences if it hasn't been loaded so far.
if (!internal())
UpdateValueFromPref(base::Closure());
- internal()->MoveToThread(task_runner.Pass());
+ internal()->MoveToThread(std::move(task_runner));
}
void PrefMemberBase::OnPreferenceChanged(PrefService* service,
@@ -124,7 +126,7 @@
void PrefMemberBase::Internal::MoveToThread(
scoped_refptr<SingleThreadTaskRunner> task_runner) {
CheckOnCorrectThread();
- thread_task_runner_ = task_runner.Pass();
+ thread_task_runner_ = std::move(task_runner);
}
bool PrefMemberVectorStringUpdate(const base::Value& value,
diff --git a/base/prefs/pref_service.cc b/base/prefs/pref_service.cc
index c53b896..7741306 100644
--- a/base/prefs/pref_service.cc
+++ b/base/prefs/pref_service.cc
@@ -5,6 +5,7 @@
#include "base/prefs/pref_service.h"
#include <algorithm>
+#include <utility>
#include "base/bind.h"
#include "base/files/file_path.h"
@@ -197,7 +198,7 @@
for (const auto& it : *pref_registry_) {
out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
}
- return out.Pass();
+ return out;
}
scoped_ptr<base::DictionaryValue> PrefService::GetPreferenceValuesOmitDefaults()
@@ -210,7 +211,7 @@
continue;
out->Set(it.first, pref->GetValue()->CreateDeepCopy());
}
- return out.Pass();
+ return out;
}
scoped_ptr<base::DictionaryValue>
@@ -222,7 +223,7 @@
DCHECK(value);
out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy());
}
- return out.Pass();
+ return out;
}
const PrefService::Preference* PrefService::FindPreference(
@@ -499,7 +500,7 @@
return;
}
- user_pref_store_->SetValue(path, owned_value.Pass(), GetWriteFlags(pref));
+ user_pref_store_->SetValue(path, std::move(owned_value), GetWriteFlags(pref));
}
void PrefService::UpdateCommandLinePrefStore(PrefStore* command_line_store) {
diff --git a/base/prefs/pref_service_factory.cc b/base/prefs/pref_service_factory.cc
index 8caf073..2380a86 100644
--- a/base/prefs/pref_service_factory.cc
+++ b/base/prefs/pref_service_factory.cc
@@ -59,7 +59,7 @@
pref_registry,
read_error_callback_,
async_));
- return pref_service.Pass();
+ return pref_service;
}
} // namespace base
diff --git a/base/prefs/pref_value_map.cc b/base/prefs/pref_value_map.cc
index 93eadb7..2340e3c 100644
--- a/base/prefs/pref_value_map.cc
+++ b/base/prefs/pref_value_map.cc
@@ -5,6 +5,7 @@
#include "base/prefs/pref_value_map.h"
#include <map>
+#include <utility>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -40,7 +41,7 @@
if (old_value && value->Equals(old_value))
return false;
- prefs_.set(key, value.Pass());
+ prefs_.set(key, std::move(value));
return true;
}
diff --git a/base/prefs/testing_pref_store.cc b/base/prefs/testing_pref_store.cc
index 2322f4e..a3a7ab5 100644
--- a/base/prefs/testing_pref_store.cc
+++ b/base/prefs/testing_pref_store.cc
@@ -4,6 +4,8 @@
#include "base/prefs/testing_pref_store.h"
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
@@ -45,7 +47,7 @@
void TestingPrefStore::SetValue(const std::string& key,
scoped_ptr<base::Value> value,
uint32 flags) {
- if (prefs_.SetValue(key, value.Pass())) {
+ if (prefs_.SetValue(key, std::move(value))) {
committed_ = false;
NotifyPrefValueChanged(key);
}
@@ -54,7 +56,7 @@
void TestingPrefStore::SetValueSilently(const std::string& key,
scoped_ptr<base::Value> value,
uint32 flags) {
- if (prefs_.SetValue(key, value.Pass()))
+ if (prefs_.SetValue(key, std::move(value)))
committed_ = false;
}
diff --git a/base/prefs/value_map_pref_store.cc b/base/prefs/value_map_pref_store.cc
index f22f93a..078ab28 100644
--- a/base/prefs/value_map_pref_store.cc
+++ b/base/prefs/value_map_pref_store.cc
@@ -5,6 +5,7 @@
#include "base/prefs/value_map_pref_store.h"
#include <algorithm>
+#include <utility>
#include "base/stl_util.h"
#include "base/values.h"
@@ -31,7 +32,7 @@
void ValueMapPrefStore::SetValue(const std::string& key,
scoped_ptr<base::Value> value,
uint32 flags) {
- if (prefs_.SetValue(key, value.Pass()))
+ if (prefs_.SetValue(key, std::move(value)))
FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
}
@@ -53,7 +54,7 @@
void ValueMapPrefStore::SetValueSilently(const std::string& key,
scoped_ptr<base::Value> value,
uint32 flags) {
- prefs_.SetValue(key, value.Pass());
+ prefs_.SetValue(key, std::move(value));
}
ValueMapPrefStore::~ValueMapPrefStore() {}
diff --git a/base/process/process_metrics.cc b/base/process/process_metrics.cc
index 6d99383..f4a3ea1 100644
--- a/base/process/process_metrics.cc
+++ b/base/process/process_metrics.cc
@@ -4,6 +4,8 @@
#include "base/process/process_metrics.h"
+#include <utility>
+
#include "base/logging.h"
#include "base/values.h"
@@ -40,7 +42,7 @@
res->Set("swapinfo", swap_info_.ToValue());
#endif
- return res.Pass();
+ return std::move(res);
}
ProcessMetrics* ProcessMetrics::CreateCurrentProcessMetrics() {
diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc
index adca7c5..63d6014 100644
--- a/base/process/process_metrics_linux.cc
+++ b/base/process/process_metrics_linux.cc
@@ -10,6 +10,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
+#include <utility>
#include "base/files/file_util.h"
#include "base/logging.h"
@@ -544,7 +545,7 @@
res->SetInteger("gem_size", gem_size);
#endif
- return res.Pass();
+ return std::move(res);
}
// exposed for testing
@@ -747,7 +748,7 @@
res->SetDouble("io_time", static_cast<double>(io_time));
res->SetDouble("weighted_io_time", static_cast<double>(weighted_io_time));
- return res.Pass();
+ return std::move(res);
}
bool IsValidDiskName(const std::string& candidate) {
@@ -872,7 +873,7 @@
else
res->SetDouble("compression_ratio", 0);
- return res.Pass();
+ return std::move(res);
}
void GetSwapInfo(SwapInfo* swap_info) {
diff --git a/base/profiler/stack_sampling_profiler.cc b/base/profiler/stack_sampling_profiler.cc
index c7e38c0..52b412d 100644
--- a/base/profiler/stack_sampling_profiler.cc
+++ b/base/profiler/stack_sampling_profiler.cc
@@ -5,6 +5,7 @@
#include "base/profiler/stack_sampling_profiler.h"
#include <algorithm>
+#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -113,11 +114,10 @@
scoped_ptr<NativeStackSampler> native_sampler,
const SamplingParams& params,
const CompletedCallback& completed_callback)
- : native_sampler_(native_sampler.Pass()),
+ : native_sampler_(std::move(native_sampler)),
params_(params),
stop_event_(false, false),
- completed_callback_(completed_callback) {
-}
+ completed_callback_(completed_callback) {}
StackSamplingProfiler::SamplingThread::~SamplingThread() {}
@@ -256,8 +256,8 @@
if (!native_sampler)
return;
- sampling_thread_.reset(
- new SamplingThread(native_sampler.Pass(), params_, completed_callback_));
+ sampling_thread_.reset(new SamplingThread(std::move(native_sampler), params_,
+ completed_callback_));
if (!PlatformThread::Create(0, sampling_thread_.get(),
&sampling_thread_handle_))
sampling_thread_.reset();
diff --git a/base/profiler/win32_stack_frame_unwinder.cc b/base/profiler/win32_stack_frame_unwinder.cc
index 2c06891..fc9a9a5 100644
--- a/base/profiler/win32_stack_frame_unwinder.cc
+++ b/base/profiler/win32_stack_frame_unwinder.cc
@@ -5,6 +5,7 @@
#include "base/profiler/win32_stack_frame_unwinder.h"
#include <windows.h>
+#include <utility>
#include "base/containers/hash_tables.h"
#include "base/memory/singleton.h"
@@ -292,7 +293,6 @@
scoped_ptr<UnwindFunctions> unwind_functions)
: at_top_frame_(true),
unwind_info_present_for_all_frames_(true),
- unwind_functions_(unwind_functions.Pass()) {
-}
+ unwind_functions_(std::move(unwind_functions)) {}
} // namespace base
diff --git a/base/profiler/win32_stack_frame_unwinder_unittest.cc b/base/profiler/win32_stack_frame_unwinder_unittest.cc
index 2fe34a7..37032e1 100644
--- a/base/profiler/win32_stack_frame_unwinder_unittest.cc
+++ b/base/profiler/win32_stack_frame_unwinder_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/profiler/win32_stack_frame_unwinder.h"
+
+#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
-#include "base/profiler/win32_stack_frame_unwinder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -197,7 +199,8 @@
Win32StackFrameUnwinderTest::CreateUnwinder() {
scoped_ptr<TestUnwindFunctions> unwind_functions(new TestUnwindFunctions);
unwind_functions_ = unwind_functions.get();
- return make_scoped_ptr(new Win32StackFrameUnwinder(unwind_functions.Pass()));
+ return make_scoped_ptr(
+ new Win32StackFrameUnwinder(std::move(unwind_functions)));
}
// Checks the case where all frames have unwind information.
diff --git a/base/scoped_generic_unittest.cc b/base/scoped_generic_unittest.cc
index b28e154..5a6abfb 100644
--- a/base/scoped_generic_unittest.cc
+++ b/base/scoped_generic_unittest.cc
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/scoped_generic.h"
+
+#include <utility>
#include <vector>
-#include "base/scoped_generic.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -85,10 +87,10 @@
EXPECT_EQ(kSecond, values_freed[1]);
values_freed.clear();
- // Pass constructor.
+ // Move constructor.
{
ScopedInt a(kFirst, traits);
- ScopedInt b(a.Pass());
+ ScopedInt b(std::move(a));
EXPECT_TRUE(values_freed.empty()); // Nothing should be freed.
ASSERT_EQ(IntTraits::InvalidValue(), a.get());
ASSERT_EQ(kFirst, b.get());
@@ -98,11 +100,11 @@
ASSERT_EQ(kFirst, values_freed[0]);
values_freed.clear();
- // Pass assign.
+ // Move assign.
{
ScopedInt a(kFirst, traits);
ScopedInt b(kSecond, traits);
- b = a.Pass();
+ b = std::move(a);
ASSERT_EQ(1u, values_freed.size());
EXPECT_EQ(kSecond, values_freed[0]);
ASSERT_EQ(IntTraits::InvalidValue(), a.get());
diff --git a/base/sequence_checker_unittest.cc b/base/sequence_checker_unittest.cc
index 0aa0f9c..f0eda25 100644
--- a/base/sequence_checker_unittest.cc
+++ b/base/sequence_checker_unittest.cc
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/sequence_checker.h"
+
+#include <utility>
+
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -9,7 +13,6 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/sequence_checker.h"
#include "base/single_thread_task_runner.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/threading/thread.h"
@@ -130,7 +133,7 @@
new SequenceCheckedObject);
// Verify the destructor doesn't assert when called on a different thread.
- PostDeleteToOtherThread(sequence_checked_object.Pass());
+ PostDeleteToOtherThread(std::move(sequence_checked_object));
other_thread()->Stop();
}
@@ -157,7 +160,7 @@
PostDoStuffToWorkerPool(sequence_checked_object.get(), "A");
pool()->FlushForTesting();
- PostDeleteToOtherThread(sequence_checked_object.Pass());
+ PostDeleteToOtherThread(std::move(sequence_checked_object));
other_thread()->Stop();
}
@@ -175,7 +178,7 @@
PostDoStuffToWorkerPool(sequence_checked_object.get(), "B");
pool()->FlushForTesting();
- PostDeleteToOtherThread(sequence_checked_object.Pass());
+ PostDeleteToOtherThread(std::move(sequence_checked_object));
other_thread()->Stop();
}
@@ -245,7 +248,7 @@
PostDoStuffToWorkerPool(sequence_checked_object.get(), "B");
pool()->FlushForTesting();
- PostDeleteToOtherThread(sequence_checked_object.Pass());
+ PostDeleteToOtherThread(std::move(sequence_checked_object));
other_thread()->Stop();
}
diff --git a/base/task_runner_util_unittest.cc b/base/task_runner_util_unittest.cc
index 8245cfc..0a4f22e 100644
--- a/base/task_runner_util_unittest.cc
+++ b/base/task_runner_util_unittest.cc
@@ -4,6 +4,8 @@
#include "base/task_runner_util.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/location.h"
#include "base/run_loop.h"
@@ -40,7 +42,7 @@
void ExpectFoo(scoped_ptr<Foo> foo) {
EXPECT_TRUE(foo.get());
- scoped_ptr<Foo> local_foo(foo.Pass());
+ scoped_ptr<Foo> local_foo(std::move(foo));
EXPECT_TRUE(local_foo.get());
EXPECT_FALSE(foo.get());
}
@@ -58,7 +60,7 @@
void ExpectScopedFoo(scoped_ptr<Foo, FooDeleter> foo) {
EXPECT_TRUE(foo.get());
- scoped_ptr<Foo, FooDeleter> local_foo(foo.Pass());
+ scoped_ptr<Foo, FooDeleter> local_foo(std::move(foo));
EXPECT_TRUE(local_foo.get());
EXPECT_FALSE(foo.get());
}
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index 09b4ef3..7fcde6d 100644
--- a/base/test/histogram_tester.cc
+++ b/base/test/histogram_tester.cc
@@ -127,7 +127,7 @@
auto original_samples_it = histograms_snapshot_.find(histogram_name);
if (original_samples_it != histograms_snapshot_.end())
named_samples->Subtract(*original_samples_it->second);
- return named_samples.Pass();
+ return named_samples;
}
void HistogramTester::CheckBucketCount(
diff --git a/base/test/launcher/test_results_tracker.cc b/base/test/launcher/test_results_tracker.cc
index b766fa6..8516a48 100644
--- a/base/test/launcher/test_results_tracker.cc
+++ b/base/test/launcher/test_results_tracker.cc
@@ -4,6 +4,8 @@
#include "base/test/launcher/test_results_tracker.h"
+#include <utility>
+
#include "base/base64.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -226,19 +228,19 @@
for (const auto& global_tag : global_tags_) {
global_tags->AppendString(global_tag);
}
- summary_root->Set("global_tags", global_tags.Pass());
+ summary_root->Set("global_tags", std::move(global_tags));
scoped_ptr<ListValue> all_tests(new ListValue);
for (const auto& test : all_tests_) {
all_tests->AppendString(test);
}
- summary_root->Set("all_tests", all_tests.Pass());
+ summary_root->Set("all_tests", std::move(all_tests));
scoped_ptr<ListValue> disabled_tests(new ListValue);
for (const auto& disabled_test : disabled_tests_) {
disabled_tests->AppendString(disabled_test);
}
- summary_root->Set("disabled_tests", disabled_tests.Pass());
+ summary_root->Set("disabled_tests", std::move(disabled_tests));
scoped_ptr<ListValue> per_iteration_data(new ListValue);
@@ -284,14 +286,14 @@
Base64Encode(test_result.output_snippet, &base64_output_snippet);
test_result_value->SetString("output_snippet_base64",
base64_output_snippet);
- test_results->Append(test_result_value.Pass());
+ test_results->Append(std::move(test_result_value));
}
current_iteration_data->SetWithoutPathExpansion(j->first,
- test_results.Pass());
+ std::move(test_results));
}
- per_iteration_data->Append(current_iteration_data.Pass());
- summary_root->Set("per_iteration_data", per_iteration_data.Pass());
+ per_iteration_data->Append(std::move(current_iteration_data));
+ summary_root->Set("per_iteration_data", std::move(per_iteration_data));
}
JSONFileValueSerializer serializer(path);
diff --git a/base/test/thread_test_helper.cc b/base/test/thread_test_helper.cc
index 6a12190..f238cee 100644
--- a/base/test/thread_test_helper.cc
+++ b/base/test/thread_test_helper.cc
@@ -4,6 +4,8 @@
#include "base/test/thread_test_helper.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/location.h"
#include "base/threading/thread_restrictions.h"
@@ -13,9 +15,8 @@
ThreadTestHelper::ThreadTestHelper(
scoped_refptr<SingleThreadTaskRunner> target_thread)
: test_result_(false),
- target_thread_(target_thread.Pass()),
- done_event_(false, false) {
-}
+ target_thread_(std::move(target_thread)),
+ done_event_(false, false) {}
bool ThreadTestHelper::Run() {
if (!target_thread_->PostTask(
diff --git a/base/test/values_test_util.cc b/base/test/values_test_util.cc
index ebfc494..f974c14 100644
--- a/base/test/values_test_util.cc
+++ b/base/test/values_test_util.cc
@@ -70,7 +70,7 @@
ADD_FAILURE() << "Failed to parse \"" << json << "\": " << error_msg;
result = Value::CreateNullValue();
}
- return result.Pass();
+ return result;
}
} // namespace test
diff --git a/base/timer/hi_res_timer_manager_unittest.cc b/base/timer/hi_res_timer_manager_unittest.cc
index 5475a91..4fc48b5 100644
--- a/base/timer/hi_res_timer_manager_unittest.cc
+++ b/base/timer/hi_res_timer_manager_unittest.cc
@@ -4,6 +4,8 @@
#include "base/timer/hi_res_timer_manager.h"
+#include <utility>
+
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/power_monitor/power_monitor.h"
@@ -22,7 +24,7 @@
scoped_ptr<base::PowerMonitorSource> power_monitor_source(
new base::PowerMonitorDeviceSource());
scoped_ptr<base::PowerMonitor> power_monitor(
- new base::PowerMonitor(power_monitor_source.Pass()));
+ new base::PowerMonitor(std::move(power_monitor_source)));
HighResolutionTimerManager manager;
// Simulate a on-AC power event to get to a known initial state.
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index 6f2e8b0..e6a1cc3 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -5,6 +5,7 @@
#include "base/trace_event/memory_dump_manager.h"
#include <algorithm>
+#include <utility>
#include "base/atomic_sequence_num.h"
#include "base/base_switches.h"
@@ -306,7 +307,7 @@
// Start the thread hop. |dump_providers_| are kept sorted by thread, so
// ContinueAsyncProcessDump will hop at most once per thread (w.r.t. thread
// affinity specified by the MemoryDumpProvider(s) in RegisterDumpProvider()).
- ContinueAsyncProcessDump(pmd_async_state.Pass());
+ ContinueAsyncProcessDump(std::move(pmd_async_state));
}
// At most one ContinueAsyncProcessDump() can be active at any time for a given
@@ -378,7 +379,7 @@
const bool did_post_task = task_runner->PostTask(
FROM_HERE, Bind(&MemoryDumpManager::ContinueAsyncProcessDump,
- Unretained(this), Passed(pmd_async_state.Pass())));
+ Unretained(this), Passed(&pmd_async_state)));
if (did_post_task)
return;
@@ -430,9 +431,9 @@
}
if (finalize)
- return FinalizeDumpAndAddToTrace(pmd_async_state.Pass());
+ return FinalizeDumpAndAddToTrace(std::move(pmd_async_state));
- ContinueAsyncProcessDump(pmd_async_state.Pass());
+ ContinueAsyncProcessDump(std::move(pmd_async_state));
}
// static
@@ -444,7 +445,7 @@
pmd_async_state->callback_task_runner;
callback_task_runner->PostTask(
FROM_HERE, Bind(&MemoryDumpManager::FinalizeDumpAndAddToTrace,
- Passed(pmd_async_state.Pass())));
+ Passed(&pmd_async_state)));
return;
}
@@ -529,7 +530,7 @@
}
DCHECK(!dump_thread_);
- dump_thread_ = dump_thread.Pass();
+ dump_thread_ = std::move(dump_thread);
session_state_ = new MemoryDumpSessionState(stack_frame_deduplicator);
for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) {
@@ -583,7 +584,7 @@
scoped_ptr<Thread> dump_thread;
{
AutoLock lock(lock_);
- dump_thread = dump_thread_.Pass();
+ dump_thread = std::move(dump_thread_);
session_state_ = nullptr;
}
@@ -645,7 +646,7 @@
auto iter = process_dumps.find(pid);
if (iter == process_dumps.end()) {
scoped_ptr<ProcessMemoryDump> new_pmd(new ProcessMemoryDump(session_state));
- iter = process_dumps.insert(pid, new_pmd.Pass()).first;
+ iter = process_dumps.insert(pid, std::move(new_pmd)).first;
}
return iter->second;
}
diff --git a/base/trace_event/trace_buffer.cc b/base/trace_event/trace_buffer.cc
index a2e4f14..eb7caa5 100644
--- a/base/trace_event/trace_buffer.cc
+++ b/base/trace_event/trace_buffer.cc
@@ -4,6 +4,8 @@
#include "base/trace_event/trace_buffer.h"
+#include <utility>
+
#include "base/memory/scoped_vector.h"
#include "base/trace_event/trace_event_impl.h"
@@ -105,7 +107,7 @@
TraceBufferChunk* chunk = chunks_[chunk_index];
cloned_buffer->chunks_.push_back(chunk ? chunk->Clone().release() : NULL);
}
- return cloned_buffer.Pass();
+ return std::move(cloned_buffer);
}
void EstimateTraceMemoryOverhead(
@@ -309,7 +311,7 @@
cloned_chunk->next_free_ = next_free_;
for (size_t i = 0; i < next_free_; ++i)
cloned_chunk->chunk_[i].CopyFrom(chunk_[i]);
- return cloned_chunk.Pass();
+ return cloned_chunk;
}
void TraceBufferChunk::EstimateTraceMemoryOverhead(
diff --git a/base/trace_event/trace_config.cc b/base/trace_event/trace_config.cc
index 7124bea..fbe7e68 100644
--- a/base/trace_event/trace_config.cc
+++ b/base/trace_event/trace_config.cc
@@ -4,6 +4,8 @@
#include "base/trace_event/trace_config.h"
+#include <utility>
+
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/strings/pattern.h"
@@ -466,7 +468,7 @@
list->AppendString(*ci);
}
- dict.Set(param, list.Pass());
+ dict.Set(param, std::move(list));
}
void TraceConfig::SetMemoryDumpConfig(
@@ -558,13 +560,13 @@
static_cast<int>(config.periodic_interval_ms));
trigger_dict->SetString(
kModeParam, MemoryDumpLevelOfDetailToString(config.level_of_detail));
- triggers_list->Append(trigger_dict.Pass());
+ triggers_list->Append(std::move(trigger_dict));
}
// Empty triggers will still be specified explicitly since it means that
// the periodic dumps are not enabled.
- memory_dump_config->Set(kTriggersParam, triggers_list.Pass());
- dict.Set(kMemoryDumpConfigParam, memory_dump_config.Pass());
+ memory_dump_config->Set(kTriggersParam, std::move(triggers_list));
+ dict.Set(kMemoryDumpConfigParam, std::move(memory_dump_config));
}
}
diff --git a/base/trace_event/trace_event_argument.cc b/base/trace_event/trace_event_argument.cc
index e370fcb2..72c6866 100644
--- a/base/trace_event/trace_event_argument.cc
+++ b/base/trace_event/trace_event_argument.cc
@@ -4,6 +4,8 @@
#include "base/trace_event/trace_event_argument.h"
+#include <utility>
+
#include "base/bits.h"
#include "base/json/json_writer.h"
#include "base/trace_event/trace_event_memory_overhead.h"
@@ -439,7 +441,7 @@
}
}
DCHECK(stack.empty());
- return root.Pass();
+ return std::move(root);
}
void TracedValue::AppendAsTraceFormat(std::string* out) const {
diff --git a/base/trace_event/trace_event_argument_unittest.cc b/base/trace_event/trace_event_argument_unittest.cc
index c1233ac..c9ccdb4 100644
--- a/base/trace_event/trace_event_argument_unittest.cc
+++ b/base/trace_event/trace_event_argument_unittest.cc
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include "base/trace_event/trace_event_argument.h"
+
+#include <utility>
+
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -106,11 +109,11 @@
list_value->AppendBoolean(false);
list_value->AppendInteger(1);
list_value->AppendString("in_list");
- list_value->Append(dict_value.Pass());
+ list_value->Append(std::move(dict_value));
scoped_refptr<TracedValue> value = new TracedValue();
value->BeginDictionary("outer_dict");
- value->SetValue("inner_list", list_value.Pass());
+ value->SetValue("inner_list", std::move(list_value));
value->EndDictionary();
dict_value.reset();
diff --git a/base/trace_event/trace_event_memory.cc b/base/trace_event/trace_event_memory.cc
index 73c8536..187bf74 100644
--- a/base/trace_event/trace_event_memory.cc
+++ b/base/trace_event/trace_event_memory.cc
@@ -4,6 +4,8 @@
#include "base/trace_event/trace_event_memory.h"
+#include <utility>
+
#include "base/debug/leak_annotations.h"
#include "base/lazy_instance.h"
#include "base/location.h"
@@ -149,7 +151,7 @@
HeapProfilerStartFunction heap_profiler_start_function,
HeapProfilerStopFunction heap_profiler_stop_function,
GetHeapProfileFunction get_heap_profile_function)
- : task_runner_(task_runner.Pass()),
+ : task_runner_(std::move(task_runner)),
heap_profiler_start_function_(heap_profiler_start_function),
heap_profiler_stop_function_(heap_profiler_stop_function),
get_heap_profile_function_(get_heap_profile_function),
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index 31dda00..c8b28e3 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <cmath>
+#include <utility>
#include "base/base_switches.h"
#include "base/bind.h"
@@ -328,7 +329,7 @@
trace_log_->lock_.AssertAcquired();
if (trace_log_->CheckGeneration(generation_)) {
// Return the chunk to the buffer only if the generation matches.
- trace_log_->logged_events_->ReturnChunk(chunk_index_, chunk_.Pass());
+ trace_log_->logged_events_->ReturnChunk(chunk_index_, std::move(chunk_));
}
// Otherwise this method may be called from the destructor, or TraceLog will
// find the generation mismatch and delete this buffer soon.
@@ -795,7 +796,7 @@
if (thread_shared_chunk_ && thread_shared_chunk_->IsFull()) {
logged_events_->ReturnChunk(thread_shared_chunk_index_,
- thread_shared_chunk_.Pass());
+ std::move(thread_shared_chunk_));
}
if (!thread_shared_chunk_) {
@@ -892,7 +893,7 @@
if (thread_shared_chunk_) {
logged_events_->ReturnChunk(thread_shared_chunk_index_,
- thread_shared_chunk_.Pass());
+ std::move(thread_shared_chunk_));
}
if (thread_message_loops_.size()) {
@@ -989,7 +990,7 @@
return;
}
- ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(),
+ ConvertTraceEventsToTraceFormat(std::move(previous_logged_events),
flush_output_callback,
argument_filter_predicate);
}
@@ -1049,9 +1050,9 @@
if (thread_shared_chunk_) {
// Return the chunk to the main buffer to flush the sampling data.
logged_events_->ReturnChunk(thread_shared_chunk_index_,
- thread_shared_chunk_.Pass());
+ std::move(thread_shared_chunk_));
}
- previous_logged_events = logged_events_->CloneForIteration().Pass();
+ previous_logged_events = logged_events_->CloneForIteration();
if (trace_options() & kInternalEnableArgumentFilter) {
CHECK(!argument_filter_predicate_.is_null());
@@ -1059,7 +1060,7 @@
}
} // release lock
- ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(),
+ ConvertTraceEventsToTraceFormat(std::move(previous_logged_events),
flush_output_callback,
argument_filter_predicate);
}
@@ -1388,7 +1389,7 @@
trace_event_internal::kNoId, // bind_id
num_args, arg_names, arg_types, arg_values, convertable_values, flags);
AutoLock lock(lock_);
- metadata_events_.push_back(trace_event.Pass());
+ metadata_events_.push_back(std::move(trace_event));
}
// May be called when a COMPELETE event ends and the unfinished event has been
diff --git a/base/values.cc b/base/values.cc
index 9b2483e..ab3c38a 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include <cmath>
#include <ostream>
+#include <utility>
#include "base/json/json_writer.h"
#include "base/logging.h"
@@ -32,7 +33,7 @@
if (child_copy) {
if (!copy)
copy.reset(new ListValue);
- copy->Append(child_copy.Pass());
+ copy->Append(std::move(child_copy));
}
}
return copy;
@@ -46,7 +47,7 @@
if (child_copy) {
if (!copy)
copy.reset(new DictionaryValue);
- copy->SetWithoutPathExpansion(it.key(), child_copy.Pass());
+ copy->SetWithoutPathExpansion(it.key(), std::move(child_copy));
}
}
return copy;
@@ -313,10 +314,7 @@
}
BinaryValue::BinaryValue(scoped_ptr<char[]> buffer, size_t size)
- : Value(TYPE_BINARY),
- buffer_(buffer.Pass()),
- size_(size) {
-}
+ : Value(TYPE_BINARY), buffer_(std::move(buffer)), size_(size) {}
BinaryValue::~BinaryValue() {
}
@@ -327,7 +325,7 @@
char* buffer_copy = new char[size];
memcpy(buffer_copy, buffer, size);
scoped_ptr<char[]> scoped_buffer_copy(buffer_copy);
- return new BinaryValue(scoped_buffer_copy.Pass(), size);
+ return new BinaryValue(std::move(scoped_buffer_copy), size);
}
bool BinaryValue::GetAsBinary(const BinaryValue** out_value) const {
@@ -419,7 +417,8 @@
current_path.erase(0, delimiter_position + 1);
}
- current_dictionary->SetWithoutPathExpansion(current_path, in_value.Pass());
+ current_dictionary->SetWithoutPathExpansion(current_path,
+ std::move(in_value));
}
void DictionaryValue::Set(const std::string& path, Value* in_value) {
diff --git a/base/values_unittest.cc b/base/values_unittest.cc
index 37ed7ce..a5bd002 100644
--- a/base/values_unittest.cc
+++ b/base/values_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <limits>
+#include <utility>
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
@@ -34,13 +35,13 @@
settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
scoped_ptr<ListValue> new_toolbar_bookmarks(new ListValue);
- settings.Set("global.toolbar.bookmarks", new_toolbar_bookmarks.Pass());
+ settings.Set("global.toolbar.bookmarks", std::move(new_toolbar_bookmarks));
ASSERT_TRUE(settings.GetList("global.toolbar.bookmarks", &toolbar_bookmarks));
scoped_ptr<DictionaryValue> new_bookmark(new DictionaryValue);
new_bookmark->SetString("name", "Froogle");
new_bookmark->SetString("url", "http://froogle.com");
- toolbar_bookmarks->Append(new_bookmark.Pass());
+ toolbar_bookmarks->Append(std::move(new_bookmark));
ListValue* bookmark_list;
ASSERT_TRUE(settings.GetList("global.toolbar.bookmarks", &bookmark_list));
@@ -114,7 +115,7 @@
// Test the common case of a non-empty buffer
scoped_ptr<char[]> buffer(new char[15]);
char* original_buffer = buffer.get();
- binary.reset(new BinaryValue(buffer.Pass(), 15));
+ binary.reset(new BinaryValue(std::move(buffer), 15));
ASSERT_TRUE(binary.get());
ASSERT_TRUE(binary->GetBuffer());
ASSERT_EQ(original_buffer, binary->GetBuffer());
@@ -250,7 +251,7 @@
ListValue list;
scoped_ptr<DeletionTestValue> value(new DeletionTestValue(&deletion_flag));
DeletionTestValue* original_value = value.get();
- list.Append(value.Pass());
+ list.Append(std::move(value));
EXPECT_FALSE(deletion_flag);
size_t index = 0;
list.Remove(*original_value, &index);
@@ -393,45 +394,45 @@
DictionaryValue original_dict;
scoped_ptr<Value> scoped_null = Value::CreateNullValue();
Value* original_null = scoped_null.get();
- original_dict.Set("null", scoped_null.Pass());
+ original_dict.Set("null", std::move(scoped_null));
scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
FundamentalValue* original_bool = scoped_bool.get();
- original_dict.Set("bool", scoped_bool.Pass());
+ original_dict.Set("bool", std::move(scoped_bool));
scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
FundamentalValue* original_int = scoped_int.get();
- original_dict.Set("int", scoped_int.Pass());
+ original_dict.Set("int", std::move(scoped_int));
scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
FundamentalValue* original_double = scoped_double.get();
- original_dict.Set("double", scoped_double.Pass());
+ original_dict.Set("double", std::move(scoped_double));
scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
StringValue* original_string = scoped_string.get();
- original_dict.Set("string", scoped_string.Pass());
+ original_dict.Set("string", std::move(scoped_string));
scoped_ptr<StringValue> scoped_string16(
new StringValue(ASCIIToUTF16("hello16")));
StringValue* original_string16 = scoped_string16.get();
- original_dict.Set("string16", scoped_string16.Pass());
+ original_dict.Set("string16", std::move(scoped_string16));
scoped_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
scoped_ptr<BinaryValue> scoped_binary(
- new BinaryValue(original_buffer.Pass(), 42));
+ new BinaryValue(std::move(original_buffer), 42));
BinaryValue* original_binary = scoped_binary.get();
- original_dict.Set("binary", scoped_binary.Pass());
+ original_dict.Set("binary", std::move(scoped_binary));
scoped_ptr<ListValue> scoped_list(new ListValue());
Value* original_list = scoped_list.get();
scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
Value* original_list_element_0 = scoped_list_element_0.get();
- scoped_list->Append(scoped_list_element_0.Pass());
+ scoped_list->Append(std::move(scoped_list_element_0));
scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
Value* original_list_element_1 = scoped_list_element_1.get();
- scoped_list->Append(scoped_list_element_1.Pass());
- original_dict.Set("list", scoped_list.Pass());
+ scoped_list->Append(std::move(scoped_list_element_1));
+ original_dict.Set("list", std::move(scoped_list));
scoped_ptr<DictionaryValue> scoped_nested_dictionary(new DictionaryValue());
Value* original_nested_dictionary = scoped_nested_dictionary.get();
scoped_nested_dictionary->SetString("key", "value");
- original_dict.Set("dictionary", scoped_nested_dictionary.Pass());
+ original_dict.Set("dictionary", std::move(scoped_nested_dictionary));
scoped_ptr<DictionaryValue> copy_dict = original_dict.CreateDeepCopy();
ASSERT_TRUE(copy_dict.get());
@@ -568,9 +569,9 @@
list->Append(make_scoped_ptr(new DictionaryValue));
scoped_ptr<Value> list_copy(list->CreateDeepCopy());
- dv.Set("f", list.Pass());
+ dv.Set("f", std::move(list));
EXPECT_FALSE(dv.Equals(copy.get()));
- copy->Set("f", list_copy.Pass());
+ copy->Set("f", std::move(list_copy));
EXPECT_TRUE(dv.Equals(copy.get()));
original_list->Append(make_scoped_ptr(new FundamentalValue(true)));
@@ -611,38 +612,38 @@
DictionaryValue original_dict;
scoped_ptr<Value> scoped_null(Value::CreateNullValue());
Value* original_null = scoped_null.get();
- original_dict.Set("null", scoped_null.Pass());
+ original_dict.Set("null", std::move(scoped_null));
scoped_ptr<FundamentalValue> scoped_bool(new FundamentalValue(true));
Value* original_bool = scoped_bool.get();
- original_dict.Set("bool", scoped_bool.Pass());
+ original_dict.Set("bool", std::move(scoped_bool));
scoped_ptr<FundamentalValue> scoped_int(new FundamentalValue(42));
Value* original_int = scoped_int.get();
- original_dict.Set("int", scoped_int.Pass());
+ original_dict.Set("int", std::move(scoped_int));
scoped_ptr<FundamentalValue> scoped_double(new FundamentalValue(3.14));
Value* original_double = scoped_double.get();
- original_dict.Set("double", scoped_double.Pass());
+ original_dict.Set("double", std::move(scoped_double));
scoped_ptr<StringValue> scoped_string(new StringValue("hello"));
Value* original_string = scoped_string.get();
- original_dict.Set("string", scoped_string.Pass());
+ original_dict.Set("string", std::move(scoped_string));
scoped_ptr<StringValue> scoped_string16(
new StringValue(ASCIIToUTF16("hello16")));
Value* original_string16 = scoped_string16.get();
- original_dict.Set("string16", scoped_string16.Pass());
+ original_dict.Set("string16", std::move(scoped_string16));
scoped_ptr<char[]> original_buffer(new char[42]);
memset(original_buffer.get(), '!', 42);
scoped_ptr<BinaryValue> scoped_binary(
- new BinaryValue(original_buffer.Pass(), 42));
+ new BinaryValue(std::move(original_buffer), 42));
Value* original_binary = scoped_binary.get();
- original_dict.Set("binary", scoped_binary.Pass());
+ original_dict.Set("binary", std::move(scoped_binary));
scoped_ptr<ListValue> scoped_list(new ListValue());
Value* original_list = scoped_list.get();
scoped_ptr<FundamentalValue> scoped_list_element_0(new FundamentalValue(0));
- scoped_list->Append(scoped_list_element_0.Pass());
+ scoped_list->Append(std::move(scoped_list_element_0));
scoped_ptr<FundamentalValue> scoped_list_element_1(new FundamentalValue(1));
- scoped_list->Append(scoped_list_element_1.Pass());
- original_dict.Set("list", scoped_list.Pass());
+ scoped_list->Append(std::move(scoped_list_element_1));
+ original_dict.Set("list", std::move(scoped_list));
scoped_ptr<Value> copy_dict = original_dict.CreateDeepCopy();
scoped_ptr<Value> copy_null = original_null->CreateDeepCopy();
@@ -697,7 +698,7 @@
scoped_ptr<DictionaryValue> inner(new DictionaryValue);
inner->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
inner->Set("empty_list", make_scoped_ptr(new ListValue));
- root->Set("dict_with_empty_children", inner.Pass());
+ root->Set("dict_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
}
@@ -705,7 +706,7 @@
scoped_ptr<ListValue> inner(new ListValue);
inner->Append(make_scoped_ptr(new DictionaryValue));
inner->Append(make_scoped_ptr(new ListValue));
- root->Set("list_with_empty_children", inner.Pass());
+ root->Set("list_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
}
@@ -715,11 +716,11 @@
scoped_ptr<ListValue> inner(new ListValue());
inner->Append(make_scoped_ptr(new DictionaryValue));
inner->Append(make_scoped_ptr(new ListValue));
- root->Set("list_with_empty_children", inner.Pass());
+ root->Set("list_with_empty_children", std::move(inner));
scoped_ptr<DictionaryValue> inner2(new DictionaryValue);
inner2->Set("empty_dict", make_scoped_ptr(new DictionaryValue));
inner2->Set("empty_list", make_scoped_ptr(new ListValue));
- root->Set("dict_with_empty_children", inner2.Pass());
+ root->Set("dict_with_empty_children", std::move(inner2));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(2U, root->size());
}
@@ -730,8 +731,8 @@
scoped_ptr<ListValue> inner2(new ListValue);
inner2->Append(make_scoped_ptr(new StringValue("hello")));
inner->Append(make_scoped_ptr(new DictionaryValue));
- inner->Append(inner2.Pass());
- root->Set("list_with_empty_children", inner.Pass());
+ inner->Append(std::move(inner2));
+ root->Set("list_with_empty_children", std::move(inner));
root = root->DeepCopyWithoutEmptyChildren();
EXPECT_EQ(3U, root->size());
@@ -750,7 +751,7 @@
scoped_ptr<DictionaryValue> base_sub_dict(new DictionaryValue);
base_sub_dict->SetString("sub_base_key", "sub_base_key_value_base");
base_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_base");
- base->Set("sub_dict_key", base_sub_dict.Pass());
+ base->Set("sub_dict_key", std::move(base_sub_dict));
scoped_ptr<DictionaryValue> merge(new DictionaryValue);
merge->SetString("merge_key", "merge_key_value_merge");
@@ -758,7 +759,7 @@
scoped_ptr<DictionaryValue> merge_sub_dict(new DictionaryValue);
merge_sub_dict->SetString("sub_merge_key", "sub_merge_key_value_merge");
merge_sub_dict->SetString("sub_collide_key", "sub_collide_key_value_merge");
- merge->Set("sub_dict_key", merge_sub_dict.Pass());
+ merge->Set("sub_dict_key", std::move(merge_sub_dict));
base->MergeDictionary(merge.get());
@@ -799,7 +800,7 @@
EXPECT_EQ("value", value);
scoped_ptr<DictionaryValue> base(new DictionaryValue);
- base->Set("dict", child.Pass());
+ base->Set("dict", std::move(child));
EXPECT_EQ(1U, base->size());
DictionaryValue* ptr;