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 {
message BackgroundSyncRegistrationProto {
required int64 id = 1;
required string name = 2;
required string tag = 2;
required bool fire_once = 3;
required int64 min_period = 4;
required SyncNetworkState network_state = 5;
......
......@@ -73,7 +73,7 @@ void BackgroundSyncManager::Register(
void BackgroundSyncManager::Unregister(
const GURL& origin,
int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
......@@ -86,14 +86,14 @@ void BackgroundSyncManager::Unregister(
op_scheduler_.ScheduleOperation(base::Bind(
&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)));
}
void BackgroundSyncManager::GetRegistration(
const GURL& origin,
int64 sw_registration_id,
const std::string sync_registration_name,
const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
......@@ -107,7 +107,7 @@ void BackgroundSyncManager::GetRegistration(
op_scheduler_.ScheduleOperation(base::Bind(
&BackgroundSyncManager::GetRegistrationImpl,
weak_ptr_factory_.GetWeakPtr(), origin, sw_registration_id,
sync_registration_name, MakeStatusAndRegistrationCompletion(callback)));
sync_registration_tag, MakeStatusAndRegistrationCompletion(callback)));
}
void BackgroundSyncManager::OnRegistrationDeleted(int64 registration_id,
......@@ -194,10 +194,10 @@ void BackgroundSyncManager::InitDidGetDataFromBackend(
}
BackgroundSyncRegistration* registration =
&registrations->name_to_registration_map[registration_proto.name()];
&registrations->tag_to_registration_map[registration_proto.tag()];
registration->id = registration_proto.id();
registration->name = registration_proto.name();
registration->tag = registration_proto.tag();
registration->fire_once = registration_proto.fire_once();
registration->min_period = registration_proto.min_period();
registration->network_state = registration_proto.network_state();
......@@ -233,7 +233,7 @@ void BackgroundSyncManager::RegisterImpl(
}
BackgroundSyncRegistration existing_registration;
if (LookupRegistration(sw_registration_id, sync_registration.name,
if (LookupRegistration(sw_registration_id, sync_registration.tag,
&existing_registration)) {
if (existing_registration.Equals(sync_registration)) {
base::MessageLoop::current()->PostTask(
......@@ -306,7 +306,7 @@ void BackgroundSyncManager::DisableAndClearManagerClearedOne(
bool BackgroundSyncManager::LookupRegistration(
int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration* existing_registration) {
SWIdToRegistrationsMap::iterator it =
sw_to_registrations_map_.find(sw_registration_id);
......@@ -314,14 +314,13 @@ bool BackgroundSyncManager::LookupRegistration(
return false;
const BackgroundSyncRegistrations& registrations = it->second;
const auto name_and_registration_iter =
registrations.name_to_registration_map.find(sync_registration_name);
if (name_and_registration_iter ==
registrations.name_to_registration_map.end())
const auto tag_and_registration_iter =
registrations.tag_to_registration_map.find(sync_registration_tag);
if (tag_and_registration_iter == registrations.tag_to_registration_map.end())
return false;
if (existing_registration)
*existing_registration = name_and_registration_iter->second;
*existing_registration = tag_and_registration_iter->second;
return true;
}
......@@ -336,14 +335,14 @@ void BackgroundSyncManager::StoreRegistrations(
BackgroundSyncRegistrationsProto registrations_proto;
registrations_proto.set_next_registration_id(registrations.next_id);
for (const auto& name_and_registration :
registrations.name_to_registration_map) {
for (const auto& tag_and_registration :
registrations.tag_to_registration_map) {
const BackgroundSyncRegistration& registration =
name_and_registration.second;
tag_and_registration.second;
BackgroundSyncRegistrationProto* registration_proto =
registrations_proto.add_registration();
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_min_period(registration.min_period);
registration_proto->set_network_state(registration.network_state);
......@@ -386,14 +385,14 @@ void BackgroundSyncManager::RegisterDidStore(
void BackgroundSyncManager::RemoveRegistrationFromMap(
int64 sw_registration_id,
const std::string& sync_registration_name) {
const std::string& sync_registration_tag) {
DCHECK(
LookupRegistration(sw_registration_id, sync_registration_name, nullptr));
LookupRegistration(sw_registration_id, sync_registration_tag, nullptr));
BackgroundSyncRegistrations* registrations =
&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(
......@@ -404,7 +403,7 @@ void BackgroundSyncManager::AddRegistrationToMap(
BackgroundSyncRegistrations* registrations =
&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;
}
......@@ -431,7 +430,7 @@ void BackgroundSyncManager::GetDataFromBackend(
void BackgroundSyncManager::UnregisterImpl(
const GURL& origin,
int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback) {
if (disabled_) {
......@@ -441,7 +440,7 @@ void BackgroundSyncManager::UnregisterImpl(
}
BackgroundSyncRegistration existing_registration;
if (!LookupRegistration(sw_registration_id, sync_registration_name,
if (!LookupRegistration(sw_registration_id, sync_registration_tag,
&existing_registration) ||
existing_registration.id != sync_registration_id) {
base::MessageLoop::current()->PostTask(
......@@ -449,7 +448,7 @@ void BackgroundSyncManager::UnregisterImpl(
return;
}
RemoveRegistrationFromMap(sw_registration_id, sync_registration_name);
RemoveRegistrationFromMap(sw_registration_id, sync_registration_tag);
StoreRegistrations(
origin, sw_registration_id,
......@@ -483,7 +482,7 @@ void BackgroundSyncManager::UnregisterDidStore(
void BackgroundSyncManager::GetRegistrationImpl(
const GURL& origin,
int64 sw_registration_id,
const std::string sync_registration_name,
const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback) {
if (disabled_) {
base::MessageLoop::current()->PostTask(
......@@ -493,7 +492,7 @@ void BackgroundSyncManager::GetRegistrationImpl(
}
BackgroundSyncRegistration out_registration;
if (!LookupRegistration(sw_registration_id, sync_registration_name,
if (!LookupRegistration(sw_registration_id, sync_registration_tag,
&out_registration)) {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(callback, ERROR_TYPE_NOT_FOUND,
......
......@@ -55,14 +55,14 @@ class CONTENT_EXPORT BackgroundSyncManager
BackgroundSyncRegistration() {}
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 &&
network_state == other.network_state &&
power_state == other.power_state;
}
RegistrationId id = kInvalidRegistrationId;
std::string name;
std::string tag;
bool fire_once = true;
int64 min_period = 0;
SyncNetworkState network_state = NETWORK_STATE_ONLINE;
......@@ -70,7 +70,7 @@ class CONTENT_EXPORT BackgroundSyncManager
};
struct CONTENT_EXPORT BackgroundSyncRegistrations {
using NameToRegistrationMap =
using TagToRegistrationMap =
std::map<std::string, BackgroundSyncRegistration>;
static const BackgroundSyncRegistration::RegistrationId kInitialId;
......@@ -79,7 +79,7 @@ class CONTENT_EXPORT BackgroundSyncManager
BackgroundSyncRegistration::RegistrationId next_id);
~BackgroundSyncRegistrations();
NameToRegistrationMap name_to_registration_map;
TagToRegistrationMap tag_to_registration_map;
BackgroundSyncRegistration::RegistrationId next_id;
};
......@@ -92,7 +92,7 @@ class CONTENT_EXPORT BackgroundSyncManager
~BackgroundSyncManager() override;
// 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
// 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
......@@ -102,15 +102,15 @@ class CONTENT_EXPORT BackgroundSyncManager
const BackgroundSyncRegistration& sync_registration,
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
// 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
// |callback| with ErrorTypeOK on success.
void Unregister(
const GURL& origin,
int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback);
......@@ -119,7 +119,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// exist. Calls |callback| with ErrorTypeOK on success.
void GetRegistration(const GURL& origin,
int64 sw_registration_id,
const std::string sync_registration_name,
const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback);
// ServiceWorkerContextObserver overrides.
......@@ -166,7 +166,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// Returns the existing registration in |existing_registration| if it is not
// null.
bool LookupRegistration(int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration* existing_registration);
// Store all registrations for a given |sw_registration_id|.
......@@ -176,7 +176,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// Removes the registration if it is in the map.
void RemoveRegistrationFromMap(int64 sw_registration_id,
const std::string& sync_registration_name);
const std::string& sync_registration_tag);
void AddRegistrationToMap(
int64 sw_registration_id,
......@@ -202,7 +202,7 @@ class CONTENT_EXPORT BackgroundSyncManager
void UnregisterImpl(
const GURL& origin,
int64 sw_registration_id,
const std::string& sync_registration_name,
const std::string& sync_registration_tag,
BackgroundSyncRegistration::RegistrationId sync_registration_id,
const StatusCallback& callback);
void UnregisterDidStore(
......@@ -213,7 +213,7 @@ class CONTENT_EXPORT BackgroundSyncManager
// GetRegistration callbacks
void GetRegistrationImpl(const GURL& origin,
int64 sw_registration_id,
const std::string sync_registration_name,
const std::string sync_registration_tag,
const StatusAndRegistrationCallback& callback);
// OnRegistrationDeleted callbacks
......
......@@ -141,8 +141,8 @@ class BackgroundSyncManagerTest : public testing::Test {
sync_reg_2_(BackgroundSyncManager::BackgroundSyncRegistration()),
callback_error_(BackgroundSyncManager::ERROR_TYPE_OK),
callback_sw_status_code_(SERVICE_WORKER_OK) {
sync_reg_1_.name = "foo";
sync_reg_2_.name = "bar";
sync_reg_1_.tag = "foo";
sync_reg_2_.tag = "bar";
}
void SetUp() override {
......@@ -228,7 +228,7 @@ class BackgroundSyncManagerTest : public testing::Test {
sync_registration) {
bool was_called = false;
background_sync_manager_->Unregister(
GURL(kOrigin), sw_registration_id, sync_registration.name,
GURL(kOrigin), sw_registration_id, sync_registration.tag,
sync_registration.id,
base::Bind(&BackgroundSyncManagerTest::StatusCallback,
base::Unretained(this), &was_called));
......@@ -237,24 +237,24 @@ class BackgroundSyncManagerTest : public testing::Test {
return callback_error_ == BackgroundSyncManager::ERROR_TYPE_OK;
}
bool GetRegistration(const std::string& sync_registration_name) {
bool GetRegistration(const std::string& sync_registration_tag) {
return GetRegistrationWithServiceWorkerId(sw_registration_id_1_,
sync_registration_name);
sync_registration_tag);
}
bool GetRegistrationWithServiceWorkerId(
int64 sw_registration_id,
const std::string& sync_registration_name) {
const std::string& sync_registration_tag) {
bool was_called = false;
background_sync_manager_->GetRegistration(
GURL(kOrigin), sw_registration_id, sync_registration_name,
GURL(kOrigin), sw_registration_id, sync_registration_tag,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &was_called));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(was_called);
if (callback_error_ == BackgroundSyncManager::ERROR_TYPE_OK)
EXPECT_TRUE(sync_registration_name == callback_registration_.name);
EXPECT_TRUE(sync_registration_tag == callback_registration_.tag);
return callback_error_ == BackgroundSyncManager::ERROR_TYPE_OK;
}
......@@ -300,7 +300,7 @@ TEST_F(BackgroundSyncManagerTest, Register) {
TEST_F(BackgroundSyncManagerTest, RegistractionIntact) {
EXPECT_TRUE(Register(sync_reg_1_));
EXPECT_STREQ(sync_reg_1_.name.c_str(), callback_registration_.name.c_str());
EXPECT_STREQ(sync_reg_1_.tag.c_str(), callback_registration_.tag.c_str());
EXPECT_NE(
BackgroundSyncManager::BackgroundSyncRegistration::kInvalidRegistrationId,
callback_registration_.id);
......@@ -332,7 +332,7 @@ TEST_F(BackgroundSyncManagerTest, RegisterBadBackend) {
EXPECT_FALSE(Register(sync_reg_1_));
manager->set_corrupt_backend(false);
EXPECT_FALSE(Register(sync_reg_1_));
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, TwoRegistrations) {
......@@ -341,32 +341,32 @@ TEST_F(BackgroundSyncManagerTest, TwoRegistrations) {
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationNonExisting) {
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationExisting) {
EXPECT_TRUE(Register(sync_reg_1_));
EXPECT_TRUE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_2_.name));
EXPECT_TRUE(GetRegistration(sync_reg_1_.tag));
EXPECT_FALSE(GetRegistration(sync_reg_2_.tag));
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationBadBackend) {
TestBackgroundSyncManager* manager = UseTestBackgroundSyncManager();
EXPECT_TRUE(Register(sync_reg_1_));
manager->set_corrupt_backend(true);
EXPECT_TRUE(GetRegistration(sync_reg_1_.name));
EXPECT_TRUE(GetRegistration(sync_reg_1_.tag));
EXPECT_FALSE(Register(sync_reg_2_));
// Registration should have discovered the bad backend and disabled the
// BackgroundSyncManager.
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
manager->set_corrupt_backend(false);
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, Unregister) {
EXPECT_TRUE(Register(sync_reg_1_));
EXPECT_TRUE(Unregister(callback_registration_));
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, UnregisterWrongId) {
......@@ -390,7 +390,7 @@ TEST_F(BackgroundSyncManagerTest, UnregisterSecond) {
EXPECT_TRUE(Register(sync_reg_1_));
EXPECT_TRUE(Register(sync_reg_2_));
EXPECT_TRUE(Unregister(callback_registration_));
EXPECT_TRUE(GetRegistration(sync_reg_1_.name));
EXPECT_TRUE(GetRegistration(sync_reg_1_.tag));
EXPECT_TRUE(Register(sync_reg_2_));
}
......@@ -404,8 +404,8 @@ TEST_F(BackgroundSyncManagerTest, UnregisterBadBackend) {
// Unregister should have discovered the bad backend and disabled the
// BackgroundSyncManager.
manager->set_corrupt_backend(false);
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_2_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
EXPECT_FALSE(GetRegistration(sync_reg_2_.tag));
}
TEST_F(BackgroundSyncManagerTest, RegistrationIncreasesId) {
......@@ -415,7 +415,7 @@ TEST_F(BackgroundSyncManagerTest, RegistrationIncreasesId) {
BackgroundSyncManager::BackgroundSyncRegistration::RegistrationId cur_id =
callback_registration_.id;
EXPECT_TRUE(GetRegistration(sync_reg_1_.name));
EXPECT_TRUE(GetRegistration(sync_reg_1_.tag));
EXPECT_TRUE(Register(sync_reg_2_));
EXPECT_LT(cur_id, callback_registration_.id);
cur_id = callback_registration_.id;
......@@ -431,8 +431,8 @@ TEST_F(BackgroundSyncManagerTest, RebootRecovery) {
background_sync_manager_ =
BackgroundSyncManager::Create(helper_->context_wrapper());
EXPECT_TRUE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_2_.name));
EXPECT_TRUE(GetRegistration(sync_reg_1_.tag));
EXPECT_FALSE(GetRegistration(sync_reg_2_.tag));
}
TEST_F(BackgroundSyncManagerTest, RebootRecoveryTwoServiceWorkers) {
......@@ -443,18 +443,18 @@ TEST_F(BackgroundSyncManagerTest, RebootRecoveryTwoServiceWorkers) {
BackgroundSyncManager::Create(helper_->context_wrapper());
EXPECT_TRUE(GetRegistrationWithServiceWorkerId(sw_registration_id_1_,
sync_reg_1_.name));
sync_reg_1_.tag));
EXPECT_FALSE(GetRegistrationWithServiceWorkerId(sw_registration_id_1_,
sync_reg_2_.name));
sync_reg_2_.tag));
EXPECT_FALSE(GetRegistrationWithServiceWorkerId(sw_registration_id_2_,
sync_reg_1_.name));
sync_reg_1_.tag));
EXPECT_TRUE(GetRegistrationWithServiceWorkerId(sw_registration_id_2_,
sync_reg_2_.name));
sync_reg_2_.tag));
EXPECT_TRUE(GetRegistrationWithServiceWorkerId(sw_registration_id_1_,
sync_reg_1_.name));
sync_reg_1_.tag));
EXPECT_TRUE(GetRegistrationWithServiceWorkerId(sw_registration_id_2_,
sync_reg_2_.name));
sync_reg_2_.tag));
EXPECT_TRUE(RegisterWithServiceWorkerId(sw_registration_id_1_, sync_reg_2_));
EXPECT_TRUE(RegisterWithServiceWorkerId(sw_registration_id_2_, sync_reg_1_));
......@@ -468,7 +468,7 @@ TEST_F(BackgroundSyncManagerTest, InitWithBadBackend) {
manager->DoInit();
EXPECT_FALSE(Register(sync_reg_1_));
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, SequentialOperations) {
......@@ -490,12 +490,12 @@ TEST_F(BackgroundSyncManagerTest, SequentialOperations) {
GURL(kOrigin), sw_registration_id_1_, sync_reg_1_,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &register_called));
manager->Unregister(GURL(kOrigin), sw_registration_id_1_, sync_reg_1_.name,
manager->Unregister(GURL(kOrigin), sw_registration_id_1_, sync_reg_1_.tag,
kExpectedInitialId,
base::Bind(&BackgroundSyncManagerTest::StatusCallback,
base::Unretained(this), &unregister_called));
manager->GetRegistration(
GURL(kOrigin), sw_registration_id_1_, sync_reg_1_.name,
GURL(kOrigin), sw_registration_id_1_, sync_reg_1_.tag,
base::Bind(&BackgroundSyncManagerTest::StatusAndRegistrationCallback,
base::Unretained(this), &get_registration_called));
......@@ -533,7 +533,7 @@ TEST_F(BackgroundSyncManagerTest, SequentialOperations) {
TEST_F(BackgroundSyncManagerTest, UnregisterServiceWorker) {
EXPECT_TRUE(Register(sync_reg_1_));
UnregisterServiceWorker(sw_registration_id_1_);
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest,
......@@ -562,14 +562,14 @@ TEST_F(BackgroundSyncManagerTest,
EXPECT_EQ(BackgroundSyncManager::ERROR_TYPE_STORAGE, callback_error_);
manager->set_delay_backend(false);
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, DeleteAndStartOverServiceWorkerContext) {
EXPECT_TRUE(Register(sync_reg_1_));
helper_->context()->ScheduleDeleteAndStartOver();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
}
TEST_F(BackgroundSyncManagerTest, DisabledManagerWorksAfterBrowserRestart) {
......@@ -584,13 +584,13 @@ TEST_F(BackgroundSyncManagerTest, DisabledManagerWorksAfterBrowserRestart) {
// The manager is now disabled and not accepting new requests until browser
// restart or notification that the storage has been wiped.
manager->set_corrupt_backend(false);
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
EXPECT_FALSE(Register(sync_reg_2_));
// Simulate restarting the browser by creating a new BackgroundSyncManager.
background_sync_manager_.reset(
new TestBackgroundSyncManager(helper_->context_wrapper()));
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
EXPECT_TRUE(Register(sync_reg_1_));
}
......@@ -618,8 +618,8 @@ TEST_F(BackgroundSyncManagerTest, DisabledManagerWorksAfterDeleteAndStartOver) {
EXPECT_TRUE(called);
EXPECT_TRUE(Register(sync_reg_2_));
EXPECT_FALSE(GetRegistration(sync_reg_1_.name));
EXPECT_TRUE(GetRegistration(sync_reg_2_.name));
EXPECT_FALSE(GetRegistration(sync_reg_1_.tag));
EXPECT_TRUE(GetRegistration(sync_reg_2_.tag));
}
TEST_F(BackgroundSyncManagerTest, RegistrationEqualsId) {
......@@ -631,11 +631,11 @@ TEST_F(BackgroundSyncManagerTest, RegistrationEqualsId) {
EXPECT_TRUE(reg_1.Equals(reg_2));
}
TEST_F(BackgroundSyncManagerTest, RegistrationEqualsName) {
TEST_F(BackgroundSyncManagerTest, RegistrationEqualsTag) {
BackgroundSyncManager::BackgroundSyncRegistration reg_1;
BackgroundSyncManager::BackgroundSyncRegistration reg_2;
EXPECT_TRUE(reg_1.Equals(reg_2));
reg_2.name = "bar";
reg_2.tag = "bar";
EXPECT_FALSE(reg_1.Equals(reg_2));
}
......@@ -676,7 +676,7 @@ TEST_F(BackgroundSyncManagerTest, RegistrationEqualsPowerState) {
TEST_F(BackgroundSyncManagerTest, StoreAndRetrievePreservesValues) {
BackgroundSyncManager::BackgroundSyncRegistration reg_1;
// Set non-default values for each field.
reg_1.name = "foo";
reg_1.tag = "foo";
reg_1.fire_once = !reg_1.fire_once;
reg_1.min_period += 1;
EXPECT_NE(NETWORK_STATE_ANY, reg_1.network_state);
......@@ -691,7 +691,7 @@ TEST_F(BackgroundSyncManagerTest, StoreAndRetrievePreservesValues) {
// disk.
UseTestBackgroundSyncManager();
EXPECT_TRUE(GetRegistration(reg_1.name));
EXPECT_TRUE(GetRegistration(reg_1.tag));
EXPECT_TRUE(reg_1.Equals(callback_registration_));
}
......
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