Commit 1c8dbbf5 authored by jkarlin's avatar jkarlin Committed by Commit bot

[BackgroundSyncManager] Rename BackgroundSyncRegistration.name to tag

This refactoring of 'name' to 'tag' is part of tracking the latest spec changes found in https://github.com/slightlyoff/BackgroundSync/pull/74

BUG=474573

Review URL: https://codereview.chromium.org/1068863003

Cr-Commit-Position: refs/heads/master@{#324233}
parent 5eef409e
...@@ -21,7 +21,7 @@ enum SyncPowerState { ...@@ -21,7 +21,7 @@ enum SyncPowerState {
message BackgroundSyncRegistrationProto { message BackgroundSyncRegistrationProto {
required int64 id = 1; required int64 id = 1;
required string name = 2; required string tag = 2;
required bool fire_once = 3; required bool fire_once = 3;
required int64 min_period = 4; required int64 min_period = 4;
required SyncNetworkState network_state = 5; required SyncNetworkState network_state = 5;
......
...@@ -73,7 +73,7 @@ void BackgroundSyncManager::Register( ...@@ -73,7 +73,7 @@ void BackgroundSyncManager::Register(
void BackgroundSyncManager::Unregister( void BackgroundSyncManager::Unregister(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id, BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback) { const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
...@@ -86,14 +86,14 @@ void BackgroundSyncManager::Unregister( ...@@ -86,14 +86,14 @@ void BackgroundSyncManager::Unregister(
op_scheduler_.ScheduleOperation(base::Bind( op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::UnregisterImpl, weak_ptr_factory_.GetWeakPtr(), &BackgroundSyncManager::UnregisterImpl, weak_ptr_factory_.GetWeakPtr(),
origin, sw_registration_id, sync_registration_name, sync_registration_id, origin, sw_registration_id, sync_registration_tag, sync_registration_id,
MakeStatusCompletion(callback))); MakeStatusCompletion(callback)));
} }
void BackgroundSyncManager::GetRegistration( void BackgroundSyncManager::GetRegistration(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string sync_registration_name, const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback) { const StatusAndRegistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
...@@ -107,7 +107,7 @@ void BackgroundSyncManager::GetRegistration( ...@@ -107,7 +107,7 @@ void BackgroundSyncManager::GetRegistration(
op_scheduler_.ScheduleOperation(base::Bind( op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::GetRegistrationImpl, &BackgroundSyncManager::GetRegistrationImpl,
weak_ptr_factory_.GetWeakPtr(), origin, sw_registration_id, weak_ptr_factory_.GetWeakPtr(), origin, sw_registration_id,
sync_registration_name, MakeStatusAndRegistrationCompletion(callback))); sync_registration_tag, MakeStatusAndRegistrationCompletion(callback)));
} }
void BackgroundSyncManager::OnRegistrationDeleted(int64 registration_id, void BackgroundSyncManager::OnRegistrationDeleted(int64 registration_id,
...@@ -194,10 +194,10 @@ void BackgroundSyncManager::InitDidGetDataFromBackend( ...@@ -194,10 +194,10 @@ void BackgroundSyncManager::InitDidGetDataFromBackend(
} }
BackgroundSyncRegistration* registration = BackgroundSyncRegistration* registration =
&registrations->name_to_registration_map[registration_proto.name()]; &registrations->tag_to_registration_map[registration_proto.tag()];
registration->id = registration_proto.id(); registration->id = registration_proto.id();
registration->name = registration_proto.name(); registration->tag = registration_proto.tag();
registration->fire_once = registration_proto.fire_once(); registration->fire_once = registration_proto.fire_once();
registration->min_period = registration_proto.min_period(); registration->min_period = registration_proto.min_period();
registration->network_state = registration_proto.network_state(); registration->network_state = registration_proto.network_state();
...@@ -233,7 +233,7 @@ void BackgroundSyncManager::RegisterImpl( ...@@ -233,7 +233,7 @@ void BackgroundSyncManager::RegisterImpl(
} }
BackgroundSyncRegistration existing_registration; BackgroundSyncRegistration existing_registration;
if (LookupRegistration(sw_registration_id, sync_registration.name, if (LookupRegistration(sw_registration_id, sync_registration.tag,
&existing_registration)) { &existing_registration)) {
if (existing_registration.Equals(sync_registration)) { if (existing_registration.Equals(sync_registration)) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
...@@ -306,7 +306,7 @@ void BackgroundSyncManager::DisableAndClearManagerClearedOne( ...@@ -306,7 +306,7 @@ void BackgroundSyncManager::DisableAndClearManagerClearedOne(
bool BackgroundSyncManager::LookupRegistration( bool BackgroundSyncManager::LookupRegistration(
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration* existing_registration) { BackgroundSyncRegistration* existing_registration) {
SWIdToRegistrationsMap::iterator it = SWIdToRegistrationsMap::iterator it =
sw_to_registrations_map_.find(sw_registration_id); sw_to_registrations_map_.find(sw_registration_id);
...@@ -314,14 +314,13 @@ bool BackgroundSyncManager::LookupRegistration( ...@@ -314,14 +314,13 @@ bool BackgroundSyncManager::LookupRegistration(
return false; return false;
const BackgroundSyncRegistrations& registrations = it->second; const BackgroundSyncRegistrations& registrations = it->second;
const auto name_and_registration_iter = const auto tag_and_registration_iter =
registrations.name_to_registration_map.find(sync_registration_name); registrations.tag_to_registration_map.find(sync_registration_tag);
if (name_and_registration_iter == if (tag_and_registration_iter == registrations.tag_to_registration_map.end())
registrations.name_to_registration_map.end())
return false; return false;
if (existing_registration) if (existing_registration)
*existing_registration = name_and_registration_iter->second; *existing_registration = tag_and_registration_iter->second;
return true; return true;
} }
...@@ -336,14 +335,14 @@ void BackgroundSyncManager::StoreRegistrations( ...@@ -336,14 +335,14 @@ void BackgroundSyncManager::StoreRegistrations(
BackgroundSyncRegistrationsProto registrations_proto; BackgroundSyncRegistrationsProto registrations_proto;
registrations_proto.set_next_registration_id(registrations.next_id); registrations_proto.set_next_registration_id(registrations.next_id);
for (const auto& name_and_registration : for (const auto& tag_and_registration :
registrations.name_to_registration_map) { registrations.tag_to_registration_map) {
const BackgroundSyncRegistration& registration = const BackgroundSyncRegistration& registration =
name_and_registration.second; tag_and_registration.second;
BackgroundSyncRegistrationProto* registration_proto = BackgroundSyncRegistrationProto* registration_proto =
registrations_proto.add_registration(); registrations_proto.add_registration();
registration_proto->set_id(registration.id); registration_proto->set_id(registration.id);
registration_proto->set_name(registration.name); registration_proto->set_tag(registration.tag);
registration_proto->set_fire_once(registration.fire_once); registration_proto->set_fire_once(registration.fire_once);
registration_proto->set_min_period(registration.min_period); registration_proto->set_min_period(registration.min_period);
registration_proto->set_network_state(registration.network_state); registration_proto->set_network_state(registration.network_state);
...@@ -386,14 +385,14 @@ void BackgroundSyncManager::RegisterDidStore( ...@@ -386,14 +385,14 @@ void BackgroundSyncManager::RegisterDidStore(
void BackgroundSyncManager::RemoveRegistrationFromMap( void BackgroundSyncManager::RemoveRegistrationFromMap(
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name) { const std::string& sync_registration_tag) {
DCHECK( DCHECK(
LookupRegistration(sw_registration_id, sync_registration_name, nullptr)); LookupRegistration(sw_registration_id, sync_registration_tag, nullptr));
BackgroundSyncRegistrations* registrations = BackgroundSyncRegistrations* registrations =
&sw_to_registrations_map_[sw_registration_id]; &sw_to_registrations_map_[sw_registration_id];
registrations->name_to_registration_map.erase(sync_registration_name); registrations->tag_to_registration_map.erase(sync_registration_tag);
} }
void BackgroundSyncManager::AddRegistrationToMap( void BackgroundSyncManager::AddRegistrationToMap(
...@@ -404,7 +403,7 @@ void BackgroundSyncManager::AddRegistrationToMap( ...@@ -404,7 +403,7 @@ void BackgroundSyncManager::AddRegistrationToMap(
BackgroundSyncRegistrations* registrations = BackgroundSyncRegistrations* registrations =
&sw_to_registrations_map_[sw_registration_id]; &sw_to_registrations_map_[sw_registration_id];
registrations->name_to_registration_map[sync_registration.name] = registrations->tag_to_registration_map[sync_registration.tag] =
sync_registration; sync_registration;
} }
...@@ -431,7 +430,7 @@ void BackgroundSyncManager::GetDataFromBackend( ...@@ -431,7 +430,7 @@ void BackgroundSyncManager::GetDataFromBackend(
void BackgroundSyncManager::UnregisterImpl( void BackgroundSyncManager::UnregisterImpl(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id, BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback) { const StatusCallback& callback) {
if (disabled_) { if (disabled_) {
...@@ -441,7 +440,7 @@ void BackgroundSyncManager::UnregisterImpl( ...@@ -441,7 +440,7 @@ void BackgroundSyncManager::UnregisterImpl(
} }
BackgroundSyncRegistration existing_registration; BackgroundSyncRegistration existing_registration;
if (!LookupRegistration(sw_registration_id, sync_registration_name, if (!LookupRegistration(sw_registration_id, sync_registration_tag,
&existing_registration) || &existing_registration) ||
existing_registration.id != sync_registration_id) { existing_registration.id != sync_registration_id) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
...@@ -449,7 +448,7 @@ void BackgroundSyncManager::UnregisterImpl( ...@@ -449,7 +448,7 @@ void BackgroundSyncManager::UnregisterImpl(
return; return;
} }
RemoveRegistrationFromMap(sw_registration_id, sync_registration_name); RemoveRegistrationFromMap(sw_registration_id, sync_registration_tag);
StoreRegistrations( StoreRegistrations(
origin, sw_registration_id, origin, sw_registration_id,
...@@ -483,7 +482,7 @@ void BackgroundSyncManager::UnregisterDidStore( ...@@ -483,7 +482,7 @@ void BackgroundSyncManager::UnregisterDidStore(
void BackgroundSyncManager::GetRegistrationImpl( void BackgroundSyncManager::GetRegistrationImpl(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string sync_registration_name, const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback) { const StatusAndRegistrationCallback& callback) {
if (disabled_) { if (disabled_) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
...@@ -493,7 +492,7 @@ void BackgroundSyncManager::GetRegistrationImpl( ...@@ -493,7 +492,7 @@ void BackgroundSyncManager::GetRegistrationImpl(
} }
BackgroundSyncRegistration out_registration; BackgroundSyncRegistration out_registration;
if (!LookupRegistration(sw_registration_id, sync_registration_name, if (!LookupRegistration(sw_registration_id, sync_registration_tag,
&out_registration)) { &out_registration)) {
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND, FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND,
......
...@@ -55,14 +55,14 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -55,14 +55,14 @@ class CONTENT_EXPORT BackgroundSyncManager
BackgroundSyncRegistration() {} BackgroundSyncRegistration() {}
bool Equals(const BackgroundSyncRegistration& other) { bool Equals(const BackgroundSyncRegistration& other) {
return this->name == other.name && this->fire_once == other.fire_once && return this->tag == other.tag && this->fire_once == other.fire_once &&
this->min_period == other.min_period && this->min_period == other.min_period &&
network_state == other.network_state && network_state == other.network_state &&
power_state == other.power_state; power_state == other.power_state;
} }
RegistrationId id = kInvalidRegistrationId; RegistrationId id = kInvalidRegistrationId;
std::string name; std::string tag;
bool fire_once = true; bool fire_once = true;
int64 min_period = 0; int64 min_period = 0;
SyncNetworkState network_state = NETWORK_STATE_ONLINE; SyncNetworkState network_state = NETWORK_STATE_ONLINE;
...@@ -70,7 +70,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -70,7 +70,7 @@ class CONTENT_EXPORT BackgroundSyncManager
}; };
struct CONTENT_EXPORT BackgroundSyncRegistrations { struct CONTENT_EXPORT BackgroundSyncRegistrations {
using NameToRegistrationMap = using TagToRegistrationMap =
std::map<std::string, BackgroundSyncRegistration>; std::map<std::string, BackgroundSyncRegistration>;
static const BackgroundSyncRegistration::RegistrationId kInitialId; static const BackgroundSyncRegistration::RegistrationId kInitialId;
...@@ -79,7 +79,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -79,7 +79,7 @@ class CONTENT_EXPORT BackgroundSyncManager
BackgroundSyncRegistration::RegistrationId next_id); BackgroundSyncRegistration::RegistrationId next_id);
~BackgroundSyncRegistrations(); ~BackgroundSyncRegistrations();
NameToRegistrationMap name_to_registration_map; TagToRegistrationMap tag_to_registration_map;
BackgroundSyncRegistration::RegistrationId next_id; BackgroundSyncRegistration::RegistrationId next_id;
}; };
...@@ -92,7 +92,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -92,7 +92,7 @@ class CONTENT_EXPORT BackgroundSyncManager
~BackgroundSyncManager() override; ~BackgroundSyncManager() override;
// Stores the given background sync registration and adds it to the scheduling // Stores the given background sync registration and adds it to the scheduling
// queue. Overwrites any existing registration with the same name but // queue. Overwrites any existing registration with the same tag but
// different parameters (other than the id). Calls |callback| with ErrorTypeOK // different parameters (other than the id). Calls |callback| with ErrorTypeOK
// and the accepted registration on success. The accepted registration will // 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 // have a unique id. It may also have altered parameters if the user or UA
...@@ -102,15 +102,15 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -102,15 +102,15 @@ class CONTENT_EXPORT BackgroundSyncManager
const BackgroundSyncRegistration& sync_registration, const BackgroundSyncRegistration& sync_registration,
const StatusAndRegistrationCallback& callback); const StatusAndRegistrationCallback& callback);
// Removes the background sync registration with |sync_registration_name| if // Removes the background sync registration with |sync_registration_tag| if
// the |sync_registration_id| matches. |sync_registration_id| will not match // the |sync_registration_id| matches. |sync_registration_id| will not match
// if, for instance, a new registration with the same name has replaced it. // if, for instance, a new registration with the same tag has replaced it.
// Calls |callback| with ErrorTypeNotFound if no match is found. Calls // Calls |callback| with ErrorTypeNotFound if no match is found. Calls
// |callback| with ErrorTypeOK on success. // |callback| with ErrorTypeOK on success.
void Unregister( void Unregister(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id, BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback); const StatusCallback& callback);
...@@ -119,7 +119,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -119,7 +119,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// exist. Calls |callback| with ErrorTypeOK on success. // exist. Calls |callback| with ErrorTypeOK on success.
void GetRegistration(const GURL& origin, void GetRegistration(const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string sync_registration_name, const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback); const StatusAndRegistrationCallback& callback);
// ServiceWorkerContextObserver overrides. // ServiceWorkerContextObserver overrides.
...@@ -166,7 +166,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -166,7 +166,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// Returns the existing registration in |existing_registration| if it is not // Returns the existing registration in |existing_registration| if it is not
// null. // null.
bool LookupRegistration(int64 sw_registration_id, bool LookupRegistration(int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration* existing_registration); BackgroundSyncRegistration* existing_registration);
// Store all registrations for a given |sw_registration_id|. // Store all registrations for a given |sw_registration_id|.
...@@ -176,7 +176,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -176,7 +176,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// Removes the registration if it is in the map. // Removes the registration if it is in the map.
void RemoveRegistrationFromMap(int64 sw_registration_id, void RemoveRegistrationFromMap(int64 sw_registration_id,
const std::string& sync_registration_name); const std::string& sync_registration_tag);
void AddRegistrationToMap( void AddRegistrationToMap(
int64 sw_registration_id, int64 sw_registration_id,
...@@ -202,7 +202,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -202,7 +202,7 @@ class CONTENT_EXPORT BackgroundSyncManager
void UnregisterImpl( void UnregisterImpl(
const GURL& origin, const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string& sync_registration_name, const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id, BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback); const StatusCallback& callback);
void UnregisterDidStore( void UnregisterDidStore(
...@@ -213,7 +213,7 @@ class CONTENT_EXPORT BackgroundSyncManager ...@@ -213,7 +213,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// GetRegistration callbacks // GetRegistration callbacks
void GetRegistrationImpl(const GURL& origin, void GetRegistrationImpl(const GURL& origin,
int64 sw_registration_id, int64 sw_registration_id,
const std::string sync_registration_name, const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback); const StatusAndRegistrationCallback& callback);
// OnRegistrationDeleted callbacks // OnRegistrationDeleted callbacks
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment