summaryrefslogtreecommitdiffstats
path: root/content/browser/background_sync
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser/background_sync')
-rw-r--r--content/browser/background_sync/background_sync_context_impl.cc4
-rw-r--r--content/browser/background_sync/background_sync_manager.cc51
-rw-r--r--content/browser/background_sync/background_sync_manager.h2
-rw-r--r--content/browser/background_sync/background_sync_manager_unittest.cc17
-rw-r--r--content/browser/background_sync/background_sync_service_impl.cc12
-rw-r--r--content/browser/background_sync/background_sync_service_impl_unittest.cc5
6 files changed, 48 insertions, 43 deletions
diff --git a/content/browser/background_sync/background_sync_context_impl.cc b/content/browser/background_sync/background_sync_context_impl.cc
index 4e55d83..009e886 100644
--- a/content/browser/background_sync/background_sync_context_impl.cc
+++ b/content/browser/background_sync/background_sync_context_impl.cc
@@ -4,6 +4,8 @@
#include "content/browser/background_sync/background_sync_context_impl.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/stl_util.h"
#include "content/browser/background_sync/background_sync_manager.h"
@@ -78,7 +80,7 @@ void BackgroundSyncContextImpl::CreateServiceOnIOThread(
mojo::InterfaceRequest<BackgroundSyncService> request) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(background_sync_manager_);
- services_.insert(new BackgroundSyncServiceImpl(this, request.Pass()));
+ services_.insert(new BackgroundSyncServiceImpl(this, std::move(request)));
}
void BackgroundSyncContextImpl::ShutdownOnIO() {
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc
index d5e86a5..327802d 100644
--- a/content/browser/background_sync/background_sync_manager.cc
+++ b/content/browser/background_sync/background_sync_manager.cc
@@ -4,6 +4,8 @@
#include "content/browser/background_sync/background_sync_manager.h"
+#include <utility>
+
#include "base/barrier_closure.h"
#include "base/bind.h"
#include "base/location.h"
@@ -56,9 +58,8 @@ void PostErrorResponse(
const BackgroundSyncManager::StatusAndRegistrationCallback& callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(
- callback, status,
- base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>().Pass())));
+ base::Bind(callback, status,
+ base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>())));
}
// Returns nullptr if the controller cannot be accessed for any reason.
@@ -114,11 +115,11 @@ scoped_ptr<BackgroundSyncParameters> GetControllerParameters(
if (!background_sync_controller) {
// Return default ParameterOverrides which don't disable and don't override.
- return parameters.Pass();
+ return parameters;
}
background_sync_controller->GetParameterOverrides(parameters.get());
- return parameters.Pass();
+ return parameters;
}
} // namespace
@@ -227,8 +228,7 @@ void BackgroundSyncManager::GetRegistrations(
callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR,
base::Passed(
scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>(
- new ScopedVector<BackgroundSyncRegistrationHandle>())
- .Pass())));
+ new ScopedVector<BackgroundSyncRegistrationHandle>()))));
return;
}
@@ -326,7 +326,7 @@ void BackgroundSyncManager::InitImpl(const base::Closure& callback) {
BrowserThread::PostTaskAndReplyWithResult(
BrowserThread::UI, FROM_HERE,
base::Bind(&GetControllerParameters, service_worker_context_,
- base::Passed(parameters_copy.Pass())),
+ base::Passed(std::move(parameters_copy))),
base::Bind(&BackgroundSyncManager::InitDidGetControllerParameters,
weak_ptr_factory_.GetWeakPtr(), callback));
}
@@ -336,7 +336,7 @@ void BackgroundSyncManager::InitDidGetControllerParameters(
scoped_ptr<BackgroundSyncParameters> updated_parameters) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- parameters_ = updated_parameters.Pass();
+ parameters_ = std::move(updated_parameters);
if (parameters_->disable) {
disabled_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
@@ -516,8 +516,7 @@ void BackgroundSyncManager::RegisterImpl(
FROM_HERE,
base::Bind(
callback, BACKGROUND_SYNC_STATUS_OK,
- base::Passed(
- CreateRegistrationHandle(existing_registration_ref).Pass())));
+ base::Passed(CreateRegistrationHandle(existing_registration_ref))));
return;
} else {
existing_registration_ref->value()->SetUnregisteredState();
@@ -697,7 +696,7 @@ void BackgroundSyncManager::RegisterDidStore(
BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
DisableAndClearManager(base::Bind(
callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR,
- base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>().Pass())));
+ base::Passed(scoped_ptr<BackgroundSyncRegistrationHandle>())));
return;
}
@@ -714,8 +713,7 @@ void BackgroundSyncManager::RegisterDidStore(
FROM_HERE,
base::Bind(
callback, BACKGROUND_SYNC_STATUS_OK,
- base::Passed(
- CreateRegistrationHandle(new_registration_ref.get()).Pass())));
+ base::Passed(CreateRegistrationHandle(new_registration_ref.get()))));
}
void BackgroundSyncManager::RemoveActiveRegistration(
@@ -941,7 +939,7 @@ void BackgroundSyncManager::NotifyWhenFinished(
op_scheduler_.ScheduleOperation(
base::Bind(&BackgroundSyncManager::NotifyWhenFinishedImpl,
weak_ptr_factory_.GetWeakPtr(),
- base::Passed(registration_handle.Pass()), callback));
+ base::Passed(std::move(registration_handle)), callback));
}
void BackgroundSyncManager::NotifyWhenFinishedImpl(
@@ -1000,7 +998,7 @@ void BackgroundSyncManager::GetRegistrationImpl(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(callback, BACKGROUND_SYNC_STATUS_OK,
- base::Passed(CreateRegistrationHandle(registration).Pass())));
+ base::Passed(CreateRegistrationHandle(registration))));
}
void BackgroundSyncManager::GetRegistrationsImpl(
@@ -1015,7 +1013,7 @@ void BackgroundSyncManager::GetRegistrationsImpl(
if (disabled_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR,
- base::Passed(out_registrations.Pass())));
+ base::Passed(std::move(out_registrations))));
return;
}
@@ -1035,7 +1033,7 @@ void BackgroundSyncManager::GetRegistrationsImpl(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_OK,
- base::Passed(out_registrations.Pass())));
+ base::Passed(std::move(out_registrations))));
}
bool BackgroundSyncManager::AreOptionConditionsMet(
@@ -1237,10 +1235,11 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration(
FireOneShotSync(
handle_id, service_worker_registration->active_version(), last_chance,
- base::Bind(
- &BackgroundSyncManager::EventComplete, weak_ptr_factory_.GetWeakPtr(),
- service_worker_registration, service_worker_registration->id(),
- base::Passed(registration_handle.Pass()), event_completed_callback));
+ base::Bind(&BackgroundSyncManager::EventComplete,
+ weak_ptr_factory_.GetWeakPtr(), service_worker_registration,
+ service_worker_registration->id(),
+ base::Passed(std::move(registration_handle)),
+ event_completed_callback));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(event_fired_callback));
@@ -1269,8 +1268,8 @@ void BackgroundSyncManager::EventComplete(
// be allowed to complete (for NotifyWhenFinished).
op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::EventCompleteImpl, weak_ptr_factory_.GetWeakPtr(),
- service_worker_id, base::Passed(registration_handle.Pass()), status_code,
- MakeClosureCompletion(callback)));
+ service_worker_id, base::Passed(std::move(registration_handle)),
+ status_code, MakeClosureCompletion(callback)));
}
void BackgroundSyncManager::EventCompleteImpl(
@@ -1442,7 +1441,7 @@ void BackgroundSyncManager::CompleteStatusAndRegistrationCallback(
scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback.Run(status, registration_handle.Pass());
+ callback.Run(status, std::move(registration_handle));
op_scheduler_.CompleteOperationAndRunNext();
}
@@ -1453,7 +1452,7 @@ void BackgroundSyncManager::CompleteStatusAndRegistrationsCallback(
registration_handles) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback.Run(status, registration_handles.Pass());
+ callback.Run(status, std::move(registration_handles));
op_scheduler_.CompleteOperationAndRunNext();
}
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h
index 7b12f6c..5a88d1e 100644
--- a/content/browser/background_sync/background_sync_manager.h
+++ b/content/browser/background_sync/background_sync_manager.h
@@ -111,7 +111,7 @@ class CONTENT_EXPORT BackgroundSyncManager
void set_clock(scoped_ptr<base::Clock> clock) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- clock_ = clock.Pass();
+ clock_ = std::move(clock);
}
void set_max_sync_attempts(int max_attempts) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc
index 1bd17d6..de8b956 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/background_sync/background_sync_manager.h"
#include <stdint.h>
+#include <utility>
#include "base/files/scoped_temp_dir.h"
#include "base/location.h"
@@ -340,7 +341,7 @@ class BackgroundSyncManagerTest : public testing::Test {
new TestBackgroundSyncController());
test_controller_ = background_sync_controller.get();
helper_->browser_context()->SetBackgroundSyncController(
- background_sync_controller.Pass());
+ std::move(background_sync_controller));
SetMaxSyncAttemptsAndRestartManager(1);
@@ -408,7 +409,7 @@ class BackgroundSyncManagerTest : public testing::Test {
scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle) {
*was_called = true;
callback_status_ = status;
- callback_registration_handle_ = registration_handle.Pass();
+ callback_registration_handle_ = std::move(registration_handle);
}
void StatusAndRegistrationsCallback(
@@ -418,7 +419,7 @@ class BackgroundSyncManagerTest : public testing::Test {
registration_handles) {
*was_called = true;
callback_status_ = status;
- callback_registration_handles_ = registration_handles.Pass();
+ callback_registration_handles_ = std::move(registration_handles);
}
void StatusCallback(bool* was_called, BackgroundSyncStatus status) {
@@ -721,7 +722,7 @@ TEST_F(BackgroundSyncManagerTest, RegisterWithoutActiveSWRegistration) {
TEST_F(BackgroundSyncManagerTest, RegisterOverwrites) {
EXPECT_TRUE(Register(sync_options_1_));
scoped_ptr<BackgroundSyncRegistrationHandle> first_registration_handle =
- callback_registration_handle_.Pass();
+ std::move(callback_registration_handle_);
sync_options_1_.min_period = 100;
EXPECT_TRUE(Register(sync_options_1_));
@@ -895,7 +896,7 @@ TEST_F(BackgroundSyncManagerTest, RegisterMaxTagLength) {
TEST_F(BackgroundSyncManagerTest, RegistrationIncreasesId) {
EXPECT_TRUE(Register(sync_options_1_));
scoped_ptr<BackgroundSyncRegistrationHandle> registered_handle =
- callback_registration_handle_.Pass();
+ std::move(callback_registration_handle_);
BackgroundSyncRegistration::RegistrationId cur_id =
registered_handle->handle_id();
@@ -1397,7 +1398,7 @@ TEST_F(BackgroundSyncManagerTest, OverwritePendingRegistration) {
EXPECT_EQ(POWER_STATE_AVOID_DRAINING,
callback_registration_handle_->options()->power_state);
scoped_ptr<BackgroundSyncRegistrationHandle> original_handle =
- callback_registration_handle_.Pass();
+ std::move(callback_registration_handle_);
// Overwrite the pending registration.
sync_options_1_.power_state = POWER_STATE_AUTO;
@@ -1419,7 +1420,7 @@ TEST_F(BackgroundSyncManagerTest, OverwriteFiringRegistrationWhichSucceeds) {
sync_options_1_.power_state = POWER_STATE_AVOID_DRAINING;
RegisterAndVerifySyncEventDelayed(sync_options_1_);
scoped_ptr<BackgroundSyncRegistrationHandle> original_handle =
- callback_registration_handle_.Pass();
+ std::move(callback_registration_handle_);
// The next registration won't block.
InitSyncEventTest();
@@ -1443,7 +1444,7 @@ TEST_F(BackgroundSyncManagerTest, OverwriteFiringRegistrationWhichFails) {
sync_options_1_.power_state = POWER_STATE_AVOID_DRAINING;
RegisterAndVerifySyncEventDelayed(sync_options_1_);
scoped_ptr<BackgroundSyncRegistrationHandle> original_handle =
- callback_registration_handle_.Pass();
+ std::move(callback_registration_handle_);
// The next registration won't block.
InitSyncEventTest();
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc
index f90433d..ffab6ab 100644
--- a/content/browser/background_sync/background_sync_service_impl.cc
+++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -4,6 +4,8 @@
#include "content/browser/background_sync/background_sync_service_impl.h"
+#include <utility>
+
#include "background_sync_registration_handle.h"
#include "base/memory/weak_ptr.h"
#include "base/stl_util.h"
@@ -41,7 +43,7 @@ SyncRegistrationPtr ToMojoRegistration(
static_cast<content::BackgroundSyncPowerState>(in.options()->power_state);
out->network_state = static_cast<content::BackgroundSyncNetworkState>(
in.options()->network_state);
- return out.Pass();
+ return out;
}
} // namespace
@@ -97,7 +99,7 @@ BackgroundSyncServiceImpl::BackgroundSyncServiceImpl(
BackgroundSyncContextImpl* background_sync_context,
mojo::InterfaceRequest<BackgroundSyncService> request)
: background_sync_context_(background_sync_context),
- binding_(this, request.Pass()),
+ binding_(this, std::move(request)),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(background_sync_context);
@@ -212,7 +214,7 @@ void BackgroundSyncServiceImpl::DuplicateRegistrationHandle(
active_handles_.AddWithID(registration_handle.release(),
handle_ptr->handle_id());
SyncRegistrationPtr mojoResult = ToMojoRegistration(*handle_ptr);
- callback.Run(BACKGROUND_SYNC_ERROR_NONE, mojoResult.Pass());
+ callback.Run(BACKGROUND_SYNC_ERROR_NONE, std::move(mojoResult));
}
void BackgroundSyncServiceImpl::ReleaseRegistration(
@@ -260,7 +262,7 @@ void BackgroundSyncServiceImpl::OnRegisterResult(
active_handles_.AddWithID(result.release(), result_ptr->handle_id());
SyncRegistrationPtr mojoResult = ToMojoRegistration(*result_ptr);
callback.Run(static_cast<content::BackgroundSyncError>(status),
- mojoResult.Pass());
+ std::move(mojoResult));
}
void BackgroundSyncServiceImpl::OnUnregisterResult(
@@ -287,7 +289,7 @@ void BackgroundSyncServiceImpl::OnGetRegistrationsResult(
result_registrations->weak_clear();
callback.Run(static_cast<content::BackgroundSyncError>(status),
- mojo_registrations.Pass());
+ std::move(mojo_registrations));
}
void BackgroundSyncServiceImpl::OnNotifyWhenFinishedResult(
diff --git a/content/browser/background_sync/background_sync_service_impl_unittest.cc b/content/browser/background_sync/background_sync_service_impl_unittest.cc
index 306bbe5..7d7b3ed 100644
--- a/content/browser/background_sync/background_sync_service_impl_unittest.cc
+++ b/content/browser/background_sync/background_sync_service_impl_unittest.cc
@@ -5,6 +5,7 @@
#include "content/browser/background_sync/background_sync_service_impl.h"
#include <stdint.h>
+#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -179,7 +180,7 @@ class BackgroundSyncServiceImplTest : public testing::Test {
mojo::InterfaceRequest<BackgroundSyncService> service_request =
mojo::GetProxy(&service_ptr_);
// Create a new BackgroundSyncServiceImpl bound to the dummy channel
- background_sync_context_->CreateService(service_request.Pass());
+ background_sync_context_->CreateService(std::move(service_request));
base::RunLoop().RunUntilIdle();
service_impl_ = *background_sync_context_->services_.begin();
@@ -190,7 +191,7 @@ class BackgroundSyncServiceImplTest : public testing::Test {
void RegisterOneShot(
SyncRegistrationPtr sync,
const BackgroundSyncService::RegisterCallback& callback) {
- service_impl_->Register(sync.Pass(), sw_registration_id_,
+ service_impl_->Register(std::move(sync), sw_registration_id_,
false /* requested_from_service_worker */,
callback);
base::RunLoop().RunUntilIdle();