summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkarlin <jkarlin@chromium.org>2016-01-25 12:50:53 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-25 20:52:19 +0000
commit323a239968fdbfb6e86247cdc2f536e8bdaf0e78 (patch)
tree3af97f4c0ac5aa99ec45983b53853c77e58b7c24
parent5304861eecb984ff17e28759c60d9f210fa6c557 (diff)
downloadchromium_src-323a239968fdbfb6e86247cdc2f536e8bdaf0e78.zip
chromium_src-323a239968fdbfb6e86247cdc2f536e8bdaf0e78.tar.gz
chromium_src-323a239968fdbfb6e86247cdc2f536e8bdaf0e78.tar.bz2
[BackgroundSync Cleanup] Remove periodic sync code
Remove periodic information from structs, protobufs, methods, and histograms. There are still functions with names like "FireOneShot" as opposed to just "Fire." If those are renamed, it will be in a followup. * Remove power monitor: https://codereview.chromium.org/1617063002/ * Remove periodic code: https://codereview.chromium.org/1614063002/ * Remove mention of one-shot: https://codereview.chromium.org/1613053004/ BUG=552031 Review URL: https://codereview.chromium.org/1614063002 Cr-Commit-Position: refs/heads/master@{#371307}
-rw-r--r--content/browser/background_sync/background_sync.proto9
-rw-r--r--content/browser/background_sync/background_sync_browsertest.cc2
-rw-r--r--content/browser/background_sync/background_sync_manager.cc171
-rw-r--r--content/browser/background_sync/background_sync_manager.h35
-rw-r--r--content/browser/background_sync/background_sync_manager_unittest.cc132
-rw-r--r--content/browser/background_sync/background_sync_metrics.cc102
-rw-r--r--content/browser/background_sync/background_sync_metrics.h14
-rw-r--r--content/browser/background_sync/background_sync_registration_handle.h3
-rw-r--r--content/browser/background_sync/background_sync_registration_options.cc4
-rw-r--r--content/browser/background_sync/background_sync_registration_options.h2
-rw-r--r--content/browser/background_sync/background_sync_service_impl.cc20
-rw-r--r--content/browser/background_sync/background_sync_service_impl.h7
-rw-r--r--content/browser/background_sync/background_sync_service_impl_unittest.cc6
-rw-r--r--content/child/background_sync/background_sync_provider.cc8
-rw-r--r--content/child/background_sync/background_sync_provider.h15
-rw-r--r--content/child/background_sync/background_sync_type_converters.cc30
-rw-r--r--content/child/background_sync/background_sync_type_converters.h17
-rw-r--r--content/child/background_sync/background_sync_type_converters_unittest.cc65
-rw-r--r--content/common/background_sync_service.mojom9
-rw-r--r--content/public/common/background_sync.mojom8
-rw-r--r--third_party/WebKit/Source/modules/background_sync/ServiceWorkerGlobalScopeSync.h1
-rw-r--r--third_party/WebKit/Source/modules/background_sync/SyncManager.cpp4
-rw-r--r--third_party/WebKit/Source/modules/background_sync/SyncManager.h2
-rw-r--r--third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h6
-rw-r--r--third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h26
-rw-r--r--tools/metrics/histograms/histograms.xml21
26 files changed, 170 insertions, 549 deletions
diff --git a/content/browser/background_sync/background_sync.proto b/content/browser/background_sync/background_sync.proto
index c6b4045..62dbe72 100644
--- a/content/browser/background_sync/background_sync.proto
+++ b/content/browser/background_sync/background_sync.proto
@@ -14,16 +14,11 @@ enum SyncNetworkState {
NETWORK_STATE_ONLINE = 2;
}
-enum SyncPeriodicity {
- SYNC_PERIODIC = 0;
- SYNC_ONE_SHOT = 1;
-}
-
message BackgroundSyncRegistrationProto {
required int64 id = 1;
required string tag = 2;
- required SyncPeriodicity periodicity = 3;
- required int64 min_period = 4;
+ // required SyncPeriodicity periodicity = 3;
+ // required int64 min_period = 4;
required SyncNetworkState network_state = 5;
// required SyncPowerState power_state = 6;
required int32 num_attempts = 7;
diff --git a/content/browser/background_sync/background_sync_browsertest.cc b/content/browser/background_sync/background_sync_browsertest.cc
index 3205c75..0821020 100644
--- a/content/browser/background_sync/background_sync_browsertest.cc
+++ b/content/browser/background_sync/background_sync_browsertest.cc
@@ -85,7 +85,7 @@ void OneShotPendingDidGetSWRegistration(
int64_t service_worker_id = registration->id();
BackgroundSyncManager* sync_manager = sync_context->background_sync_manager();
sync_manager->GetRegistration(
- service_worker_id, tag, SYNC_ONE_SHOT,
+ service_worker_id, tag,
base::Bind(&OneShotPendingDidGetSyncRegistration, callback));
}
diff --git a/content/browser/background_sync/background_sync_manager.cc b/content/browser/background_sync/background_sync_manager.cc
index 4cc12bc..002b681 100644
--- a/content/browser/background_sync/background_sync_manager.cc
+++ b/content/browser/background_sync/background_sync_manager.cc
@@ -161,19 +161,17 @@ BackgroundSyncManager::~BackgroundSyncManager() {
BackgroundSyncManager::RegistrationKey::RegistrationKey(
const BackgroundSyncRegistration& registration)
- : RegistrationKey(registration.options()->tag,
- registration.options()->periodicity) {
-}
+ : RegistrationKey(registration.options()->tag) {}
BackgroundSyncManager::RegistrationKey::RegistrationKey(
const BackgroundSyncRegistrationOptions& options)
- : RegistrationKey(options.tag, options.periodicity) {
-}
+ : RegistrationKey(options.tag) {}
-BackgroundSyncManager::RegistrationKey::RegistrationKey(
- const std::string& tag,
- SyncPeriodicity periodicity)
- : value_(periodicity == SYNC_ONE_SHOT ? "o_" + tag : "p_" + tag) {
+BackgroundSyncManager::RegistrationKey::RegistrationKey(const std::string& tag)
+ : value_("o_" + tag) {
+ // Note that the "o_" prefix on the key is because at one time one-shots were
+ // prefixed with an "o_" and periodic with a "p_". Removing the "o_" requires
+ // migration.
}
void BackgroundSyncManager::Register(
@@ -185,7 +183,7 @@ void BackgroundSyncManager::Register(
if (disabled_) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
+ BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
PostErrorResponse(BACKGROUND_SYNC_STATUS_STORAGE_ERROR, callback);
return;
}
@@ -207,7 +205,6 @@ void BackgroundSyncManager::Register(
void BackgroundSyncManager::GetRegistration(
int64_t sw_registration_id,
const std::string& sync_registration_tag,
- SyncPeriodicity periodicity,
const StatusAndRegistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -216,7 +213,7 @@ void BackgroundSyncManager::GetRegistration(
return;
}
- RegistrationKey registration_key(sync_registration_tag, periodicity);
+ RegistrationKey registration_key(sync_registration_tag);
op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::GetRegistrationImpl,
@@ -226,7 +223,6 @@ void BackgroundSyncManager::GetRegistration(
void BackgroundSyncManager::GetRegistrations(
int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusAndRegistrationsCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -244,7 +240,7 @@ void BackgroundSyncManager::GetRegistrations(
op_scheduler_.ScheduleOperation(
base::Bind(&BackgroundSyncManager::GetRegistrationsImpl,
weak_ptr_factory_.GetWeakPtr(), sw_registration_id,
- periodicity, MakeStatusAndRegistrationsCompletion(callback)));
+ MakeStatusAndRegistrationsCompletion(callback)));
}
// Given a HandleId |handle_id|, return a new handle for the same
@@ -395,8 +391,7 @@ void BackgroundSyncManager::InitDidGetDataFromBackend(
break;
}
- RegistrationKey registration_key(registration_proto.tag(),
- registration_proto.periodicity());
+ RegistrationKey registration_key(registration_proto.tag());
scoped_refptr<RefCountedRegistration> ref_registration(
new RefCountedRegistration());
@@ -405,8 +400,6 @@ void BackgroundSyncManager::InitDidGetDataFromBackend(
BackgroundSyncRegistrationOptions* options = registration->options();
options->tag = registration_proto.tag();
- options->periodicity = registration_proto.periodicity();
- options->min_period = registration_proto.min_period();
options->network_state = registration_proto.network_state();
registration->set_id(registration_proto.id());
@@ -442,7 +435,7 @@ void BackgroundSyncManager::RegisterCheckIfHasMainFrame(
service_worker_context_->GetLiveRegistration(sw_registration_id);
if (!sw_registration || !sw_registration->active_version()) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER);
+ BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER);
PostErrorResponse(BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER, callback);
return;
}
@@ -463,7 +456,7 @@ void BackgroundSyncManager::RegisterDidCheckIfMainFrame(
if (!has_main_frame_client) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_NOT_ALLOWED);
+ BACKGROUND_SYNC_STATUS_NOT_ALLOWED);
PostErrorResponse(BACKGROUND_SYNC_STATUS_NOT_ALLOWED, callback);
return;
}
@@ -478,14 +471,14 @@ void BackgroundSyncManager::RegisterImpl(
if (disabled_) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
+ BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
PostErrorResponse(BACKGROUND_SYNC_STATUS_STORAGE_ERROR, callback);
return;
}
if (options.tag.length() > kMaxTagLength) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_NOT_ALLOWED);
+ BACKGROUND_SYNC_STATUS_NOT_ALLOWED);
PostErrorResponse(BACKGROUND_SYNC_STATUS_NOT_ALLOWED, callback);
return;
}
@@ -494,7 +487,7 @@ void BackgroundSyncManager::RegisterImpl(
service_worker_context_->GetLiveRegistration(sw_registration_id);
if (!sw_registration || !sw_registration->active_version()) {
BackgroundSyncMetrics::CountRegisterFailure(
- options.periodicity, BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER);
+ BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER);
PostErrorResponse(BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER, callback);
return;
}
@@ -516,7 +509,6 @@ void BackgroundSyncManager::RegisterImpl(
? BackgroundSyncMetrics::REGISTRATION_COULD_FIRE
: BackgroundSyncMetrics::REGISTRATION_COULD_NOT_FIRE;
BackgroundSyncMetrics::CountRegisterSuccess(
- existing_registration->options()->periodicity,
registration_could_fire,
BackgroundSyncMetrics::REGISTRATION_IS_DUPLICATE);
@@ -664,8 +656,6 @@ void BackgroundSyncManager::StoreRegistrations(
registrations_proto.add_registration();
registration_proto->set_id(registration.id());
registration_proto->set_tag(registration.options()->tag);
- registration_proto->set_periodicity(registration.options()->periodicity);
- registration_proto->set_min_period(registration.options()->min_period);
registration_proto->set_network_state(
registration.options()->network_state);
registration_proto->set_num_attempts(registration.num_attempts());
@@ -693,7 +683,6 @@ void BackgroundSyncManager::RegisterDidStore(
if (status == SERVICE_WORKER_ERROR_NOT_FOUND) {
// The service worker registration is gone.
BackgroundSyncMetrics::CountRegisterFailure(
- new_registration->options()->periodicity,
BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
active_registrations_.erase(sw_registration_id);
PostErrorResponse(BACKGROUND_SYNC_STATUS_STORAGE_ERROR, callback);
@@ -704,7 +693,6 @@ void BackgroundSyncManager::RegisterDidStore(
LOG(ERROR) << "BackgroundSync failed to store registration due to backend "
"failure.";
BackgroundSyncMetrics::CountRegisterFailure(
- new_registration->options()->periodicity,
BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
DisableAndClearManager(base::Bind(
callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR,
@@ -717,7 +705,7 @@ void BackgroundSyncManager::RegisterDidStore(
? BackgroundSyncMetrics::REGISTRATION_COULD_FIRE
: BackgroundSyncMetrics::REGISTRATION_COULD_NOT_FIRE;
BackgroundSyncMetrics::CountRegisterSuccess(
- new_registration->options()->periodicity, registration_could_fire,
+ registration_could_fire,
BackgroundSyncMetrics::REGISTRATION_IS_NOT_DUPLICATE);
FireReadyEvents();
@@ -868,7 +856,6 @@ void BackgroundSyncManager::Unregister(
if (disabled_) {
BackgroundSyncMetrics::CountUnregister(
- registration->options()->periodicity,
BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR));
@@ -878,20 +865,19 @@ void BackgroundSyncManager::Unregister(
op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::UnregisterImpl, weak_ptr_factory_.GetWeakPtr(),
sw_registration_id, RegistrationKey(*registration), registration->id(),
- registration->options()->periodicity, MakeStatusCompletion(callback)));
+ MakeStatusCompletion(callback)));
}
void BackgroundSyncManager::UnregisterImpl(
int64_t sw_registration_id,
const RegistrationKey& registration_key,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
- SyncPeriodicity periodicity,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (disabled_) {
BackgroundSyncMetrics::CountUnregister(
- periodicity, BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
+ BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR));
return;
@@ -902,8 +888,7 @@ void BackgroundSyncManager::UnregisterImpl(
if (!existing_registration ||
existing_registration->value()->id() != sync_registration_id) {
- BackgroundSyncMetrics::CountUnregister(periodicity,
- BACKGROUND_SYNC_STATUS_NOT_FOUND);
+ BackgroundSyncMetrics::CountUnregister(BACKGROUND_SYNC_STATUS_NOT_FOUND);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_NOT_FOUND));
return;
@@ -913,14 +898,13 @@ void BackgroundSyncManager::UnregisterImpl(
RemoveActiveRegistration(sw_registration_id, registration_key);
- StoreRegistrations(sw_registration_id,
- base::Bind(&BackgroundSyncManager::UnregisterDidStore,
- weak_ptr_factory_.GetWeakPtr(),
- sw_registration_id, periodicity, callback));
+ StoreRegistrations(
+ sw_registration_id,
+ base::Bind(&BackgroundSyncManager::UnregisterDidStore,
+ weak_ptr_factory_.GetWeakPtr(), sw_registration_id, callback));
}
void BackgroundSyncManager::UnregisterDidStore(int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusCallback& callback,
ServiceWorkerStatusCode status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -928,7 +912,7 @@ void BackgroundSyncManager::UnregisterDidStore(int64_t sw_registration_id,
if (status == SERVICE_WORKER_ERROR_NOT_FOUND) {
// ServiceWorker was unregistered.
BackgroundSyncMetrics::CountUnregister(
- periodicity, BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
+ BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
active_registrations_.erase(sw_registration_id);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR));
@@ -938,14 +922,13 @@ void BackgroundSyncManager::UnregisterDidStore(int64_t sw_registration_id,
if (status != SERVICE_WORKER_OK) {
LOG(ERROR) << "BackgroundSync failed to unregister due to backend failure.";
BackgroundSyncMetrics::CountUnregister(
- periodicity, BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
+ BACKGROUND_SYNC_STATUS_STORAGE_ERROR);
DisableAndClearManager(
base::Bind(callback, BACKGROUND_SYNC_STATUS_STORAGE_ERROR));
return;
}
- BackgroundSyncMetrics::CountUnregister(periodicity,
- BACKGROUND_SYNC_STATUS_OK);
+ BackgroundSyncMetrics::CountUnregister(BACKGROUND_SYNC_STATUS_OK);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, BACKGROUND_SYNC_STATUS_OK));
}
@@ -975,7 +958,6 @@ void BackgroundSyncManager::NotifyWhenFinishedImpl(
scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle,
const StatusAndStateCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK_EQ(SYNC_ONE_SHOT, registration_handle->options()->periodicity);
if (disabled_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -1032,7 +1014,6 @@ void BackgroundSyncManager::GetRegistrationImpl(
void BackgroundSyncManager::GetRegistrationsImpl(
int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusAndRegistrationsCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -1053,10 +1034,8 @@ void BackgroundSyncManager::GetRegistrationsImpl(
const BackgroundSyncRegistrations& registrations = it->second;
for (const auto& tag_and_registration : registrations.registration_map) {
RefCountedRegistration* registration = tag_and_registration.second.get();
- if (registration->value()->options()->periodicity == periodicity) {
- out_registrations->push_back(
- CreateRegistrationHandle(registration).release());
- }
+ out_registrations->push_back(
+ CreateRegistrationHandle(registration).release());
}
}
@@ -1075,18 +1054,12 @@ bool BackgroundSyncManager::IsRegistrationReadyToFire(
const BackgroundSyncRegistration& registration) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- // TODO(jkarlin): Add support for firing periodic registrations.
- if (registration.options()->periodicity == SYNC_PERIODIC)
- return false;
-
if (registration.sync_state() != BackgroundSyncState::PENDING)
return false;
if (clock_->Now() < registration.delay_until())
return false;
- DCHECK_EQ(SYNC_ONE_SHOT, registration.options()->periodicity);
-
return AreOptionConditionsMet(*registration.options());
}
@@ -1100,18 +1073,13 @@ void BackgroundSyncManager::RunInBackgroundIfNecessary() {
const BackgroundSyncRegistration& registration =
*key_and_registration.second->value();
if (registration.sync_state() == BackgroundSyncState::PENDING) {
- if (registration.options()->periodicity == SYNC_ONE_SHOT) {
- if (clock_->Now() >= registration.delay_until()) {
- soonest_wakeup_delta = base::TimeDelta();
- } else {
- base::TimeDelta delay_delta =
- registration.delay_until() - clock_->Now();
- if (delay_delta < soonest_wakeup_delta)
- soonest_wakeup_delta = delay_delta;
- }
+ if (clock_->Now() >= registration.delay_until()) {
+ soonest_wakeup_delta = base::TimeDelta();
} else {
- // TODO(jkarlin): Support keeping the browser alive for periodic
- // syncs.
+ base::TimeDelta delay_delta =
+ registration.delay_until() - clock_->Now();
+ if (delay_delta < soonest_wakeup_delta)
+ soonest_wakeup_delta = delay_delta;
}
}
}
@@ -1258,8 +1226,7 @@ void BackgroundSyncManager::FireReadyEventsDidFindRegistration(
HasMainFrameProviderHost(
service_worker_registration->pattern().GetOrigin(),
- base::Bind(&BackgroundSyncMetrics::RecordEventStarted,
- registration->value()->options()->periodicity));
+ base::Bind(&BackgroundSyncMetrics::RecordEventStarted));
FireOneShotSync(
handle_id, service_worker_registration->active_version(), last_chance,
@@ -1324,52 +1291,44 @@ void BackgroundSyncManager::EventCompleteImpl(
HasMainFrameProviderHost(
sw_registration->pattern().GetOrigin(),
base::Bind(&BackgroundSyncMetrics::RecordEventResult,
- registration->options()->periodicity,
status_code == SERVICE_WORKER_OK));
}
- if (registration->options()->periodicity == SYNC_ONE_SHOT) {
+ if (registration->sync_state() ==
+ BackgroundSyncState::REREGISTERED_WHILE_FIRING) {
+ registration->set_sync_state(BackgroundSyncState::PENDING);
+ registration->set_num_attempts(0);
+ } else if (status_code != SERVICE_WORKER_OK) { // Sync failed
+ bool can_retry =
+ registration->num_attempts() < parameters_->max_sync_attempts;
if (registration->sync_state() ==
- BackgroundSyncState::REREGISTERED_WHILE_FIRING) {
+ BackgroundSyncState::UNREGISTERED_WHILE_FIRING) {
+ registration->set_sync_state(can_retry ? BackgroundSyncState::UNREGISTERED
+ : BackgroundSyncState::FAILED);
+ registration->RunFinishedCallbacks();
+ } else if (can_retry) {
registration->set_sync_state(BackgroundSyncState::PENDING);
- registration->set_num_attempts(0);
- } else if (status_code != SERVICE_WORKER_OK) { // Sync failed
- bool can_retry =
- registration->num_attempts() < parameters_->max_sync_attempts;
- if (registration->sync_state() ==
- BackgroundSyncState::UNREGISTERED_WHILE_FIRING) {
- registration->set_sync_state(can_retry
- ? BackgroundSyncState::UNREGISTERED
- : BackgroundSyncState::FAILED);
- registration->RunFinishedCallbacks();
- } else if (can_retry) {
- registration->set_sync_state(BackgroundSyncState::PENDING);
- registration->set_delay_until(
- clock_->Now() +
- parameters_->initial_retry_delay *
- pow(parameters_->retry_delay_factor,
- registration->num_attempts() - 1));
- } else {
- registration->set_sync_state(BackgroundSyncState::FAILED);
- registration->RunFinishedCallbacks();
- }
- } else { // Sync succeeded
- registration->set_sync_state(BackgroundSyncState::SUCCESS);
+ registration->set_delay_until(clock_->Now() +
+ parameters_->initial_retry_delay *
+ pow(parameters_->retry_delay_factor,
+ registration->num_attempts() - 1));
+ } else {
+ registration->set_sync_state(BackgroundSyncState::FAILED);
registration->RunFinishedCallbacks();
}
+ } else { // Sync succeeded
+ registration->set_sync_state(BackgroundSyncState::SUCCESS);
+ registration->RunFinishedCallbacks();
+ }
- if (registration->HasCompleted()) {
- RegistrationKey key(*registration);
- RefCountedRegistration* active_registration =
- LookupActiveRegistration(service_worker_id, key);
- if (active_registration &&
- active_registration->value()->id() == registration->id()) {
- RemoveActiveRegistration(service_worker_id, key);
- }
+ if (registration->HasCompleted()) {
+ RegistrationKey key(*registration);
+ RefCountedRegistration* active_registration =
+ LookupActiveRegistration(service_worker_id, key);
+ if (active_registration &&
+ active_registration->value()->id() == registration->id()) {
+ RemoveActiveRegistration(service_worker_id, key);
}
- } else { // !SYNC_ONE_SHOT
- // TODO(jkarlin): Add support for running periodic syncs. (crbug.com/479674)
- NOTREACHED();
}
if (disabled_) {
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h
index 5f1c762..8d92f80 100644
--- a/content/browser/background_sync/background_sync_manager.h
+++ b/content/browser/background_sync/background_sync_manager.h
@@ -64,9 +64,9 @@ class CONTENT_EXPORT BackgroundSyncManager
~BackgroundSyncManager() override;
// Stores the given background sync registration and adds it to the scheduling
- // queue. It will overwrite an existing registration with the same tag and
- // periodicity unless they're identical (save for the id). Calls |callback|
- // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success.
+ // queue. It will overwrite an existing registration with the same tag unless
+ // they're identical (save for the id). Calls |callback| with
+ // BACKGROUND_SYNC_STATUS_OK and the accepted registration on success.
// The accepted registration will have a unique id. It may also have altered
// parameters if the user or UA chose different parameters than those
// supplied.
@@ -76,22 +76,19 @@ class CONTENT_EXPORT BackgroundSyncManager
const StatusAndRegistrationCallback& callback);
// Finds the background sync registration associated with
- // |sw_registration_id|, periodicity |periodicity|, and tag
- // |sync_registration_tag|. Calls |callback| with
- // BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback| with
- // BACKGROUND_SYNC_STATUS_OK on success. If the callback's status
- // is not BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle
- // will be nullptr.
+ // |sw_registration_id|, and tag |sync_registration_tag|. Calls |callback|
+ // with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback|
+ // with BACKGROUND_SYNC_STATUS_OK on success. If the callback's status is not
+ // BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle will be
+ // nullptr.
void GetRegistration(int64_t sw_registration_id,
const std::string& sync_registration_tag,
- SyncPeriodicity periodicity,
const StatusAndRegistrationCallback& callback);
// Finds the background sync registrations associated with
- // |sw_registration_id| and periodicity |periodicity|. Calls
- // |callback| with BACKGROUND_SYNC_STATUS_OK on success.
+ // |sw_registration_id|. Calls |callback| with BACKGROUND_SYNC_STATUS_OK on
+ // success.
void GetRegistrations(int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusAndRegistrationsCallback& callback);
// Given a HandleId |handle_id|, return a new handle for the same
@@ -162,7 +159,7 @@ class CONTENT_EXPORT BackgroundSyncManager
public:
explicit RegistrationKey(const BackgroundSyncRegistration& registration);
explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options);
- RegistrationKey(const std::string& tag, SyncPeriodicity periodicity);
+ RegistrationKey(const std::string& tag);
RegistrationKey(const RegistrationKey& other) = default;
RegistrationKey& operator=(const RegistrationKey& other) = default;
@@ -266,10 +263,9 @@ class CONTENT_EXPORT BackgroundSyncManager
const StatusAndRegistrationCallback& callback,
ServiceWorkerStatusCode status);
- // Removes the background sync with periodicity |periodicity| and id
- // |sync_registration_id|. Calls |callback| with
- // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback|
- // with BACKGROUND_SYNC_STATUS_OK on success.
+ // Removes the background sync with id |sync_registration_id|. Calls
+ // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found.
+ // Calls |callback| with BACKGROUND_SYNC_STATUS_OK on success.
void Unregister(int64_t sw_registration_id,
BackgroundSyncRegistrationHandle::HandleId handle_id,
const StatusCallback& callback);
@@ -277,10 +273,8 @@ class CONTENT_EXPORT BackgroundSyncManager
int64_t sw_registration_id,
const RegistrationKey& key,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
- SyncPeriodicity periodicity,
const StatusCallback& callback);
void UnregisterDidStore(int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusCallback& callback,
ServiceWorkerStatusCode status);
@@ -302,7 +296,6 @@ class CONTENT_EXPORT BackgroundSyncManager
// GetRegistrations callbacks
void GetRegistrationsImpl(int64_t sw_registration_id,
- SyncPeriodicity periodicity,
const StatusAndRegistrationsCallback& callback);
bool AreOptionConditionsMet(const BackgroundSyncRegistrationOptions& options);
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc
index 4b138e8..52c827a 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -288,11 +288,9 @@ class BackgroundSyncManagerTest : public testing::Test {
: browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP),
network_change_notifier_(net::NetworkChangeNotifier::CreateMock()) {
sync_options_1_.tag = "foo";
- sync_options_1_.periodicity = SYNC_ONE_SHOT;
sync_options_1_.network_state = NETWORK_STATE_ONLINE;
sync_options_2_.tag = "bar";
- sync_options_2_.periodicity = SYNC_ONE_SHOT;
sync_options_2_.network_state = NETWORK_STATE_ONLINE;
}
@@ -536,7 +534,6 @@ class BackgroundSyncManagerTest : public testing::Test {
bool was_called = false;
background_sync_manager_->GetRegistration(
sw_registration_id, registration_options.tag,
- registration_options.periodicity,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &was_called));
base::RunLoop().RunUntilIdle();
@@ -550,16 +547,14 @@ class BackgroundSyncManagerTest : public testing::Test {
return callback_status_ == BACKGROUND_SYNC_STATUS_OK;
}
- bool GetRegistrations(SyncPeriodicity periodicity) {
- return GetRegistrationWithServiceWorkerId(sw_registration_id_1_,
- periodicity);
+ bool GetRegistrations() {
+ return GetRegistrationWithServiceWorkerId(sw_registration_id_1_);
}
- bool GetRegistrationWithServiceWorkerId(int64_t sw_registration_id,
- SyncPeriodicity periodicity) {
+ bool GetRegistrationWithServiceWorkerId(int64_t sw_registration_id) {
bool was_called = false;
background_sync_manager_->GetRegistrations(
- sw_registration_id, periodicity,
+ sw_registration_id,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationsCallback,
base::Unretained(this), &was_called));
base::RunLoop().RunUntilIdle();
@@ -689,36 +684,6 @@ TEST_F(BackgroundSyncManagerTest, RegisterWithoutActiveSWRegistration) {
EXPECT_EQ(BACKGROUND_SYNC_STATUS_NO_SERVICE_WORKER, callback_status_);
}
-TEST_F(BackgroundSyncManagerTest, RegisterOverwrites) {
- EXPECT_TRUE(Register(sync_options_1_));
- scoped_ptr<BackgroundSyncRegistrationHandle> first_registration_handle =
- std::move(callback_registration_handle_);
-
- sync_options_1_.min_period = 100;
- EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_LT(first_registration_handle->handle_id(),
- callback_registration_handle_->handle_id());
- EXPECT_FALSE(first_registration_handle->options()->Equals(
- *callback_registration_handle_->options()));
-}
-
-TEST_F(BackgroundSyncManagerTest, RegisterOverlappingPeriodicAndOneShotTags) {
- // Registrations with the same tags but different periodicities should not
- // collide.
- sync_options_1_.tag = "";
- sync_options_2_.tag = "";
- sync_options_1_.periodicity = SYNC_PERIODIC;
- sync_options_2_.periodicity = SYNC_ONE_SHOT;
- EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_TRUE(Register(sync_options_2_));
- EXPECT_TRUE(GetRegistration(sync_options_1_));
- EXPECT_EQ(SYNC_PERIODIC,
- callback_registration_handle_->options()->periodicity);
- EXPECT_TRUE(GetRegistration(sync_options_2_));
- EXPECT_EQ(SYNC_ONE_SHOT,
- callback_registration_handle_->options()->periodicity);
-}
-
TEST_F(BackgroundSyncManagerTest, RegisterBadBackend) {
test_background_sync_manager_->set_corrupt_backend(true);
EXPECT_FALSE(Register(sync_options_1_));
@@ -769,55 +734,38 @@ TEST_F(BackgroundSyncManagerTest, GetRegistrationBadBackend) {
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsZero) {
- EXPECT_TRUE(GetRegistrations(SYNC_ONE_SHOT));
+ EXPECT_TRUE(GetRegistrations());
EXPECT_EQ(0u, callback_registration_handles_->size());
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsOne) {
EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_TRUE(GetRegistrations(sync_options_1_.periodicity));
+ EXPECT_TRUE(GetRegistrations());
EXPECT_EQ(1u, callback_registration_handles_->size());
sync_options_1_.Equals(*(*callback_registration_handles_)[0]->options());
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsTwo) {
- EXPECT_EQ(sync_options_1_.periodicity, sync_options_2_.periodicity);
-
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_TRUE(Register(sync_options_2_));
- EXPECT_TRUE(GetRegistrations(sync_options_1_.periodicity));
+ EXPECT_TRUE(GetRegistrations());
EXPECT_EQ(2u, callback_registration_handles_->size());
sync_options_1_.Equals(*(*callback_registration_handles_)[0]->options());
sync_options_2_.Equals(*(*callback_registration_handles_)[1]->options());
}
-TEST_F(BackgroundSyncManagerTest, GetRegistrationsPeriodicity) {
- sync_options_1_.periodicity = SYNC_ONE_SHOT;
- sync_options_2_.periodicity = SYNC_PERIODIC;
- EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_TRUE(Register(sync_options_2_));
-
- EXPECT_TRUE(GetRegistrations(SYNC_ONE_SHOT));
- EXPECT_EQ(1u, callback_registration_handles_->size());
- sync_options_1_.Equals(*(*callback_registration_handles_)[0]->options());
-
- EXPECT_TRUE(GetRegistrations(SYNC_PERIODIC));
- EXPECT_EQ(1u, callback_registration_handles_->size());
- sync_options_2_.Equals(*(*callback_registration_handles_)[0]->options());
-}
-
TEST_F(BackgroundSyncManagerTest, GetRegistrationsBadBackend) {
EXPECT_TRUE(Register(sync_options_1_));
test_background_sync_manager_->set_corrupt_backend(true);
- EXPECT_TRUE(GetRegistrations(sync_options_1_.periodicity));
+ EXPECT_TRUE(GetRegistrations());
EXPECT_FALSE(Register(sync_options_2_));
// Registration should have discovered the bad backend and disabled the
// BackgroundSyncManager.
- EXPECT_FALSE(GetRegistrations(sync_options_1_.periodicity));
+ EXPECT_FALSE(GetRegistrations());
test_background_sync_manager_->set_corrupt_backend(false);
- EXPECT_FALSE(GetRegistrations(sync_options_1_.periodicity));
+ EXPECT_FALSE(GetRegistrations());
}
TEST_F(BackgroundSyncManagerTest, Unregister) {
@@ -841,7 +789,6 @@ TEST_F(BackgroundSyncManagerTest, UnregisterSecond) {
}
TEST_F(BackgroundSyncManagerTest, UnregisterBadBackend) {
- sync_options_1_.min_period += 1;
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_TRUE(Register(sync_options_2_));
test_background_sync_manager_->set_corrupt_backend(true);
@@ -937,7 +884,7 @@ TEST_F(BackgroundSyncManagerTest, SequentialOperations) {
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &register_called));
test_background_sync_manager_->GetRegistration(
- sw_registration_id_1_, sync_options_1_.tag, sync_options_1_.periodicity,
+ sw_registration_id_1_, sync_options_1_.tag,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &get_registration_called));
@@ -1048,23 +995,6 @@ TEST_F(BackgroundSyncManagerTest, RegistrationEqualsTag) {
EXPECT_FALSE(reg_1.Equals(reg_2));
}
-TEST_F(BackgroundSyncManagerTest, RegistrationEqualsPeriodicity) {
- BackgroundSyncRegistration reg_1;
- BackgroundSyncRegistration reg_2;
- EXPECT_TRUE(reg_1.Equals(reg_2));
- reg_1.options()->periodicity = SYNC_PERIODIC;
- reg_2.options()->periodicity = SYNC_ONE_SHOT;
- EXPECT_FALSE(reg_1.Equals(reg_2));
-}
-
-TEST_F(BackgroundSyncManagerTest, RegistrationEqualsMinPeriod) {
- BackgroundSyncRegistration reg_1;
- BackgroundSyncRegistration reg_2;
- EXPECT_TRUE(reg_1.Equals(reg_2));
- reg_2.options()->min_period = reg_1.options()->min_period + 1;
- EXPECT_FALSE(reg_1.Equals(reg_2));
-}
-
TEST_F(BackgroundSyncManagerTest, RegistrationEqualsNetworkState) {
BackgroundSyncRegistration reg_1;
BackgroundSyncRegistration reg_2;
@@ -1075,14 +1005,13 @@ TEST_F(BackgroundSyncManagerTest, RegistrationEqualsNetworkState) {
}
TEST_F(BackgroundSyncManagerTest, StoreAndRetrievePreservesValues) {
+ InitDelayedSyncEventTest();
BackgroundSyncRegistrationOptions options;
+
// Set non-default values for each field.
options.tag = "foo";
- EXPECT_NE(SYNC_PERIODIC, options.periodicity);
- options.periodicity = SYNC_PERIODIC;
- options.min_period += 1;
- EXPECT_NE(NETWORK_STATE_ANY, options.network_state);
- options.network_state = NETWORK_STATE_ANY;
+ EXPECT_NE(NETWORK_STATE_AVOID_CELLULAR, options.network_state);
+ options.network_state = NETWORK_STATE_AVOID_CELLULAR;
// Store the registration.
EXPECT_TRUE(Register(options));
@@ -1105,35 +1034,6 @@ TEST_F(BackgroundSyncManagerTest, EmptyTagSupported) {
EXPECT_FALSE(GetRegistration(sync_options_1_));
}
-TEST_F(BackgroundSyncManagerTest, OverlappingPeriodicAndOneShotTags) {
- // Registrations with the same tags but different periodicities should not
- // collide.
- sync_options_1_.tag = "";
- sync_options_2_.tag = "";
- sync_options_1_.periodicity = SYNC_PERIODIC;
- sync_options_2_.periodicity = SYNC_ONE_SHOT;
-
- EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_TRUE(Register(sync_options_2_));
-
- EXPECT_TRUE(GetRegistration(sync_options_1_));
- EXPECT_EQ(SYNC_PERIODIC,
- callback_registration_handle_->options()->periodicity);
- EXPECT_TRUE(GetRegistration(sync_options_2_));
- EXPECT_EQ(SYNC_ONE_SHOT,
- callback_registration_handle_->options()->periodicity);
-
- EXPECT_TRUE(GetRegistration(sync_options_1_));
- EXPECT_TRUE(Unregister(callback_registration_handle_.get()));
- EXPECT_FALSE(GetRegistration(sync_options_1_));
- EXPECT_TRUE(GetRegistration(sync_options_2_));
- EXPECT_EQ(SYNC_ONE_SHOT,
- callback_registration_handle_->options()->periodicity);
-
- EXPECT_TRUE(Unregister(callback_registration_handle_.get()));
- EXPECT_FALSE(GetRegistration(sync_options_2_));
-}
-
TEST_F(BackgroundSyncManagerTest, OneShotFiresOnRegistration) {
InitSyncEventTest();
@@ -1365,6 +1265,8 @@ TEST_F(BackgroundSyncManagerTest, OverwritePendingRegistration) {
EXPECT_TRUE(GetRegistration(sync_options_1_));
EXPECT_EQ(NETWORK_STATE_ONLINE,
callback_registration_handle_->options()->network_state);
+ EXPECT_LT(original_handle->handle_id(),
+ callback_registration_handle_->handle_id());
EXPECT_TRUE(NotifyWhenFinished(original_handle.get()));
EXPECT_EQ(BackgroundSyncState::UNREGISTERED, FinishedState());
diff --git a/content/browser/background_sync/background_sync_metrics.cc b/content/browser/background_sync/background_sync_metrics.cc
index 20b3a66..8198815 100644
--- a/content/browser/background_sync/background_sync_metrics.cc
+++ b/content/browser/background_sync/background_sync_metrics.cc
@@ -33,40 +33,18 @@ ResultPattern EventResultToResultPattern(bool success,
namespace content {
// static
-void BackgroundSyncMetrics::RecordEventStarted(SyncPeriodicity periodicity,
- bool started_in_foreground) {
- switch (periodicity) {
- case SYNC_ONE_SHOT:
- UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Event.OneShotStartedInForeground",
- started_in_foreground);
- return;
- case SYNC_PERIODIC:
- UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Event.PeriodicStartedInForeground",
- started_in_foreground);
- return;
- }
- NOTREACHED();
+void BackgroundSyncMetrics::RecordEventStarted(bool started_in_foreground) {
+ UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Event.OneShotStartedInForeground",
+ started_in_foreground);
}
// static
-void BackgroundSyncMetrics::RecordEventResult(SyncPeriodicity periodicity,
- bool success,
+void BackgroundSyncMetrics::RecordEventResult(bool success,
bool finished_in_foreground) {
- switch (periodicity) {
- case SYNC_ONE_SHOT:
- UMA_HISTOGRAM_ENUMERATION(
- "BackgroundSync.Event.OneShotResultPattern",
- EventResultToResultPattern(success, finished_in_foreground),
- RESULT_PATTERN_MAX + 1);
- return;
- case SYNC_PERIODIC:
- UMA_HISTOGRAM_ENUMERATION(
- "BackgroundSync.Event.PeriodicResultPattern",
- EventResultToResultPattern(success, finished_in_foreground),
- RESULT_PATTERN_MAX + 1);
- return;
- }
- NOTREACHED();
+ UMA_HISTOGRAM_ENUMERATION(
+ "BackgroundSync.Event.OneShotResultPattern",
+ EventResultToResultPattern(success, finished_in_foreground),
+ RESULT_PATTERN_MAX + 1);
}
// static
@@ -84,62 +62,30 @@ void BackgroundSyncMetrics::RecordBatchSyncEventComplete(
// static
void BackgroundSyncMetrics::CountRegisterSuccess(
- SyncPeriodicity periodicity,
RegistrationCouldFire registration_could_fire,
RegistrationIsDuplicate registration_is_duplicate) {
- switch (periodicity) {
- case SYNC_ONE_SHOT:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.OneShot",
- BACKGROUND_SYNC_STATUS_OK,
- BACKGROUND_SYNC_STATUS_MAX + 1);
- UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.OneShot.CouldFire",
- registration_could_fire == REGISTRATION_COULD_FIRE);
- UMA_HISTOGRAM_BOOLEAN(
- "BackgroundSync.Registration.OneShot.IsDuplicate",
- registration_is_duplicate == REGISTRATION_IS_DUPLICATE);
- return;
- case SYNC_PERIODIC:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.Periodic",
- BACKGROUND_SYNC_STATUS_OK,
- BACKGROUND_SYNC_STATUS_MAX + 1);
- UMA_HISTOGRAM_BOOLEAN(
- "BackgroundSync.Registration.Periodic.IsDuplicate",
- registration_is_duplicate == REGISTRATION_IS_DUPLICATE);
- return;
- }
- NOTREACHED();
+ UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.OneShot",
+ BACKGROUND_SYNC_STATUS_OK,
+ BACKGROUND_SYNC_STATUS_MAX + 1);
+ UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.OneShot.CouldFire",
+ registration_could_fire == REGISTRATION_COULD_FIRE);
+ UMA_HISTOGRAM_BOOLEAN("BackgroundSync.Registration.OneShot.IsDuplicate",
+ registration_is_duplicate == REGISTRATION_IS_DUPLICATE);
+ return;
}
// static
-void BackgroundSyncMetrics::CountRegisterFailure(SyncPeriodicity periodicity,
- BackgroundSyncStatus result) {
- switch (periodicity) {
- case SYNC_ONE_SHOT:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.OneShot", result,
- BACKGROUND_SYNC_STATUS_MAX + 1);
- return;
- case SYNC_PERIODIC:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.Periodic", result,
- BACKGROUND_SYNC_STATUS_MAX + 1);
- return;
- }
- NOTREACHED();
+void BackgroundSyncMetrics::CountRegisterFailure(BackgroundSyncStatus result) {
+ UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Registration.OneShot", result,
+ BACKGROUND_SYNC_STATUS_MAX + 1);
+ return;
}
// static
-void BackgroundSyncMetrics::CountUnregister(SyncPeriodicity periodicity,
- BackgroundSyncStatus result) {
- switch (periodicity) {
- case SYNC_ONE_SHOT:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Unregistration.OneShot", result,
- BACKGROUND_SYNC_STATUS_MAX + 1);
- return;
- case SYNC_PERIODIC:
- UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Unregistration.Periodic",
- result, BACKGROUND_SYNC_STATUS_MAX + 1);
- return;
- }
- NOTREACHED();
+void BackgroundSyncMetrics::CountUnregister(BackgroundSyncStatus result) {
+ UMA_HISTOGRAM_ENUMERATION("BackgroundSync.Unregistration.OneShot", result,
+ BACKGROUND_SYNC_STATUS_MAX + 1);
+ return;
}
} // namespace content
diff --git a/content/browser/background_sync/background_sync_metrics.h b/content/browser/background_sync/background_sync_metrics.h
index f92a7c5..891e114 100644
--- a/content/browser/background_sync/background_sync_metrics.h
+++ b/content/browser/background_sync/background_sync_metrics.h
@@ -29,13 +29,10 @@ class BackgroundSyncMetrics {
};
// Records the start of a sync event.
- static void RecordEventStarted(SyncPeriodicity periodicity,
- bool startedin_foreground);
+ static void RecordEventStarted(bool startedin_foreground);
// Records the result of a single sync event firing.
- static void RecordEventResult(SyncPeriodicity periodicity,
- bool result,
- bool finished_in_foreground);
+ static void RecordEventResult(bool result, bool finished_in_foreground);
// Records the result of running a batch of sync events, including the total
// time spent, and the batch size.
@@ -46,17 +43,14 @@ class BackgroundSyncMetrics {
// indicates whether the conditions were sufficient for the sync to fire
// immediately at the time it was registered.
static void CountRegisterSuccess(
- SyncPeriodicity periodicity,
RegistrationCouldFire could_fire,
RegistrationIsDuplicate registration_is_duplicate);
// Records the status of a failed sync registration.
- static void CountRegisterFailure(SyncPeriodicity periodicity,
- BackgroundSyncStatus status);
+ static void CountRegisterFailure(BackgroundSyncStatus status);
// Records the result of trying to unregister a sync.
- static void CountUnregister(SyncPeriodicity periodicity,
- BackgroundSyncStatus result);
+ static void CountUnregister(BackgroundSyncStatus result);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundSyncMetrics);
diff --git a/content/browser/background_sync/background_sync_registration_handle.h b/content/browser/background_sync/background_sync_registration_handle.h
index 22cfdaa..da4db86 100644
--- a/content/browser/background_sync/background_sync_registration_handle.h
+++ b/content/browser/background_sync/background_sync_registration_handle.h
@@ -53,8 +53,7 @@ class CONTENT_EXPORT BackgroundSyncRegistrationHandle {
// succeeded. The provided state is BackgroundSyncState::SUCCESS on success,
// BACKGRUOND_SYNC_STATE_FAILED on final failure, and
// BackgroundSyncState::UNREGISTERED if the registration was unregistered
- // before it could complete. NotifyWhenFinished should only be called for
- // SYNC_ONE_SHOT registrations.
+ // before it could complete.
void NotifyWhenFinished(const StatusAndStateCallback& callback);
// Returns true if the handle is backed by a BackgroundSyncRegistration in the
diff --git a/content/browser/background_sync/background_sync_registration_options.cc b/content/browser/background_sync/background_sync_registration_options.cc
index 24c68fd..7b8e1e7 100644
--- a/content/browser/background_sync/background_sync_registration_options.cc
+++ b/content/browser/background_sync/background_sync_registration_options.cc
@@ -8,9 +8,7 @@ namespace content {
bool BackgroundSyncRegistrationOptions::Equals(
const BackgroundSyncRegistrationOptions& other) const {
- return tag == other.tag && min_period == other.min_period &&
- network_state == other.network_state &&
- periodicity == other.periodicity;
+ return tag == other.tag && network_state == other.network_state;
}
} // namespace content
diff --git a/content/browser/background_sync/background_sync_registration_options.h b/content/browser/background_sync/background_sync_registration_options.h
index 7f02648..5c81e30 100644
--- a/content/browser/background_sync/background_sync_registration_options.h
+++ b/content/browser/background_sync/background_sync_registration_options.h
@@ -19,9 +19,7 @@ struct CONTENT_EXPORT BackgroundSyncRegistrationOptions {
bool Equals(const BackgroundSyncRegistrationOptions& other) const;
std::string tag;
- int64_t min_period = 0;
SyncNetworkState network_state = NETWORK_STATE_ONLINE;
- SyncPeriodicity periodicity = SYNC_ONE_SHOT;
};
} // namespace content
diff --git a/content/browser/background_sync/background_sync_service_impl.cc b/content/browser/background_sync/background_sync_service_impl.cc
index 430348e..ce27c48 100644
--- a/content/browser/background_sync/background_sync_service_impl.cc
+++ b/content/browser/background_sync/background_sync_service_impl.cc
@@ -24,9 +24,7 @@ BackgroundSyncRegistrationOptions ToBackgroundSyncRegistrationOptions(
BackgroundSyncRegistrationOptions out;
out.tag = in->tag;
- out.min_period = in->min_period_ms;
out.network_state = static_cast<SyncNetworkState>(in->network_state);
- out.periodicity = static_cast<SyncPeriodicity>(in->periodicity);
return out;
}
@@ -35,9 +33,6 @@ SyncRegistrationPtr ToMojoRegistration(
SyncRegistrationPtr out(content::SyncRegistration::New());
out->handle_id = in.handle_id();
out->tag = in.options()->tag;
- out->min_period_ms = in.options()->min_period;
- out->periodicity = static_cast<content::BackgroundSyncPeriodicity>(
- in.options()->periodicity);
out->network_state = static_cast<content::BackgroundSyncNetworkState>(
in.options()->network_state);
return out;
@@ -73,13 +68,6 @@ COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ONLINE,
COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::MAX,
SyncNetworkState::NETWORK_STATE_ONLINE);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::PERIODIC,
- SyncPeriodicity::SYNC_PERIODIC);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::ONE_SHOT,
- SyncPeriodicity::SYNC_ONE_SHOT);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX,
- SyncPeriodicity::SYNC_ONE_SHOT);
-
BackgroundSyncServiceImpl::~BackgroundSyncServiceImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(background_sync_context_->background_sync_manager());
@@ -142,7 +130,6 @@ void BackgroundSyncServiceImpl::Unregister(
}
void BackgroundSyncServiceImpl::GetRegistration(
- BackgroundSyncPeriodicity periodicity,
const mojo::String& tag,
int64_t sw_registration_id,
const GetRegistrationCallback& callback) {
@@ -151,13 +138,12 @@ void BackgroundSyncServiceImpl::GetRegistration(
background_sync_context_->background_sync_manager();
DCHECK(background_sync_manager);
background_sync_manager->GetRegistration(
- sw_registration_id, tag.get(), static_cast<SyncPeriodicity>(periodicity),
+ sw_registration_id, tag.get(),
base::Bind(&BackgroundSyncServiceImpl::OnRegisterResult,
weak_ptr_factory_.GetWeakPtr(), callback));
}
void BackgroundSyncServiceImpl::GetRegistrations(
- BackgroundSyncPeriodicity periodicity,
int64_t sw_registration_id,
const GetRegistrationsCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -165,20 +151,18 @@ void BackgroundSyncServiceImpl::GetRegistrations(
background_sync_context_->background_sync_manager();
DCHECK(background_sync_manager);
background_sync_manager->GetRegistrations(
- sw_registration_id, static_cast<SyncPeriodicity>(periodicity),
+ sw_registration_id,
base::Bind(&BackgroundSyncServiceImpl::OnGetRegistrationsResult,
weak_ptr_factory_.GetWeakPtr(), callback));
}
void BackgroundSyncServiceImpl::GetPermissionStatus(
- BackgroundSyncPeriodicity periodicity,
int64_t sw_registration_id,
const GetPermissionStatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// TODO(iclelland): Implement a real policy. This is a stub implementation.
// OneShot: crbug.com/482091
- // Periodic: crbug.com/482093
callback.Run(BackgroundSyncError::NONE, PermissionStatus::GRANTED);
}
diff --git a/content/browser/background_sync/background_sync_service_impl.h b/content/browser/background_sync/background_sync_service_impl.h
index a5b6d18..77df3b6a 100644
--- a/content/browser/background_sync/background_sync_service_impl.h
+++ b/content/browser/background_sync/background_sync_service_impl.h
@@ -39,15 +39,12 @@ class CONTENT_EXPORT BackgroundSyncServiceImpl
void Unregister(BackgroundSyncRegistrationHandle::HandleId handle_id,
int64_t sw_registration_id,
const UnregisterCallback& callback) override;
- void GetRegistration(BackgroundSyncPeriodicity periodicity,
- const mojo::String& tag,
+ void GetRegistration(const mojo::String& tag,
int64_t sw_registration_id,
const GetRegistrationCallback& callback) override;
- void GetRegistrations(BackgroundSyncPeriodicity periodicity,
- int64_t sw_registration_id,
+ void GetRegistrations(int64_t sw_registration_id,
const GetRegistrationsCallback& callback) override;
void GetPermissionStatus(
- BackgroundSyncPeriodicity periodicity,
int64_t sw_registration_id,
const GetPermissionStatusCallback& callback) override;
void DuplicateRegistrationHandle(
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 21f312f12..c88eb17 100644
--- a/content/browser/background_sync/background_sync_service_impl_unittest.cc
+++ b/content/browser/background_sync/background_sync_service_impl_unittest.cc
@@ -211,15 +211,13 @@ class BackgroundSyncServiceImplTest : public testing::Test {
void GetRegistrationOneShot(
const mojo::String& tag,
const BackgroundSyncService::RegisterCallback& callback) {
- service_impl_->GetRegistration(BackgroundSyncPeriodicity::ONE_SHOT, tag,
- sw_registration_id_, callback);
+ service_impl_->GetRegistration(tag, sw_registration_id_, callback);
base::RunLoop().RunUntilIdle();
}
void GetRegistrationsOneShot(
const BackgroundSyncService::GetRegistrationsCallback& callback) {
- service_impl_->GetRegistrations(BackgroundSyncPeriodicity::ONE_SHOT,
- sw_registration_id_, callback);
+ service_impl_->GetRegistrations(sw_registration_id_, callback);
base::RunLoop().RunUntilIdle();
}
diff --git a/content/child/background_sync/background_sync_provider.cc b/content/child/background_sync/background_sync_provider.cc
index 9895820..9975246 100644
--- a/content/child/background_sync/background_sync_provider.cc
+++ b/content/child/background_sync/background_sync_provider.cc
@@ -127,7 +127,6 @@ void BackgroundSyncProvider::unregisterBackgroundSync(
}
void BackgroundSyncProvider::getRegistration(
- blink::WebSyncRegistration::Periodicity periodicity,
const blink::WebString& tag,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncRegistrationCallbacks* callbacks) {
@@ -140,15 +139,13 @@ void BackgroundSyncProvider::getRegistration(
// base::Unretained is safe here, as the mojo channel will be deleted (and
// will wipe its callbacks) before 'this' is deleted.
GetBackgroundSyncServicePtr()->GetRegistration(
- mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity), tag.utf8(),
- service_worker_registration_id,
+ tag.utf8(), service_worker_registration_id,
base::Bind(&BackgroundSyncProvider::GetRegistrationCallback,
base::Unretained(this),
base::Passed(std::move(callbacksPtr))));
}
void BackgroundSyncProvider::getRegistrations(
- blink::WebSyncRegistration::Periodicity periodicity,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncGetRegistrationsCallbacks* callbacks) {
DCHECK(service_worker_registration);
@@ -160,7 +157,6 @@ void BackgroundSyncProvider::getRegistrations(
// base::Unretained is safe here, as the mojo channel will be deleted (and
// will wipe its callbacks) before 'this' is deleted.
GetBackgroundSyncServicePtr()->GetRegistrations(
- mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity),
service_worker_registration_id,
base::Bind(&BackgroundSyncProvider::GetRegistrationsCallback,
base::Unretained(this),
@@ -168,7 +164,6 @@ void BackgroundSyncProvider::getRegistrations(
}
void BackgroundSyncProvider::getPermissionStatus(
- blink::WebSyncRegistration::Periodicity periodicity,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncGetPermissionStatusCallbacks* callbacks) {
DCHECK(service_worker_registration);
@@ -181,7 +176,6 @@ void BackgroundSyncProvider::getPermissionStatus(
// base::Unretained is safe here, as the mojo channel will be deleted (and
// will wipe its callbacks) before 'this' is deleted.
GetBackgroundSyncServicePtr()->GetPermissionStatus(
- mojo::ConvertTo<BackgroundSyncPeriodicity>(periodicity),
service_worker_registration_id,
base::Bind(&BackgroundSyncProvider::GetPermissionStatusCallback,
base::Unretained(this),
diff --git a/content/child/background_sync/background_sync_provider.h b/content/child/background_sync/background_sync_provider.h
index 3d5aea2..0d8e6b9 100644
--- a/content/child/background_sync/background_sync_provider.h
+++ b/content/child/background_sync/background_sync_provider.h
@@ -22,12 +22,12 @@ class SingleThreadTaskRunner;
namespace content {
// The BackgroundSyncProvider is called by the SyncManager and SyncRegistration
-// objects (and their Periodic counterparts) and communicates with the
-// BackgroundSyncManager object in the browser process. Each thread will have
-// its own instance (e.g. main thread, worker threads), instantiated as needed
-// by BlinkPlatformImpl. Each instance of the provider creates a new mojo
-// connection to a new BackgroundSyncManagerImpl, which then talks to the
-// BackgroundSyncManager object.
+// objects and communicates with the BackgroundSyncManager object in the browser
+// process. Each thread will have its own instance (e.g. main thread, worker
+// threads), instantiated as needed by BlinkPlatformImpl. Each instance of
+// the provider creates a new mojo connection to a new
+// BackgroundSyncManagerImpl, which then talks to the BackgroundSyncManager
+// object.
class BackgroundSyncProvider : public blink::WebSyncProvider,
public WorkerThread::Observer {
public:
@@ -55,16 +55,13 @@ class BackgroundSyncProvider : public blink::WebSyncProvider,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncUnregistrationCallbacks* callbacks) override;
void getRegistration(
- blink::WebSyncRegistration::Periodicity,
const blink::WebString& tag,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncRegistrationCallbacks* callbacks) override;
void getRegistrations(
- blink::WebSyncRegistration::Periodicity periodicity,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncGetRegistrationsCallbacks* callbacks) override;
void getPermissionStatus(
- blink::WebSyncRegistration::Periodicity periodicity,
blink::WebServiceWorkerRegistration* service_worker_registration,
blink::WebSyncGetPermissionStatusCallbacks* callbacks) override;
// TODO(jkarlin): Rename to releaseRegistrationHandle.
diff --git a/content/child/background_sync/background_sync_type_converters.cc b/content/child/background_sync/background_sync_type_converters.cc
index 8502654..61088f8 100644
--- a/content/child/background_sync/background_sync_type_converters.cc
+++ b/content/child/background_sync/background_sync_type_converters.cc
@@ -13,14 +13,6 @@ namespace mojo {
static_cast<int>(blink::blink_name), \
"mojo and blink enums must match")
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::PERIODIC,
- WebSyncRegistration::PeriodicityPeriodic);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::ONE_SHOT,
- WebSyncRegistration::PeriodicityOneShot);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX,
- WebSyncRegistration::PeriodicityOneShot);
-COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncPeriodicity::MAX,
- WebSyncRegistration::PeriodicityLast);
COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::ANY,
WebSyncRegistration::NetworkStateAny);
COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncNetworkState::AVOID_CELLULAR,
@@ -37,22 +29,6 @@ COMPILE_ASSERT_MATCHING_ENUM(BackgroundSyncEventLastChance::IS_LAST_CHANCE,
WebServiceWorkerContextProxy::IsLastChance);
// static
-blink::WebSyncRegistration::Periodicity
- TypeConverter<blink::WebSyncRegistration::Periodicity,
- content::BackgroundSyncPeriodicity>::Convert(
- content::BackgroundSyncPeriodicity input) {
- return static_cast<blink::WebSyncRegistration::Periodicity>(input);
-}
-
-// static
-content::BackgroundSyncPeriodicity
- TypeConverter<content::BackgroundSyncPeriodicity,
- blink::WebSyncRegistration::Periodicity>::Convert(
- blink::WebSyncRegistration::Periodicity input) {
- return static_cast<content::BackgroundSyncPeriodicity>(input);
-}
-
-// static
blink::WebSyncRegistration::NetworkState
TypeConverter<blink::WebSyncRegistration::NetworkState,
content::BackgroundSyncNetworkState>::Convert(
@@ -76,10 +52,7 @@ scoped_ptr<blink::WebSyncRegistration> TypeConverter<
scoped_ptr<blink::WebSyncRegistration> result(
new blink::WebSyncRegistration());
result->id = input->handle_id;
- result->periodicity =
- ConvertTo<blink::WebSyncRegistration::Periodicity>(input->periodicity);
result->tag = blink::WebString::fromUTF8(input->tag);
- result->minPeriodMs = input->min_period_ms;
result->networkState =
ConvertTo<blink::WebSyncRegistration::NetworkState>(input->network_state);
return result;
@@ -93,10 +66,7 @@ content::SyncRegistrationPtr TypeConverter<
content::SyncRegistrationPtr result(
content::SyncRegistration::New());
result->handle_id = input.id;
- result->periodicity =
- ConvertTo<content::BackgroundSyncPeriodicity>(input.periodicity);
result->tag = input.tag.utf8();
- result->min_period_ms = input.minPeriodMs;
result->network_state =
ConvertTo<content::BackgroundSyncNetworkState>(input.networkState);
return result;
diff --git a/content/child/background_sync/background_sync_type_converters.h b/content/child/background_sync/background_sync_type_converters.h
index 4152f2b..950e629 100644
--- a/content/child/background_sync/background_sync_type_converters.h
+++ b/content/child/background_sync/background_sync_type_converters.h
@@ -15,23 +15,6 @@
namespace mojo {
-// blink::WebSyngRegistration::Periodicity <=>
-// content::BackgroundSyncPeriodicity
-
-template <>
-struct CONTENT_EXPORT TypeConverter<blink::WebSyncRegistration::Periodicity,
- content::BackgroundSyncPeriodicity> {
- static blink::WebSyncRegistration::Periodicity Convert(
- content::BackgroundSyncPeriodicity input);
-};
-
-template <>
-struct CONTENT_EXPORT TypeConverter<content::BackgroundSyncPeriodicity,
- blink::WebSyncRegistration::Periodicity> {
- static content::BackgroundSyncPeriodicity Convert(
- blink::WebSyncRegistration::Periodicity input);
-};
-
// blink::WebSyncRegistration::NetworkState <=>
// content::BackgroundSyncNetworkState
diff --git a/content/child/background_sync/background_sync_type_converters_unittest.cc b/content/child/background_sync/background_sync_type_converters_unittest.cc
index 12e3aa9..4afca4c 100644
--- a/content/child/background_sync/background_sync_type_converters_unittest.cc
+++ b/content/child/background_sync/background_sync_type_converters_unittest.cc
@@ -9,24 +9,6 @@
namespace mojo {
namespace {
-TEST(BackgroundSyncTypeConverterTest, TestBlinkToMojoPeriodicityConversions) {
- ASSERT_EQ(blink::WebSyncRegistration::PeriodicityPeriodic,
- ConvertTo<blink::WebSyncRegistration::Periodicity>(
- content::BackgroundSyncPeriodicity::PERIODIC));
- ASSERT_EQ(blink::WebSyncRegistration::PeriodicityOneShot,
- ConvertTo<blink::WebSyncRegistration::Periodicity>(
- content::BackgroundSyncPeriodicity::ONE_SHOT));
-}
-
-TEST(BackgroundSyncTypeConverterTest, TestMojoToBlinkPeriodicityConversions) {
- ASSERT_EQ(content::BackgroundSyncPeriodicity::PERIODIC,
- ConvertTo<content::BackgroundSyncPeriodicity>(
- blink::WebSyncRegistration::PeriodicityPeriodic));
- ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT,
- ConvertTo<content::BackgroundSyncPeriodicity>(
- blink::WebSyncRegistration::PeriodicityOneShot));
-}
-
TEST(BackgroundSyncTypeConverterTest, TestBlinkToMojoNetworkStateConversions) {
ASSERT_EQ(blink::WebSyncRegistration::NetworkStateAny,
ConvertTo<blink::WebSyncRegistration::NetworkState>(
@@ -57,38 +39,18 @@ TEST(BackgroundSyncTypeConverterTest, TestDefaultBlinkToMojoConversion) {
ConvertTo<content::SyncRegistrationPtr>(in);
ASSERT_EQ(blink::WebSyncRegistration::UNREGISTERED_SYNC_ID, out->handle_id);
- ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT, out->periodicity);
ASSERT_EQ("", out->tag);
- ASSERT_EQ(0UL, out->min_period_ms);
ASSERT_EQ(content::BackgroundSyncNetworkState::ONLINE, out->network_state);
}
-TEST(BackgroundSyncTypeConverterTest, TestFullPeriodicBlinkToMojoConversion) {
- blink::WebSyncRegistration in(
- 7, blink::WebSyncRegistration::PeriodicityPeriodic, "BlinkToMojo",
- 12340000, blink::WebSyncRegistration::NetworkStateAvoidCellular);
- content::SyncRegistrationPtr out =
- ConvertTo<content::SyncRegistrationPtr>(in);
-
- ASSERT_EQ(7, out->handle_id);
- ASSERT_EQ(content::BackgroundSyncPeriodicity::PERIODIC, out->periodicity);
- ASSERT_EQ("BlinkToMojo", out->tag);
- ASSERT_EQ(12340000UL, out->min_period_ms);
- ASSERT_EQ(content::BackgroundSyncNetworkState::AVOID_CELLULAR,
- out->network_state);
-}
-
TEST(BackgroundSyncTypeConverterTest, TestFullOneShotBlinkToMojoConversion) {
blink::WebSyncRegistration in(
- 7, blink::WebSyncRegistration::PeriodicityOneShot, "BlinkToMojo",
- 12340000, blink::WebSyncRegistration::NetworkStateAvoidCellular);
+ 7, "BlinkToMojo", blink::WebSyncRegistration::NetworkStateAvoidCellular);
content::SyncRegistrationPtr out =
ConvertTo<content::SyncRegistrationPtr>(in);
ASSERT_EQ(7, out->handle_id);
- ASSERT_EQ(content::BackgroundSyncPeriodicity::ONE_SHOT, out->periodicity);
ASSERT_EQ("BlinkToMojo", out->tag);
- ASSERT_EQ(12340000UL, out->min_period_ms);
ASSERT_EQ(content::BackgroundSyncNetworkState::AVOID_CELLULAR,
out->network_state);
}
@@ -100,46 +62,21 @@ TEST(BackgroundSyncTypeConverterTest, TestDefaultMojoToBlinkConversion) {
ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(in);
ASSERT_EQ(blink::WebSyncRegistration::UNREGISTERED_SYNC_ID, out->id);
- ASSERT_EQ(blink::WebSyncRegistration::PeriodicityOneShot, out->periodicity);
ASSERT_EQ("",out->tag);
- ASSERT_EQ(0UL, out->minPeriodMs);
ASSERT_EQ(blink::WebSyncRegistration::NetworkStateOnline, out->networkState);
}
-TEST(BackgroundSyncTypeConverterTest, TestFullPeriodicMojoToBlinkConversion) {
- content::SyncRegistrationPtr in(
- content::SyncRegistration::New());
- in->handle_id = 41;
- in->periodicity = content::BackgroundSyncPeriodicity::PERIODIC;
- in->tag = mojo::String("MojoToBlink");
- in->min_period_ms = 43210000;
- in->network_state = content::BackgroundSyncNetworkState::AVOID_CELLULAR;
- scoped_ptr<blink::WebSyncRegistration> out =
- ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(in);
-
- ASSERT_EQ(41, out->id);
- ASSERT_EQ(blink::WebSyncRegistration::PeriodicityPeriodic, out->periodicity);
- ASSERT_EQ("MojoToBlink", out->tag.utf8());
- ASSERT_EQ(43210000UL, out->minPeriodMs);
- ASSERT_EQ(blink::WebSyncRegistration::NetworkStateAvoidCellular,
- out->networkState);
-}
-
TEST(BackgroundSyncTypeConverterTest, TestFullOneShotMojoToBlinkConversion) {
content::SyncRegistrationPtr in(
content::SyncRegistration::New());
in->handle_id = 41;
- in->periodicity = content::BackgroundSyncPeriodicity::ONE_SHOT;
in->tag = mojo::String("MojoToBlink");
- in->min_period_ms = 43210000;
in->network_state = content::BackgroundSyncNetworkState::AVOID_CELLULAR;
scoped_ptr<blink::WebSyncRegistration> out =
ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(in);
ASSERT_EQ(41, out->id);
- ASSERT_EQ(blink::WebSyncRegistration::PeriodicityOneShot, out->periodicity);
ASSERT_EQ("MojoToBlink", out->tag.utf8());
- ASSERT_EQ(43210000UL, out->minPeriodMs);
ASSERT_EQ(blink::WebSyncRegistration::NetworkStateAvoidCellular,
out->networkState);
}
diff --git a/content/common/background_sync_service.mojom b/content/common/background_sync_service.mojom
index d1b0cd1..d30edc8 100644
--- a/content/common/background_sync_service.mojom
+++ b/content/common/background_sync_service.mojom
@@ -36,16 +36,13 @@ interface BackgroundSyncService {
Register(SyncRegistration options, int64 service_worker_registration_id,
bool requested_from_service_worker)
=> (BackgroundSyncError err, SyncRegistration options);
- GetRegistration(BackgroundSyncPeriodicity periodicity, string tag,
- int64 service_worker_registration_id)
+ GetRegistration(string tag, int64 service_worker_registration_id)
=> (BackgroundSyncError err, SyncRegistration? registration);
- GetRegistrations(BackgroundSyncPeriodicity periodicity,
- int64 service_worker_registration_id)
+ GetRegistrations(int64 service_worker_registration_id)
=> (BackgroundSyncError err, array<SyncRegistration> registrations);
Unregister(int64 handle_id, int64 service_worker_registration_id)
=> (BackgroundSyncError err);
- GetPermissionStatus(BackgroundSyncPeriodicity periodicity,
- int64 service_worker_registration_id)
+ GetPermissionStatus(int64 service_worker_registration_id)
=> (BackgroundSyncError err, PermissionStatus status);
DuplicateRegistrationHandle(int64 handle_id)
=> (BackgroundSyncError err, SyncRegistration? registration);
diff --git a/content/public/common/background_sync.mojom b/content/public/common/background_sync.mojom
index 6fc547f..969e0b6 100644
--- a/content/public/common/background_sync.mojom
+++ b/content/public/common/background_sync.mojom
@@ -11,16 +11,8 @@ enum BackgroundSyncNetworkState {
MAX=ONLINE
};
-enum BackgroundSyncPeriodicity {
- PERIODIC,
- ONE_SHOT,
- MAX=ONE_SHOT
-};
-
struct SyncRegistration {
int64 handle_id = -1;
- BackgroundSyncPeriodicity periodicity = ONE_SHOT;
string tag = "";
- uint64 min_period_ms = 0;
BackgroundSyncNetworkState network_state = ONLINE;
};
diff --git a/third_party/WebKit/Source/modules/background_sync/ServiceWorkerGlobalScopeSync.h b/third_party/WebKit/Source/modules/background_sync/ServiceWorkerGlobalScopeSync.h
index 42f4b3a..d5dc737 100644
--- a/third_party/WebKit/Source/modules/background_sync/ServiceWorkerGlobalScopeSync.h
+++ b/third_party/WebKit/Source/modules/background_sync/ServiceWorkerGlobalScopeSync.h
@@ -12,7 +12,6 @@ namespace blink {
class ServiceWorkerGlobalScopeSync {
public:
DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(sync);
- DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(periodicsync);
};
} // namespace blink
diff --git a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
index 1c38603..883e379 100644
--- a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
+++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
@@ -58,9 +58,7 @@ ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, ExecutionC
WebSyncRegistration* webSyncRegistration = new WebSyncRegistration(
WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */,
- WebSyncRegistration::PeriodicityOneShot,
tag,
- 0 /* minPeriod */,
WebSyncRegistration::NetworkStateOnline /* networkState */
);
backgroundSyncProvider()->registerBackgroundSync(webSyncRegistration, m_registration->webRegistration(), context->isServiceWorkerGlobalScope(), new SyncRegistrationCallbacks(resolver, m_registration));
@@ -73,7 +71,7 @@ ScriptPromise SyncManager::getTags(ScriptState* scriptState)
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
- backgroundSyncProvider()->getRegistrations(WebSyncRegistration::PeriodicityOneShot, m_registration->webRegistration(), new SyncGetRegistrationsCallbacks(resolver, m_registration));
+ backgroundSyncProvider()->getRegistrations(m_registration->webRegistration(), new SyncGetRegistrationsCallbacks(resolver, m_registration));
return promise;
}
diff --git a/third_party/WebKit/Source/modules/background_sync/SyncManager.h b/third_party/WebKit/Source/modules/background_sync/SyncManager.h
index 2529574..891231f 100644
--- a/third_party/WebKit/Source/modules/background_sync/SyncManager.h
+++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.h
@@ -25,8 +25,6 @@ public:
return new SyncManager(registration);
}
- unsigned long minAllowablePeriod();
-
ScriptPromise registerFunction(ScriptState*, ExecutionContext*, const String&);
ScriptPromise getTags(ScriptState*);
diff --git a/third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h b/third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h
index 890ffbb..92a682f 100644
--- a/third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h
+++ b/third_party/WebKit/public/platform/modules/background_sync/WebSyncProvider.h
@@ -37,15 +37,15 @@ public:
// Takes ownership of the WebSyncRegistrationCallbacks.
// Does not take ownership of the WebServiceWorkerRegistration.
- virtual void getRegistration(blink::WebSyncRegistration::Periodicity, const WebString&, WebServiceWorkerRegistration*, WebSyncRegistrationCallbacks*) = 0;
+ virtual void getRegistration(const WebString&, WebServiceWorkerRegistration*, WebSyncRegistrationCallbacks*) = 0;
// Takes ownership of the WebSyncGetRegistrationsCallbacks.
// Does not take ownership of the WebServiceWorkerRegistration.
- virtual void getRegistrations(blink::WebSyncRegistration::Periodicity, WebServiceWorkerRegistration*, WebSyncGetRegistrationsCallbacks*) = 0;
+ virtual void getRegistrations(WebServiceWorkerRegistration*, WebSyncGetRegistrationsCallbacks*) = 0;
// Takes ownership of the WebSyncGetPermissionStatusCallbacks.
// Does not take ownership of the WebServiceWorkerRegistration.
- virtual void getPermissionStatus(blink::WebSyncRegistration::Periodicity, WebServiceWorkerRegistration*, WebSyncGetPermissionStatusCallbacks*) = 0;
+ virtual void getPermissionStatus(WebServiceWorkerRegistration*, WebSyncGetPermissionStatusCallbacks*) = 0;
// Takes ownership of the WebSyncNotifyWhenFinishedCallbacks.
virtual void notifyWhenFinished(int64_t handleId, WebSyncNotifyWhenFinishedCallbacks*) = 0;
diff --git a/third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h b/third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h
index 880aea4..1fabc78 100644
--- a/third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h
+++ b/third_party/WebKit/public/platform/modules/background_sync/WebSyncRegistration.h
@@ -20,28 +20,18 @@ struct WebSyncRegistration {
enum { UNREGISTERED_SYNC_ID = -1};
- enum Periodicity {
- PeriodicityPeriodic = 0,
- PeriodicityOneShot,
- PeriodicityLast = PeriodicityOneShot
- };
-
WebSyncRegistration()
: id(UNREGISTERED_SYNC_ID)
- , periodicity(PeriodicityOneShot)
, tag("")
- , minPeriodMs(0)
, networkState(NetworkState::NetworkStateOnline)
{
}
- WebSyncRegistration(int64_t id, Periodicity periodicity,
- const WebString& registrationTag, unsigned long minPeriodMs,
+ WebSyncRegistration(int64_t id,
+ const WebString& registrationTag,
NetworkState networkState)
: id(id)
- , periodicity(periodicity)
, tag(registrationTag)
- , minPeriodMs(minPeriodMs)
, networkState(networkState)
{
}
@@ -49,19 +39,7 @@ struct WebSyncRegistration {
/* Internal identity; not exposed to JS API. */
int64_t id;
- /* Internal flag; not directly exposed to JS API.
- * Instead, this determines whether this object is represented in JS as a
- * SyncRegistration or a PeriodicSyncRegistration.
- */
- Periodicity periodicity;
-
WebString tag;
-
- /* Minimum time between periodic sync events, in milliseconds. A 0 value
- * here means that the event is a one-shot (not periodic.)
- */
- unsigned long minPeriodMs;
-
NetworkState networkState;
};
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 4f4657c..631b24c 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -2811,9 +2811,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>
Records the number of sync events which were fired in a batch. A batch is
defined as the set of sync events dispatched at the same time by the
- BackgroundSyncManager. Periodic syncs often run in a batch. One-shots
- usually run individually (a batch of one), unless the device was offline and
- multiple are waiting for the device to go back online.
+ BackgroundSyncManager. One-shots usually run individually (a batch of one),
+ unless the device was offline and multiple are waiting for the device to go
+ back online.
</summary>
</histogram>
@@ -2860,6 +2860,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="BackgroundSync.Event.PeriodicResultPattern"
enum="BackgroundSyncResultPattern">
<owner>jkarlin@chromium.org</owner>
+ <obsolete>
+ Stopped recording as of 1/2016.
+ </obsolete>
<summary>
Records whether a one-shot sync event succeeded or failed and whether the
sync event finished in the foreground or background.
@@ -2873,6 +2876,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="BackgroundSync.Event.PeriodicStartedInForeground"
enum="BooleanInForeground">
<owner>jkarlin@chromium.org</owner>
+ <obsolete>
+ Stopped recording as of 1/2016.
+ </obsolete>
<summary>
Records whether a periodic sync event started firing in the foreground or
background. Called shortly before the event is fired.
@@ -2956,6 +2962,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="BackgroundSync.Registration.Periodic"
enum="BackgroundSyncStatus">
<owner>iclelland@chromium.org</owner>
+ <obsolete>
+ Stopped recording as of 1/2016.
+ </obsolete>
<summary>
Records the result of attempting to register a periodic sync.
</summary>
@@ -2964,6 +2973,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="BackgroundSync.Registration.Periodic.IsDuplicate"
enum="BooleanRegistrationIsDuplicate">
<owner>iclelland@chromium.org</owner>
+ <obsolete>
+ Stopped recording as of 1/2016.
+ </obsolete>
<summary>
Records whether a periodic sync registration exactly duplicates an existing
registered sync.
@@ -2981,6 +2993,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="BackgroundSync.Unregistration.Periodic"
enum="BackgroundSyncStatus">
<owner>iclelland@chromium.org</owner>
+ <obsolete>
+ Stopped recording as of 1/2016.
+ </obsolete>
<summary>
Records the result of attempting to unregister a periodic sync.
</summary>