diff options
author | dcheng <dcheng@chromium.org> | 2015-12-18 09:48:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-18 17:48:52 +0000 |
commit | e59eca16010c109a5e3e4922189c8b264d34caa9 (patch) | |
tree | 838815399c6364a99a465938df9978aeaf75c766 /extensions/browser/value_store | |
parent | 5100baf1eac806abbdaaf8002887aacf652f34e5 (diff) | |
download | chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.zip chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.gz chromium_src-e59eca16010c109a5e3e4922189c8b264d34caa9.tar.bz2 |
Convert Pass()→std::move() in //extensions
BUG=557422
Review URL: https://codereview.chromium.org/1537893002
Cr-Commit-Position: refs/heads/master@{#366120}
Diffstat (limited to 'extensions/browser/value_store')
6 files changed, 34 insertions, 20 deletions
diff --git a/extensions/browser/value_store/leveldb_value_store.cc b/extensions/browser/value_store/leveldb_value_store.cc index 6ae15c4..cc6975b 100644 --- a/extensions/browser/value_store/leveldb_value_store.cc +++ b/extensions/browser/value_store/leveldb_value_store.cc @@ -4,6 +4,8 @@ #include "extensions/browser/value_store/leveldb_value_store.h" +#include <utility> + #include "base/files/file_util.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -167,7 +169,7 @@ ValueStore::ReadResult LeveldbValueStore::Get( settings->SetWithoutPathExpansion(*it, setting.release()); } - return MakeReadResult(settings.Pass(), status); + return MakeReadResult(std::move(settings), status); } ValueStore::ReadResult LeveldbValueStore::Get() { @@ -196,12 +198,12 @@ ValueStore::ReadResult LeveldbValueStore::Get() { Delete(key).ok() ? RESTORE_REPAIR_SUCCESS : RESTORE_DELETE_FAILURE, kInvalidJson)); } - settings->SetWithoutPathExpansion(key, value.Pass()); + settings->SetWithoutPathExpansion(key, std::move(value)); } if (it->status().IsNotFound()) { NOTREACHED() << "IsNotFound() but iterating over all keys?!"; - return MakeReadResult(settings.Pass(), status); + return MakeReadResult(std::move(settings), status); } if (!it->status().ok()) { @@ -209,7 +211,7 @@ ValueStore::ReadResult LeveldbValueStore::Get() { return MakeReadResult(status); } - return MakeReadResult(settings.Pass(), status); + return MakeReadResult(std::move(settings), status); } ValueStore::WriteResult LeveldbValueStore::Set( @@ -227,7 +229,7 @@ ValueStore::WriteResult LeveldbValueStore::Set( return MakeWriteResult(status); status.Merge(WriteToDb(&batch)); - return status.ok() ? MakeWriteResult(changes.Pass(), status) + return status.ok() ? MakeWriteResult(std::move(changes), status) : MakeWriteResult(status); } @@ -251,7 +253,7 @@ ValueStore::WriteResult LeveldbValueStore::Set( } status.Merge(WriteToDb(&batch)); - return status.ok() ? MakeWriteResult(changes.Pass(), status) + return status.ok() ? MakeWriteResult(std::move(changes), status) : MakeWriteResult(status); } @@ -289,7 +291,7 @@ ValueStore::WriteResult LeveldbValueStore::Remove( status.Merge(ToValueStoreError(ldb_status)); return MakeWriteResult(status); } - return MakeWriteResult(changes.Pass(), status); + return MakeWriteResult(std::move(changes), status); } ValueStore::WriteResult LeveldbValueStore::Clear() { @@ -310,7 +312,7 @@ ValueStore::WriteResult LeveldbValueStore::Clear() { } DeleteDbFile(); - return MakeWriteResult(changes.Pass(), read_result->status()); + return MakeWriteResult(std::move(changes), read_result->status()); } bool LeveldbValueStore::WriteToDbForTest(leveldb::WriteBatch* batch) { @@ -487,7 +489,7 @@ ValueStore::Status LeveldbValueStore::ReadFromDb( if (!value) return Status(CORRUPTION, FixCorruption(&key), kInvalidJson); - *setting = value.Pass(); + *setting = std::move(value); return Status(); } diff --git a/extensions/browser/value_store/testing_value_store.cc b/extensions/browser/value_store/testing_value_store.cc index 500e6e8..fee2aa0 100644 --- a/extensions/browser/value_store/testing_value_store.cc +++ b/extensions/browser/value_store/testing_value_store.cc @@ -4,6 +4,8 @@ #include "extensions/browser/value_store/testing_value_store.h" +#include <utility> + #include "base/logging.h" namespace { @@ -94,7 +96,7 @@ ValueStore::WriteResult TestingValueStore::Set( storage_.SetWithoutPathExpansion(it.key(), it.value().DeepCopy()); } } - return MakeWriteResult(changes.Pass(), status_); + return MakeWriteResult(std::move(changes), status_); } ValueStore::WriteResult TestingValueStore::Remove(const std::string& key) { @@ -115,7 +117,7 @@ ValueStore::WriteResult TestingValueStore::Remove( changes->push_back(ValueStoreChange(*it, old_value.release(), NULL)); } } - return MakeWriteResult(changes.Pass(), status_); + return MakeWriteResult(std::move(changes), status_); } ValueStore::WriteResult TestingValueStore::Clear() { diff --git a/extensions/browser/value_store/value_store.cc b/extensions/browser/value_store/value_store.cc index 88ebe2a..c198f10 100644 --- a/extensions/browser/value_store/value_store.cc +++ b/extensions/browser/value_store/value_store.cc @@ -4,6 +4,8 @@ #include "extensions/browser/value_store/value_store.h" +#include <utility> + #include "base/logging.h" // Implementation of Status. @@ -34,7 +36,7 @@ void ValueStore::Status::Merge(const Status& status) { ValueStore::ReadResultType::ReadResultType( scoped_ptr<base::DictionaryValue> settings, const Status& status) - : settings_(settings.Pass()), status_(status) { + : settings_(std::move(settings)), status_(status) { CHECK(settings_); } @@ -48,7 +50,7 @@ ValueStore::ReadResultType::~ReadResultType() {} ValueStore::WriteResultType::WriteResultType( scoped_ptr<ValueStoreChangeList> changes, const Status& status) - : changes_(changes.Pass()), status_(status) { + : changes_(std::move(changes)), status_(status) { CHECK(changes_); } diff --git a/extensions/browser/value_store/value_store.h b/extensions/browser/value_store/value_store.h index ca9d48c..cddc9aa 100644 --- a/extensions/browser/value_store/value_store.h +++ b/extensions/browser/value_store/value_store.h @@ -6,6 +6,7 @@ #define EXTENSIONS_BROWSER_VALUE_STORE_VALUE_STORE_H_ #include <string> +#include <utility> #include <vector> #include "base/memory/scoped_ptr.h" @@ -92,7 +93,7 @@ class ValueStore { // Must only be called if there is no error. base::DictionaryValue& settings() { return *settings_; } scoped_ptr<base::DictionaryValue> PassSettings() { - return settings_.Pass(); + return std::move(settings_); } const Status& status() const { return status_; } @@ -117,7 +118,9 @@ class ValueStore { // Won't be present if the NO_GENERATE_CHANGES WriteOptions was given. // Only call if no error. ValueStoreChangeList& changes() { return *changes_; } - scoped_ptr<ValueStoreChangeList> PassChanges() { return changes_.Pass(); } + scoped_ptr<ValueStoreChangeList> PassChanges() { + return std::move(changes_); + } const Status& status() const { return status_; } @@ -147,7 +150,7 @@ class ValueStore { // Helpers for making a Read/WriteResult. template <typename T> static ReadResult MakeReadResult(scoped_ptr<T> arg, const Status& status) { - return ReadResult(new ReadResultType(arg.Pass(), status)); + return ReadResult(new ReadResultType(std::move(arg), status)); } static ReadResult MakeReadResult(const Status& status) { return ReadResult(new ReadResultType(status)); @@ -155,7 +158,7 @@ class ValueStore { template <typename T> static WriteResult MakeWriteResult(scoped_ptr<T> arg, const Status& status) { - return WriteResult(new WriteResultType(arg.Pass(), status)); + return WriteResult(new WriteResultType(std::move(arg), status)); } static WriteResult MakeWriteResult(const Status& status) { return WriteResult(new WriteResultType(status)); diff --git a/extensions/browser/value_store/value_store_frontend.cc b/extensions/browser/value_store/value_store_frontend.cc index 26c3a43..0a46fe0 100644 --- a/extensions/browser/value_store/value_store_frontend.cc +++ b/extensions/browser/value_store/value_store_frontend.cc @@ -4,6 +4,8 @@ #include "extensions/browser/value_store/value_store_frontend.h" +#include <utility> + #include "base/bind.h" #include "base/files/file_path.h" #include "base/logging.h" @@ -82,7 +84,7 @@ class ValueStoreFrontend::Backend : public base::RefCountedThreadSafe<Backend> { void RunCallback(const ValueStoreFrontend::ReadCallback& callback, scoped_ptr<base::Value> value) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - callback.Run(value.Pass()); + callback.Run(std::move(value)); } // The actual ValueStore that handles persisting the data to disk. Used diff --git a/extensions/browser/value_store/value_store_frontend_unittest.cc b/extensions/browser/value_store/value_store_frontend_unittest.cc index b3030f5..0ee4c5c 100644 --- a/extensions/browser/value_store/value_store_frontend_unittest.cc +++ b/extensions/browser/value_store/value_store_frontend_unittest.cc @@ -2,13 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "extensions/browser/value_store/value_store_frontend.h" + +#include <utility> + #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" #include "content/public/test/test_browser_thread.h" -#include "extensions/browser/value_store/value_store_frontend.h" #include "extensions/common/extension_paths.h" #include "testing/gtest/include/gtest/gtest.h" @@ -55,7 +58,7 @@ class ValueStoreFrontendTest : public testing::Test { protected: void GetAndWait(scoped_ptr<base::Value>* output, scoped_ptr<base::Value> result) { - *output = result.Pass(); + *output = std::move(result); base::MessageLoop::current()->QuitWhenIdle(); } |