From c80b1b61bf666dfc15b6f93e8c6701cb30dc9354 Mon Sep 17 00:00:00 2001 From: dcheng Date: Fri, 25 Dec 2015 18:40:19 -0800 Subject: =?UTF-8?q?Convert=20Pass()=E2=86=92std::move()=20in=20//sync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=557422 Review URL: https://codereview.chromium.org/1539843002 Cr-Commit-Position: refs/heads/master@{#366886} --- .../attachments/attachment_downloader_impl.cc | 7 +++--- .../attachments/attachment_service_impl.cc | 15 +++++++------ .../attachment_service_impl_unittest.cc | 10 ++++----- .../attachment_service_proxy_for_test.cc | 10 +++++---- .../attachments/attachment_store_frontend.cc | 4 +++- .../attachment_store_frontend_unittest.cc | 4 +++- .../attachments/attachment_store_test_template.h | 10 +++++---- .../attachments/attachment_uploader_impl.cc | 4 ++-- .../attachment_uploader_impl_unittest.cc | 3 ++- .../attachments/on_disk_attachment_store.cc | 16 ++++++------- .../on_disk_attachment_store_unittest.cc | 4 ++-- .../attachments/task_queue_unittest.cc | 5 +++-- sync/internal_api/events/protocol_event.cc | 2 +- sync/internal_api/model_type_entity_unittest.cc | 8 +++---- sync/internal_api/model_type_store_backend.cc | 4 +++- .../model_type_store_backend_unittest.cc | 12 +++++----- sync/internal_api/model_type_store_impl.cc | 24 +++++++++++--------- .../internal_api/model_type_store_impl_unittest.cc | 16 +++++++------ sync/internal_api/protocol_event_buffer.cc | 4 ++-- sync/internal_api/public/attachments/task_queue.h | 4 ++-- .../public/base/progress_marker_map.cc | 2 +- sync/internal_api/public/change_record_unittest.cc | 6 ++--- .../public/sessions/commit_counters.cc | 2 +- .../public/sessions/status_counters.cc | 2 +- .../public/sessions/sync_session_snapshot.cc | 3 ++- .../public/sessions/update_counters.cc | 2 +- .../public/util/proto_value_ptr_unittest.cc | 4 +++- sync/internal_api/shared_model_type_processor.cc | 8 +++---- sync/internal_api/sync_backup_manager_unittest.cc | 2 +- .../sync_context_proxy_impl_unittest.cc | 3 ++- sync/internal_api/sync_manager_impl.cc | 26 ++++++++-------------- sync/internal_api/sync_manager_impl_unittest.cc | 7 +++--- sync/internal_api/sync_rollback_manager_base.cc | 8 +++---- 33 files changed, 129 insertions(+), 112 deletions(-) (limited to 'sync/internal_api') diff --git a/sync/internal_api/attachments/attachment_downloader_impl.cc b/sync/internal_api/attachments/attachment_downloader_impl.cc index b1e2153..0bdcbc3 100644 --- a/sync/internal_api/attachments/attachment_downloader_impl.cc +++ b/sync/internal_api/attachments/attachment_downloader_impl.cc @@ -5,6 +5,7 @@ #include "sync/internal_api/public/attachments/attachment_downloader_impl.h" #include +#include #include "base/base64.h" #include "base/bind.h" @@ -90,7 +91,7 @@ void AttachmentDownloaderImpl::DownloadAttachment( // DownloadState and request access token for it. scoped_ptr new_download_state( new DownloadState(attachment_id, url)); - iter = state_map_.add(url, new_download_state.Pass()).first; + iter = state_map_.add(url, std::move(new_download_state)).first; RequestAccessToken(iter->second); } DownloadState* download_state = iter->second; @@ -113,7 +114,7 @@ void AttachmentDownloaderImpl::OnGetTokenSuccess( DownloadState* download_state = *iter; download_state->access_token = access_token; download_state->url_fetcher = - CreateFetcher(download_state->attachment_url, access_token).Pass(); + CreateFetcher(download_state->attachment_url, access_token); download_state->start_time = base::TimeTicks::Now(); download_state->url_fetcher->Start(); } @@ -213,7 +214,7 @@ scoped_ptr AttachmentDownloaderImpl::CreateFetcher( AttachmentUploaderImpl::ConfigureURLFetcherCommon( url_fetcher.get(), access_token, raw_store_birthday_, model_type_, url_request_context_getter_.get()); - return url_fetcher.Pass(); + return url_fetcher; } void AttachmentDownloaderImpl::RequestAccessToken( diff --git a/sync/internal_api/attachments/attachment_service_impl.cc b/sync/internal_api/attachments/attachment_service_impl.cc index 6b0e606..3638a83 100644 --- a/sync/internal_api/attachments/attachment_service_impl.cc +++ b/sync/internal_api/attachments/attachment_service_impl.cc @@ -5,6 +5,7 @@ #include "sync/internal_api/public/attachments/attachment_service_impl.h" #include +#include #include "base/bind.h" #include "base/macros.h" @@ -117,9 +118,9 @@ AttachmentServiceImpl::AttachmentServiceImpl( Delegate* delegate, const base::TimeDelta& initial_backoff_delay, const base::TimeDelta& max_backoff_delay) - : attachment_store_(attachment_store.Pass()), - attachment_uploader_(attachment_uploader.Pass()), - attachment_downloader_(attachment_downloader.Pass()), + : attachment_store_(std::move(attachment_store)), + attachment_uploader_(std::move(attachment_uploader)), + attachment_downloader_(std::move(attachment_downloader)), delegate_(delegate), weak_ptr_factory_(this) { DCHECK(CalledOnValidThread()); @@ -154,9 +155,9 @@ scoped_ptr AttachmentServiceImpl::CreateForTest() { scoped_ptr attachment_service( new syncer::AttachmentServiceImpl( attachment_store->CreateAttachmentStoreForSync(), - attachment_uploader.Pass(), attachment_downloader.Pass(), NULL, - base::TimeDelta(), base::TimeDelta())); - return attachment_service.Pass(); + std::move(attachment_uploader), std::move(attachment_downloader), + NULL, base::TimeDelta(), base::TimeDelta())); + return attachment_service; } void AttachmentServiceImpl::GetOrDownloadAttachments( @@ -327,7 +328,7 @@ void AttachmentServiceImpl::ReadDoneNowUpload( } void AttachmentServiceImpl::SetTimerForTest(scoped_ptr timer) { - upload_task_queue_->SetTimerForTest(timer.Pass()); + upload_task_queue_->SetTimerForTest(std::move(timer)); } } // namespace syncer diff --git a/sync/internal_api/attachments/attachment_service_impl_unittest.cc b/sync/internal_api/attachments/attachment_service_impl_unittest.cc index a044a22..aaf0274 100644 --- a/sync/internal_api/attachments/attachment_service_impl_unittest.cc +++ b/sync/internal_api/attachments/attachment_service_impl_unittest.cc @@ -232,7 +232,7 @@ class AttachmentServiceImplTest : public testing::Test, attachment_store_backend_ = attachment_store_backend->AsWeakPtr(); scoped_ptr attachment_store = AttachmentStore::CreateMockStoreForTest( - attachment_store_backend.Pass()); + std::move(attachment_store_backend)); if (uploader.get()) { attachment_uploader_ = uploader->AsWeakPtr(); @@ -241,14 +241,14 @@ class AttachmentServiceImplTest : public testing::Test, attachment_downloader_ = downloader->AsWeakPtr(); } attachment_service_.reset(new AttachmentServiceImpl( - attachment_store->CreateAttachmentStoreForSync(), uploader.Pass(), - downloader.Pass(), delegate, base::TimeDelta::FromMinutes(1), + attachment_store->CreateAttachmentStoreForSync(), std::move(uploader), + std::move(downloader), delegate, base::TimeDelta::FromMinutes(1), base::TimeDelta::FromMinutes(8))); scoped_ptr timer_to_pass( new base::MockTimer(false, false)); mock_timer_ = timer_to_pass.get(); - attachment_service_->SetTimerForTest(timer_to_pass.Pass()); + attachment_service_->SetTimerForTest(std::move(timer_to_pass)); } AttachmentService* attachment_service() { return attachment_service_.get(); } @@ -263,7 +263,7 @@ class AttachmentServiceImplTest : public testing::Test, void DownloadDone(const AttachmentService::GetOrDownloadResult& result, scoped_ptr attachments) { download_results_.push_back(result); - last_download_attachments_ = attachments.Pass(); + last_download_attachments_ = std::move(attachments); } void RunLoop() { diff --git a/sync/internal_api/attachments/attachment_service_proxy_for_test.cc b/sync/internal_api/attachments/attachment_service_proxy_for_test.cc index 8682a91..fa8756b 100644 --- a/sync/internal_api/attachments/attachment_service_proxy_for_test.cc +++ b/sync/internal_api/attachments/attachment_service_proxy_for_test.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test.h" +#include + #include "base/message_loop/message_loop.h" #include "base/thread_task_runner_handle.h" #include "sync/internal_api/public/attachments/attachment_service_impl.h" @@ -12,10 +14,10 @@ namespace syncer { AttachmentServiceProxyForTest::OwningCore::OwningCore( scoped_ptr wrapped, - scoped_ptr > weak_ptr_factory) + scoped_ptr> weak_ptr_factory) : Core(weak_ptr_factory->GetWeakPtr()), - wrapped_(wrapped.Pass()), - weak_ptr_factory_(weak_ptr_factory.Pass()) { + wrapped_(std::move(wrapped)), + weak_ptr_factory_(std::move(weak_ptr_factory)) { DCHECK(wrapped_); } @@ -36,7 +38,7 @@ AttachmentServiceProxy AttachmentServiceProxyForTest::Create() { new base::WeakPtrFactory(wrapped.get())); scoped_refptr core_for_test( - new OwningCore(wrapped.Pass(), weak_ptr_factory.Pass())); + new OwningCore(std::move(wrapped), std::move(weak_ptr_factory))); scoped_refptr runner; if (base::ThreadTaskRunnerHandle::IsSet()) { diff --git a/sync/internal_api/attachments/attachment_store_frontend.cc b/sync/internal_api/attachments/attachment_store_frontend.cc index f1d1ffe..b098dd4 100644 --- a/sync/internal_api/attachments/attachment_store_frontend.cc +++ b/sync/internal_api/attachments/attachment_store_frontend.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/attachments/attachment_store_frontend.h" +#include + #include "base/bind.h" #include "base/location.h" #include "base/sequenced_task_runner.h" @@ -24,7 +26,7 @@ void NoOp(scoped_ptr backend) { AttachmentStoreFrontend::AttachmentStoreFrontend( scoped_ptr backend, const scoped_refptr& backend_task_runner) - : backend_(backend.Pass()), backend_task_runner_(backend_task_runner) { + : backend_(std::move(backend)), backend_task_runner_(backend_task_runner) { DCHECK(backend_); DCHECK(backend_task_runner_.get()); } diff --git a/sync/internal_api/attachments/attachment_store_frontend_unittest.cc b/sync/internal_api/attachments/attachment_store_frontend_unittest.cc index 590eee8..2994da1 100644 --- a/sync/internal_api/attachments/attachment_store_frontend_unittest.cc +++ b/sync/internal_api/attachments/attachment_store_frontend_unittest.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/attachments/attachment_store_frontend.h" +#include + #include "base/bind.h" #include "base/callback.h" #include "base/memory/ref_counted.h" @@ -125,7 +127,7 @@ class AttachmentStoreFrontendTest : public testing::Test { base::Bind(&AttachmentStoreFrontendTest::DtorCalled, base::Unretained(this)))); attachment_store_frontend_ = new AttachmentStoreFrontend( - backend.Pass(), base::ThreadTaskRunnerHandle::Get()); + std::move(backend), base::ThreadTaskRunnerHandle::Get()); } static void DoneWithResult(const AttachmentStore::Result& result) { diff --git a/sync/internal_api/attachments/attachment_store_test_template.h b/sync/internal_api/attachments/attachment_store_test_template.h index 86ea20e..831044b 100644 --- a/sync/internal_api/attachments/attachment_store_test_template.h +++ b/sync/internal_api/attachments/attachment_store_test_template.h @@ -5,7 +5,7 @@ #ifndef SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ #define SYNC_INTERNAL_API_ATTACHMENTS_ATTACHMENT_STORE_TEST_TEMPLATE_H_ -#include "sync/api/attachments/attachment_store.h" +#include #include "base/bind.h" #include "base/files/scoped_temp_dir.h" @@ -14,6 +14,7 @@ #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" #include "sync/api/attachments/attachment.h" +#include "sync/api/attachments/attachment_store.h" #include "sync/internal_api/public/attachments/attachment_util.h" #include "sync/protocol/sync.pb.h" #include "testing/gmock/include/gmock/gmock-matchers.h" @@ -114,8 +115,9 @@ class AttachmentStoreTest : public testing::Test { scoped_ptr source_attachments, scoped_ptr source_failed_attachment_ids) { CopyResult(destination_result, source_result); - *destination_attachments = source_attachments.Pass(); - *destination_failed_attachment_ids = source_failed_attachment_ids.Pass(); + *destination_attachments = std::move(source_attachments); + *destination_failed_attachment_ids = + std::move(source_failed_attachment_ids); } void CopyResultMetadata( @@ -124,7 +126,7 @@ class AttachmentStoreTest : public testing::Test { const AttachmentStore::Result& source_result, scoped_ptr source_metadata) { CopyResult(destination_result, source_result); - *destination_metadata = source_metadata.Pass(); + *destination_metadata = std::move(source_metadata); } }; diff --git a/sync/internal_api/attachments/attachment_uploader_impl.cc b/sync/internal_api/attachments/attachment_uploader_impl.cc index 735af8c..e0246d8 100644 --- a/sync/internal_api/attachments/attachment_uploader_impl.cc +++ b/sync/internal_api/attachments/attachment_uploader_impl.cc @@ -5,8 +5,8 @@ #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" #include - #include +#include #include #include "base/base64.h" @@ -329,7 +329,7 @@ void AttachmentUploaderImpl::UploadAttachment(const Attachment& attachment, url, url_request_context_getter_, attachment, callback, account_id_, scopes_, token_service_provider_.get(), raw_store_birthday_, weak_ptr_factory_.GetWeakPtr(), model_type_)); - state_map_.add(unique_id, upload_state.Pass()); + state_map_.add(unique_id, std::move(upload_state)); } // Static. diff --git a/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc b/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc index d8cf893..eed1266 100644 --- a/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc +++ b/sync/internal_api/attachments/attachment_uploader_impl_unittest.cc @@ -5,6 +5,7 @@ #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" #include +#include #include #include "base/bind.h" @@ -397,7 +398,7 @@ scoped_ptr RequestHandler::HandleRequest( scoped_ptr response(new BasicHttpResponse); response->set_code(GetStatusCode()); response->set_content_type("text/plain"); - return response.Pass(); + return std::move(response); } void RequestHandler::SetStatusCode(const net::HttpStatusCode& status_code) { diff --git a/sync/internal_api/attachments/on_disk_attachment_store.cc b/sync/internal_api/attachments/on_disk_attachment_store.cc index c579c45..ebdc3f8 100644 --- a/sync/internal_api/attachments/on_disk_attachment_store.cc +++ b/sync/internal_api/attachments/on_disk_attachment_store.cc @@ -5,8 +5,8 @@ #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" #include - #include +#include #include "base/bind.h" #include "base/callback.h" @@ -399,7 +399,7 @@ AttachmentStore::Result OnDiskAttachmentStore::OpenOrCreate( return AttachmentStore::UNSPECIFIED_ERROR; } - db_ = db.Pass(); + db_ = std::move(db); return AttachmentStore::SUCCESS; } @@ -409,11 +409,11 @@ scoped_ptr OnDiskAttachmentStore::ReadSingleAttachment( scoped_ptr attachment; attachment_store_pb::RecordMetadata record_metadata; if (!ReadSingleRecordMetadata(attachment_id, &record_metadata)) { - return attachment.Pass(); + return attachment; } if (!AttachmentHasReferenceFromComponent(record_metadata, ComponentToProto(component))) - return attachment.Pass(); + return attachment; const std::string key = MakeDataKeyFromAttachmentId(attachment_id); std::string data_str; @@ -421,7 +421,7 @@ scoped_ptr OnDiskAttachmentStore::ReadSingleAttachment( MakeNonCachingReadOptions(), key, &data_str); if (!status.ok()) { DVLOG(1) << "DB::Get for data failed: status=" << status.ToString(); - return attachment.Pass(); + return attachment; } scoped_refptr data = base::RefCountedString::TakeString(&data_str); @@ -429,16 +429,16 @@ scoped_ptr OnDiskAttachmentStore::ReadSingleAttachment( if (record_metadata.has_crc32c()) { if (record_metadata.crc32c() != crc32c) { DVLOG(1) << "Attachment crc32c does not match value read from store"; - return attachment.Pass(); + return attachment; } if (record_metadata.crc32c() != attachment_id.GetCrc32c()) { DVLOG(1) << "Attachment crc32c does not match value in AttachmentId"; - return attachment.Pass(); + return attachment; } } attachment.reset( new Attachment(Attachment::CreateFromParts(attachment_id, data))); - return attachment.Pass(); + return attachment; } bool OnDiskAttachmentStore::WriteSingleAttachment( diff --git a/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc b/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc index 09142e5..e195869 100644 --- a/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc +++ b/sync/internal_api/attachments/on_disk_attachment_store_unittest.cc @@ -5,8 +5,8 @@ #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" #include - #include +#include #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -99,7 +99,7 @@ class OnDiskAttachmentStoreSpecificTest : public testing::Test { const AttachmentStore::Result& source_result, scoped_ptr source_metadata) { CopyResult(destination_result, source_result); - *destination_metadata = source_metadata.Pass(); + *destination_metadata = std::move(source_metadata); } scoped_ptr OpenLevelDB() { diff --git a/sync/internal_api/attachments/task_queue_unittest.cc b/sync/internal_api/attachments/task_queue_unittest.cc index 361d49c..a84cae2 100644 --- a/sync/internal_api/attachments/task_queue_unittest.cc +++ b/sync/internal_api/attachments/task_queue_unittest.cc @@ -4,6 +4,7 @@ #include "sync/internal_api/public/attachments/task_queue.h" +#include #include #include "base/bind.h" @@ -100,7 +101,7 @@ TEST_F(TaskQueueTest, AddToQueue_NoDuplicates) { TEST_F(TaskQueueTest, Retry) { scoped_ptr timer_to_pass(new base::MockTimer(false, false)); base::MockTimer* mock_timer = timer_to_pass.get(); - queue_->SetTimerForTest(timer_to_pass.Pass()); + queue_->SetTimerForTest(std::move(timer_to_pass)); // 1st attempt. queue_->AddToQueue(1); @@ -198,7 +199,7 @@ TEST_F(TaskQueueTest, Cancel) { TEST_F(TaskQueueTest, ResetBackoff) { scoped_ptr timer_to_pass(new base::MockTimer(false, false)); base::MockTimer* mock_timer = timer_to_pass.get(); - queue_->SetTimerForTest(timer_to_pass.Pass()); + queue_->SetTimerForTest(std::move(timer_to_pass)); // Add an item, mark it as failed, re-add it and see that we now have a // backoff delay. diff --git a/sync/internal_api/events/protocol_event.cc b/sync/internal_api/events/protocol_event.cc index 78682b4..49e43b5 100644 --- a/sync/internal_api/events/protocol_event.cc +++ b/sync/internal_api/events/protocol_event.cc @@ -19,7 +19,7 @@ scoped_ptr ProtocolEvent::ToValue( dict->SetString("details", event.GetDetails()); dict->Set("proto", event.GetProtoMessage().release()); - return dict.Pass(); + return dict; } } // namespace syncer diff --git a/sync/internal_api/model_type_entity_unittest.cc b/sync/internal_api/model_type_entity_unittest.cc index 68390434..b47b69d 100644 --- a/sync/internal_api/model_type_entity_unittest.cc +++ b/sync/internal_api/model_type_entity_unittest.cc @@ -5,6 +5,7 @@ #include "sync/internal_api/public/model_type_entity.h" #include +#include #include "base/memory/scoped_ptr.h" #include "base/time/time.h" @@ -12,7 +13,6 @@ #include "sync/internal_api/public/non_blocking_sync_common.h" #include "sync/protocol/sync.pb.h" #include "sync/syncable/syncable_util.h" - #include "testing/gtest/include/gtest/gtest.h" namespace syncer_v2 { @@ -54,7 +54,7 @@ class ModelTypeEntityTest : public ::testing::Test { const sync_pb::EntitySpecifics& specifics) { scoped_ptr entity(NewLocalItem(tag)); MakeLocalChange(entity.get(), specifics); - return entity.Pass(); + return entity; } void MakeLocalChange(ModelTypeEntity* entity, @@ -62,7 +62,7 @@ class ModelTypeEntityTest : public ::testing::Test { scoped_ptr entity_data = make_scoped_ptr(new EntityData()); entity_data->specifics = specifics; entity_data->non_unique_name = "foo"; - entity->MakeLocalChange(entity_data.Pass(), kMtime); + entity->MakeLocalChange(std::move(entity_data), kMtime); } scoped_ptr NewServerItem() { @@ -75,7 +75,7 @@ class ModelTypeEntityTest : public ::testing::Test { const sync_pb::EntitySpecifics& specifics) { scoped_ptr entity(NewServerItem()); ApplyUpdateFromServer(entity.get(), version, specifics); - return entity.Pass(); + return entity; } void ApplyUpdateFromServer(ModelTypeEntity* entity, diff --git a/sync/internal_api/model_type_store_backend.cc b/sync/internal_api/model_type_store_backend.cc index ebe4118..d60d51f 100644 --- a/sync/internal_api/model_type_store_backend.cc +++ b/sync/internal_api/model_type_store_backend.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/model_type_store_backend.h" +#include + #include "base/files/file_path.h" #include "third_party/leveldatabase/env_chromium.h" #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" @@ -32,7 +34,7 @@ scoped_ptr ModelTypeStoreBackend::CreateInMemoryEnv() { } void ModelTypeStoreBackend::TakeEnvOwnership(scoped_ptr env) { - env_ = env.Pass(); + env_ = std::move(env); } ModelTypeStore::Result ModelTypeStoreBackend::Init(const std::string& path, diff --git a/sync/internal_api/model_type_store_backend_unittest.cc b/sync/internal_api/model_type_store_backend_unittest.cc index d84d831..4cc5aab 100644 --- a/sync/internal_api/model_type_store_backend_unittest.cc +++ b/sync/internal_api/model_type_store_backend_unittest.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/model_type_store_backend.h" +#include + #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -28,7 +30,7 @@ class ModelTypeStoreBackendTest : public testing::Test { path += "/test_db"; ModelTypeStore::Result result = backend->Init(path, in_memory_env_.get()); EXPECT_EQ(ModelTypeStore::Result::SUCCESS, result); - return backend.Pass(); + return backend; } protected: @@ -44,7 +46,7 @@ TEST_F(ModelTypeStoreBackendTest, WriteThenRead) { scoped_ptr write_batch(new leveldb::WriteBatch()); write_batch->Put("prefix:id1", "data1"); ModelTypeStore::Result result = - backend->WriteModifications(write_batch.Pass()); + backend->WriteModifications(std::move(write_batch)); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); // Read all records with prefix. @@ -73,7 +75,7 @@ TEST_F(ModelTypeStoreBackendTest, ReadAllRecordsWithPrefix) { write_batch->Put("prefix1:id1", "data1"); write_batch->Put("prefix2:id2", "data2"); ModelTypeStore::Result result = - backend->WriteModifications(write_batch.Pass()); + backend->WriteModifications(std::move(write_batch)); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); ModelTypeStore::RecordList record_list; @@ -94,7 +96,7 @@ TEST_F(ModelTypeStoreBackendTest, ReadDeletedRecord) { write_batch->Put("prefix:id1", "data1"); write_batch->Put("prefix:id2", "data2"); ModelTypeStore::Result result = - backend->WriteModifications(write_batch.Pass()); + backend->WriteModifications(std::move(write_batch)); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); ModelTypeStore::IdList id_list; @@ -111,7 +113,7 @@ TEST_F(ModelTypeStoreBackendTest, ReadDeletedRecord) { // Delete one record. write_batch.reset(new leveldb::WriteBatch()); write_batch->Delete("prefix:id2"); - result = backend->WriteModifications(write_batch.Pass()); + result = backend->WriteModifications(std::move(write_batch)); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); // Ensure deleted record id is returned in missing_id_list. diff --git a/sync/internal_api/model_type_store_impl.cc b/sync/internal_api/model_type_store_impl.cc index fa5a6b7..39d60c3 100644 --- a/sync/internal_api/model_type_store_impl.cc +++ b/sync/internal_api/model_type_store_impl.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/model_type_store_impl.h" +#include + #include "base/bind.h" #include "base/location.h" #include "base/logging.h" @@ -50,7 +52,7 @@ leveldb::WriteBatch* ModelTypeStoreImpl::GetLeveldbWriteBatch( ModelTypeStoreImpl::ModelTypeStoreImpl( scoped_ptr backend, scoped_refptr backend_task_runner) - : backend_(backend.Pass()), + : backend_(std::move(backend)), backend_task_runner_(backend_task_runner), weak_ptr_factory_(this) { DCHECK(backend_); @@ -73,7 +75,7 @@ void ModelTypeStoreImpl::CreateStore( scoped_ptr backend(new ModelTypeStoreBackend()); scoped_ptr store( - new ModelTypeStoreImpl(backend.Pass(), blocking_task_runner)); + new ModelTypeStoreImpl(std::move(backend), blocking_task_runner)); auto task = base::Bind(&ModelTypeStoreBackend::Init, @@ -97,13 +99,13 @@ void ModelTypeStoreImpl::CreateInMemoryStoreForTest( leveldb::Env* env_ptr = env.get(); scoped_ptr backend(new ModelTypeStoreBackend()); - backend->TakeEnvOwnership(env.Pass()); + backend->TakeEnvOwnership(std::move(env)); // In-memory store backend works on the same thread as test. scoped_refptr task_runner = base::ThreadTaskRunnerHandle::Get(); scoped_ptr store( - new ModelTypeStoreImpl(backend.Pass(), task_runner)); + new ModelTypeStoreImpl(std::move(backend), task_runner)); std::string path; env_ptr->GetTestDirectory(&path); @@ -126,7 +128,7 @@ void ModelTypeStoreImpl::BackendInitDone(const InitCallback& callback, if (result != Result::SUCCESS) { store.reset(); } - callback.Run(result, store.Pass()); + callback.Run(result, std::move(store)); } // Note on pattern for communicating with backend: @@ -163,7 +165,7 @@ void ModelTypeStoreImpl::ReadDataDone(const ReadDataCallback& callback, scoped_ptr missing_id_list, Result result) { DCHECK(CalledOnValidThread()); - callback.Run(result, record_list.Pass(), missing_id_list.Pass()); + callback.Run(result, std::move(record_list), std::move(missing_id_list)); } void ModelTypeStoreImpl::ReadAllData(const ReadAllDataCallback& callback) { @@ -184,7 +186,7 @@ void ModelTypeStoreImpl::ReadAllDataDone(const ReadAllDataCallback& callback, scoped_ptr record_list, Result result) { DCHECK(CalledOnValidThread()); - callback.Run(result, record_list.Pass()); + callback.Run(result, std::move(record_list)); } void ModelTypeStoreImpl::ReadAllMetadata(const ReadMetadataCallback& callback) { @@ -212,7 +214,7 @@ void ModelTypeStoreImpl::ReadMetadataRecordsDone( Result result) { DCHECK(CalledOnValidThread()); if (result != Result::SUCCESS) { - callback.Run(result, metadata_records.Pass(), std::string()); + callback.Run(result, std::move(metadata_records), std::string()); return; } @@ -241,7 +243,7 @@ void ModelTypeStoreImpl::ReadAllMetadataDone( Result result) { DCHECK(CalledOnValidThread()); if (result != Result::SUCCESS) { - callback.Run(result, metadata_records.Pass(), std::string()); + callback.Run(result, std::move(metadata_records), std::string()); return; } @@ -250,12 +252,12 @@ void ModelTypeStoreImpl::ReadAllMetadataDone( // string in this case. DCHECK((*missing_id_list)[0] == kGlobalMetadataKey); DCHECK(global_metadata_records->empty()); - callback.Run(Result::SUCCESS, metadata_records.Pass(), std::string()); + callback.Run(Result::SUCCESS, std::move(metadata_records), std::string()); return; } DCHECK(!global_metadata_records->empty()); DCHECK((*global_metadata_records)[0].id == kGlobalMetadataKey); - callback.Run(Result::SUCCESS, metadata_records.Pass(), + callback.Run(Result::SUCCESS, std::move(metadata_records), (*global_metadata_records)[0].value); } diff --git a/sync/internal_api/model_type_store_impl_unittest.cc b/sync/internal_api/model_type_store_impl_unittest.cc index 6f32242..1a01009 100644 --- a/sync/internal_api/model_type_store_impl_unittest.cc +++ b/sync/internal_api/model_type_store_impl_unittest.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/model_type_store_impl.h" +#include + #include "base/bind.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -26,7 +28,7 @@ class ModelTypeStoreImplTest : public testing::Test { void OnInitDone(ModelTypeStore::Result result, scoped_ptr store) { ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); - store_ = store.Pass(); + store_ = std::move(store); } void PumpLoop() { @@ -48,7 +50,7 @@ class ModelTypeStoreImplTest : public testing::Test { store()->WriteData(write_batch.get(), "id2", "data2"); store()->WriteGlobalMetadata(write_batch.get(), "global_metadata"); ModelTypeStore::Result result; - store()->CommitWriteBatch(write_batch.Pass(), + store()->CommitWriteBatch(std::move(write_batch), base::Bind(&CaptureResult, &result)); PumpLoop(); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); @@ -68,7 +70,7 @@ class ModelTypeStoreImplTest : public testing::Test { ModelTypeStore::Result result, scoped_ptr records) { *dst_result = result; - *dst_records = records.Pass(); + *dst_records = std::move(records); } static void CaptureResutRecordsAndString( @@ -79,7 +81,7 @@ class ModelTypeStoreImplTest : public testing::Test { scoped_ptr records, const std::string& value) { *dst_result = result; - *dst_records = records.Pass(); + *dst_records = std::move(records); *dst_value = value; } @@ -91,8 +93,8 @@ class ModelTypeStoreImplTest : public testing::Test { scoped_ptr records, scoped_ptr missing_id_list) { *dst_result = result; - *dst_records = records.Pass(); - *dst_id_list = missing_id_list.Pass(); + *dst_records = std::move(records); + *dst_id_list = std::move(missing_id_list); } private: @@ -168,7 +170,7 @@ TEST_F(ModelTypeStoreImplTest, MissingGlobalMetadata) { scoped_ptr write_batch = store()->CreateWriteBatch(); store()->DeleteGlobalMetadata(write_batch.get()); - store()->CommitWriteBatch(write_batch.Pass(), + store()->CommitWriteBatch(std::move(write_batch), base::Bind(&CaptureResult, &result)); PumpLoop(); ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result); diff --git a/sync/internal_api/protocol_event_buffer.cc b/sync/internal_api/protocol_event_buffer.cc index 962a0bd..dc4af22 100644 --- a/sync/internal_api/protocol_event_buffer.cc +++ b/sync/internal_api/protocol_event_buffer.cc @@ -31,9 +31,9 @@ ProtocolEventBuffer::GetBufferedProtocolEvents() const { ScopedVector ret; for (std::deque::const_iterator it = buffer_.begin(); it != buffer_.end(); ++it) { - ret.push_back((*it)->Clone().Pass()); + ret.push_back((*it)->Clone()); } - return ret.Pass(); + return ret; } } // namespace syncer diff --git a/sync/internal_api/public/attachments/task_queue.h b/sync/internal_api/public/attachments/task_queue.h index 0d76b91..e8ff1a0 100644 --- a/sync/internal_api/public/attachments/task_queue.h +++ b/sync/internal_api/public/attachments/task_queue.h @@ -6,9 +6,9 @@ #define SYNC_INTERNAL_API_PUBLIC_ATTACHMENTS_TASK_QUEUE_H_ #include - #include #include +#include #include "base/bind.h" #include "base/callback.h" @@ -235,7 +235,7 @@ template void TaskQueue::SetTimerForTest(scoped_ptr timer) { DCHECK(CalledOnValidThread()); DCHECK(timer.get()); - backoff_timer_ = timer.Pass(); + backoff_timer_ = std::move(timer); } template diff --git a/sync/internal_api/public/base/progress_marker_map.cc b/sync/internal_api/public/base/progress_marker_map.cc index f86b194..24d80ac 100644 --- a/sync/internal_api/public/base/progress_marker_map.cc +++ b/sync/internal_api/public/base/progress_marker_map.cc @@ -20,7 +20,7 @@ scoped_ptr ProgressMarkerMapToValue( it->second, false /* put_in_quotes */, &printable_payload); value->SetString(ModelTypeToString(it->first), printable_payload); } - return value.Pass(); + return value; } } // namespace syncer diff --git a/sync/internal_api/public/change_record_unittest.cc b/sync/internal_api/public/change_record_unittest.cc index a6b7a00..736e3e2 100644 --- a/sync/internal_api/public/change_record_unittest.cc +++ b/sync/internal_api/public/change_record_unittest.cc @@ -6,8 +6,8 @@ #include #include - #include +#include #include "base/memory/scoped_ptr.h" #include "base/strings/string_number_conversions.h" @@ -87,7 +87,7 @@ class TestExtraChangeRecordData : public ExtraPasswordChangeRecordData { } void set_dictionary_value(scoped_ptr dict) { - dict_ = dict.Pass(); + dict_ = std::move(dict); } void set_expected_to_value_calls(size_t expectation) { @@ -151,7 +151,7 @@ TEST_F(ChangeRecordTest, ChangeRecordToValue) { extra_value->SetString("foo", "bar"); scoped_ptr extra( new TestExtraChangeRecordData()); - extra->set_dictionary_value(extra_value.Pass()); + extra->set_dictionary_value(std::move(extra_value)); extra->set_expected_to_value_calls(2U); record.extra.reset(extra.release()); diff --git a/sync/internal_api/public/sessions/commit_counters.cc b/sync/internal_api/public/sessions/commit_counters.cc index 6038ad2..b44b54e 100644 --- a/sync/internal_api/public/sessions/commit_counters.cc +++ b/sync/internal_api/public/sessions/commit_counters.cc @@ -23,7 +23,7 @@ scoped_ptr CommitCounters::ToValue() const { value->SetInteger("numCommitsSuccess", num_commits_success); value->SetInteger("numCommitsConflict", num_commits_conflict); value->SetInteger("numCommitsError", num_commits_error); - return value.Pass(); + return value; } std::string CommitCounters::ToString() const { diff --git a/sync/internal_api/public/sessions/status_counters.cc b/sync/internal_api/public/sessions/status_counters.cc index 9a5dcb6..26b22fd 100644 --- a/sync/internal_api/public/sessions/status_counters.cc +++ b/sync/internal_api/public/sessions/status_counters.cc @@ -19,7 +19,7 @@ scoped_ptr StatusCounters::ToValue() const { scoped_ptr value(new base::DictionaryValue()); value->SetInteger("numEntries", num_entries); value->SetInteger("numEntriesAndTombstones", num_entries_and_tombstones); - return value.Pass(); + return value; } std::string StatusCounters::ToString() const { diff --git a/sync/internal_api/public/sessions/sync_session_snapshot.cc b/sync/internal_api/public/sessions/sync_session_snapshot.cc index 8842c17..e595934 100644 --- a/sync/internal_api/public/sessions/sync_session_snapshot.cc +++ b/sync/internal_api/public/sessions/sync_session_snapshot.cc @@ -5,6 +5,7 @@ #include "sync/internal_api/public/sessions/sync_session_snapshot.h" #include +#include #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" @@ -100,7 +101,7 @@ scoped_ptr SyncSessionSnapshot::ToValue() const { const std::string model_type = ModelTypeToString(static_cast(i)); counter_entries->Set(model_type, type_entries.release()); } - value->Set("counter_entries", counter_entries.Pass()); + value->Set("counter_entries", std::move(counter_entries)); return value; } diff --git a/sync/internal_api/public/sessions/update_counters.cc b/sync/internal_api/public/sessions/update_counters.cc index 0656baf..7f54fcb 100644 --- a/sync/internal_api/public/sessions/update_counters.cc +++ b/sync/internal_api/public/sessions/update_counters.cc @@ -39,7 +39,7 @@ scoped_ptr UpdateCounters::ToValue() const { value->SetInteger("numServerOverwrites", num_server_overwrites); value->SetInteger("numLocalOverwrites", num_local_overwrites); - return value.Pass(); + return value; } std::string UpdateCounters::ToString() const { diff --git a/sync/internal_api/public/util/proto_value_ptr_unittest.cc b/sync/internal_api/public/util/proto_value_ptr_unittest.cc index b47ffa5..d522317 100644 --- a/sync/internal_api/public/util/proto_value_ptr_unittest.cc +++ b/sync/internal_api/public/util/proto_value_ptr_unittest.cc @@ -4,6 +4,8 @@ #include "sync/internal_api/public/util/proto_value_ptr.h" +#include + #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "testing/gtest/include/gtest/gtest.h" @@ -70,7 +72,7 @@ class TestValue { ASSERT_TRUE(src->is_initialized()); ASSERT_FALSE(src->is_default()); // Not exactly swap, but good enough for the test. - value_ = src->value_.Pass(); + value_ = std::move(src->value_); } void ParseFromArray(const void* blob, int length) { diff --git a/sync/internal_api/shared_model_type_processor.cc b/sync/internal_api/shared_model_type_processor.cc index 15edd30..a6ed683 100644 --- a/sync/internal_api/shared_model_type_processor.cc +++ b/sync/internal_api/shared_model_type_processor.cc @@ -47,7 +47,7 @@ ModelTypeProcessorProxy::~ModelTypeProcessorProxy() {} void ModelTypeProcessorProxy::OnConnect(scoped_ptr worker) { processor_task_runner_->PostTask( FROM_HERE, base::Bind(&ModelTypeProcessor::OnConnect, processor_, - base::Passed(worker.Pass()))); + base::Passed(std::move(worker)))); } void ModelTypeProcessorProxy::OnCommitCompleted( @@ -100,7 +100,7 @@ void SharedModelTypeProcessor::Start(StartCallback callback) { new ModelTypeProcessorProxy(weak_ptr_factory_for_sync_.GetWeakPtr(), base::ThreadTaskRunnerHandle::Get())); - callback.Run(syncer::SyncError(), activation_context.Pass()); + callback.Run(syncer::SyncError(), std::move(activation_context)); } bool SharedModelTypeProcessor::IsEnabled() const { @@ -143,7 +143,7 @@ void SharedModelTypeProcessor::OnConnect(scoped_ptr worker) { DVLOG(1) << "Successfully connected " << ModelTypeToString(type_); is_connected_ = true; - worker_ = worker.Pass(); + worker_ = std::move(worker); FlushPendingCommitRequests(); } @@ -184,7 +184,7 @@ void SharedModelTypeProcessor::Put(const std::string& client_tag, entity = it->second.get(); } - entity->MakeLocalChange(entity_data.Pass(), now); + entity->MakeLocalChange(std::move(entity_data), now); FlushPendingCommitRequests(); } diff --git a/sync/internal_api/sync_backup_manager_unittest.cc b/sync/internal_api/sync_backup_manager_unittest.cc index 74132dd..4a986b1 100644 --- a/sync/internal_api/sync_backup_manager_unittest.cc +++ b/sync/internal_api/sync_backup_manager_unittest.cc @@ -66,7 +66,7 @@ class SyncBackupManagerTest : public syncer::SyncManager::Observer, args.database_location = temp_dir_.path(); args.event_handler = MakeWeakHandle(base::WeakPtr()); args.service_url = GURL("https://example.com/"); - args.post_factory = scoped_ptr().Pass(); + args.post_factory = scoped_ptr(); args.internal_components_factory.reset(new TestInternalComponentsFactory( InternalComponentsFactory::Switches(), storage_option, &storage_used_)); diff --git a/sync/internal_api/sync_context_proxy_impl_unittest.cc b/sync/internal_api/sync_context_proxy_impl_unittest.cc index e0f0a81d..c90fda1 100644 --- a/sync/internal_api/sync_context_proxy_impl_unittest.cc +++ b/sync/internal_api/sync_context_proxy_impl_unittest.cc @@ -4,6 +4,7 @@ #include "sync/internal_api/sync_context_proxy_impl.h" +#include #include #include "base/bind.h" @@ -54,7 +55,7 @@ class SyncContextProxyImplTest : public ::testing::Test, FakeModelTypeService { void StartDone(syncer::SyncError error, scoped_ptr context) { - context_proxy_->ConnectTypeToSync(syncer::THEMES, context.Pass()); + context_proxy_->ConnectTypeToSync(syncer::THEMES, std::move(context)); } scoped_ptr CreateModelTypeProcessor() { diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index 13e4244..fde8dc1 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -6,8 +6,8 @@ #include #include - #include +#include #include "base/base64.h" #include "base/bind.h" @@ -263,7 +263,7 @@ void SyncManagerImpl::Init(InitArgs* args) { scoped_ptr backing_store = args->internal_components_factory->BuildDirectoryBackingStore( InternalComponentsFactory::STORAGE_ON_DISK, - args->credentials.account_id, absolute_db_path).Pass(); + args->credentials.account_id, absolute_db_path); DCHECK(backing_store.get()); share_.directory.reset( @@ -327,18 +327,12 @@ void SyncManagerImpl::Init(InitArgs* args) { std::vector listeners; listeners.push_back(&allstatus_); listeners.push_back(this); - session_context_ = - args->internal_components_factory->BuildContext( - connection_manager_.get(), - directory(), - args->extensions_activity, - listeners, - &debug_info_event_listener_, - model_type_registry_.get(), - args->invalidator_client_id) - .Pass(); + session_context_ = args->internal_components_factory->BuildContext( + connection_manager_.get(), directory(), args->extensions_activity, + listeners, &debug_info_event_listener_, model_type_registry_.get(), + args->invalidator_client_id); scheduler_ = args->internal_components_factory->BuildScheduler( - name_, session_context_.get(), args->cancelation_signal).Pass(); + name_, session_context_.get(), args->cancelation_signal); scheduler_->Start(SyncScheduler::CONFIGURATION_MODE, base::Time()); @@ -917,10 +911,8 @@ void SyncManagerImpl::OnIncomingInvalidation( DCHECK(thread_checker_.CalledOnValidThread()); allstatus_.IncrementNotificationsReceived(); - scheduler_->ScheduleInvalidationNudge( - type, - invalidation.Pass(), - FROM_HERE); + scheduler_->ScheduleInvalidationNudge(type, std::move(invalidation), + FROM_HERE); } void SyncManagerImpl::RefreshTypes(ModelTypeSet types) { diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc index f231757..ee72254 100644 --- a/sync/internal_api/sync_manager_impl_unittest.cc +++ b/sync/internal_api/sync_manager_impl_unittest.cc @@ -6,10 +6,12 @@ // functionality is provided by the Syncable layer, which has its own // unit tests. We'll test SyncApi specific things in this harness. -#include +#include "sync/internal_api/sync_manager_impl.h" +#include #include #include +#include #include "base/callback.h" #include "base/compiler_specific.h" @@ -42,7 +44,6 @@ #include "sync/internal_api/public/write_node.h" #include "sync/internal_api/public/write_transaction.h" #include "sync/internal_api/sync_encryption_handler_impl.h" -#include "sync/internal_api/sync_manager_impl.h" #include "sync/internal_api/syncapi_internal.h" #include "sync/js/js_backend.h" #include "sync/js/js_event_handler.h" @@ -2549,7 +2550,7 @@ class ComponentsFactory : public TestInternalComponentsFactory { sessions::SyncSessionContext* context, CancelationSignal* stop_handle) override { *session_context_ = context; - return scheduler_to_use_.Pass(); + return std::move(scheduler_to_use_); } private: diff --git a/sync/internal_api/sync_rollback_manager_base.cc b/sync/internal_api/sync_rollback_manager_base.cc index 3ec3005..d62f354 100644 --- a/sync/internal_api/sync_rollback_manager_base.cc +++ b/sync/internal_api/sync_rollback_manager_base.cc @@ -218,7 +218,7 @@ syncer_v2::SyncContextProxy* SyncRollbackManagerBase::GetSyncContextProxy() { ScopedVector SyncRollbackManagerBase::GetBufferedProtocolEvents() { - return ScopedVector().Pass(); + return ScopedVector(); } scoped_ptr SyncRollbackManagerBase::GetAllNodesForType( @@ -227,7 +227,7 @@ scoped_ptr SyncRollbackManagerBase::GetAllNodesForType( scoped_ptr nodes( trans.GetDirectory()->GetNodeDetailsForType(trans.GetWrappedTrans(), type)); - return nodes.Pass(); + return nodes; } bool SyncRollbackManagerBase::InitBackupDB( @@ -237,8 +237,8 @@ bool SyncRollbackManagerBase::InitBackupDB( base::FilePath backup_db_path = sync_folder.Append( syncable::Directory::kSyncDatabaseFilename); scoped_ptr backing_store = - internal_components_factory->BuildDirectoryBackingStore( - storage, "backup", backup_db_path).Pass(); + internal_components_factory->BuildDirectoryBackingStore(storage, "backup", + backup_db_path); DCHECK(backing_store.get()); share_.directory.reset( -- cgit v1.1