Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1240)

Unified Diff: content/browser/background_sync/background_sync_manager_unittest.cc

Issue 1763123002: [BackgroundSync] Remove BackgroundSyncRegistrationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS7 Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/background_sync/background_sync_manager_unittest.cc
diff --git a/content/browser/background_sync/background_sync_manager_unittest.cc b/content/browser/background_sync/background_sync_manager_unittest.cc
index c8f96f1d0a22d768f3a9b683e7aed5873ad4e979..cefb8f6f4c0088647a12748e542dca077084d601 100644
--- a/content/browser/background_sync/background_sync_manager_unittest.cc
+++ b/content/browser/background_sync/background_sync_manager_unittest.cc
@@ -18,7 +18,6 @@
#include "base/test/simple_test_clock.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/background_sync/background_sync_network_observer.h"
-#include "content/browser/background_sync/background_sync_registration_handle.h"
#include "content/browser/background_sync/background_sync_status.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
@@ -200,7 +199,7 @@ class TestBackgroundSyncManager : public BackgroundSyncManager {
}
void DispatchSyncEvent(
- BackgroundSyncRegistrationHandle::HandleId handle_id,
+ const std::string& tag,
const scoped_refptr<ServiceWorkerVersion>& active_version,
BackgroundSyncEventLastChance last_chance,
const ServiceWorkerVersion::StatusCallback& callback) override {
@@ -320,20 +319,19 @@ class BackgroundSyncManagerTest : public testing::Test {
void StatusAndRegistrationCallback(
bool* was_called,
BackgroundSyncStatus status,
- scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle) {
+ scoped_ptr<BackgroundSyncRegistration> registration) {
*was_called = true;
callback_status_ = status;
- callback_registration_handle_ = std::move(registration_handle);
+ callback_registration_ = std::move(registration);
}
void StatusAndRegistrationsCallback(
bool* was_called,
BackgroundSyncStatus status,
- scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>
- registration_handles) {
+ scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations) {
*was_called = true;
callback_status_ = status;
- callback_registration_handles_ = std::move(registration_handles);
+ callback_registrations_ = std::move(registrations);
}
void StatusCallback(bool* was_called, BackgroundSyncStatus status) {
@@ -343,8 +341,6 @@ class BackgroundSyncManagerTest : public testing::Test {
protected:
void CreateBackgroundSyncManager() {
- ClearRegistrationHandles();
-
test_background_sync_manager_ =
new TestBackgroundSyncManager(helper_->context_wrapper());
background_sync_manager_.reset(test_background_sync_manager_);
@@ -365,12 +361,6 @@ class BackgroundSyncManagerTest : public testing::Test {
base::RunLoop().RunUntilIdle();
}
- // Clear the registrations so that the BackgroundSyncManager can release them.
- void ClearRegistrationHandles() {
- callback_registration_handle_.reset();
- callback_registration_handles_.reset();
- }
-
void SetupBackgroundSyncManager() {
CreateBackgroundSyncManager();
InitBackgroundSyncManager();
@@ -389,7 +379,6 @@ class BackgroundSyncManagerTest : public testing::Test {
}
void DeleteBackgroundSyncManager() {
- ClearRegistrationHandles();
background_sync_manager_.reset();
test_background_sync_manager_ = nullptr;
test_clock_ = nullptr;
@@ -443,13 +432,13 @@ class BackgroundSyncManagerTest : public testing::Test {
EXPECT_TRUE(was_called);
if (callback_status_ == BACKGROUND_SYNC_STATUS_OK) {
- for (auto iter = callback_registration_handles_->begin();
- iter < callback_registration_handles_->end(); ++iter) {
+ for (auto iter = callback_registrations_->begin();
+ iter < callback_registrations_->end(); ++iter) {
if ((*iter)->options()->tag == registration_options.tag) {
- // Transfer the matching registration handle out of the vector into
- // callback_registration_handle_ for testing.
- callback_registration_handle_.reset(*iter);
- callback_registration_handles_->weak_erase(iter);
+ // Transfer the matching registration out of the vector into
+ // callback_registration_ for testing.
+ callback_registration_.reset(*iter);
+ callback_registrations_->weak_erase(iter);
return true;
}
}
@@ -564,9 +553,8 @@ class BackgroundSyncManagerTest : public testing::Test {
// Callback values.
BackgroundSyncStatus callback_status_ = BACKGROUND_SYNC_STATUS_OK;
- scoped_ptr<BackgroundSyncRegistrationHandle> callback_registration_handle_;
- scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>
- callback_registration_handles_;
+ scoped_ptr<BackgroundSyncRegistration> callback_registration_;
+ scoped_ptr<ScopedVector<BackgroundSyncRegistration>> callback_registrations_;
ServiceWorkerStatusCode callback_sw_status_code_ = SERVICE_WORKER_OK;
int sync_events_called_ = 0;
ServiceWorkerVersion::StatusCallback sync_fired_callback_;
@@ -579,8 +567,8 @@ TEST_F(BackgroundSyncManagerTest, Register) {
TEST_F(BackgroundSyncManagerTest, RegistractionIntact) {
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_STREQ(sync_options_1_.tag.c_str(),
- callback_registration_handle_->options()->tag.c_str());
- EXPECT_TRUE(callback_registration_handle_->IsValid());
+ callback_registration_->options()->tag.c_str());
+ EXPECT_TRUE(callback_registration_->IsValid());
}
TEST_F(BackgroundSyncManagerTest, RegisterWithoutLiveSWRegistration) {
@@ -603,20 +591,6 @@ TEST_F(BackgroundSyncManagerTest, RegisterBadBackend) {
EXPECT_FALSE(GetRegistration(sync_options_1_));
}
-TEST_F(BackgroundSyncManagerTest, DuplicateRegistrationHandle) {
- EXPECT_TRUE(Register(sync_options_1_));
- EXPECT_TRUE(
- sync_options_1_.Equals(*callback_registration_handle_->options()));
-
- scoped_ptr<BackgroundSyncRegistrationHandle> dup_handle =
- background_sync_manager_->DuplicateRegistrationHandle(
- callback_registration_handle_->handle_id());
-
- EXPECT_TRUE(sync_options_1_.Equals(*dup_handle->options()));
- EXPECT_NE(callback_registration_handle_->handle_id(),
- dup_handle->handle_id());
-}
-
TEST_F(BackgroundSyncManagerTest, TwoRegistrations) {
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_TRUE(Register(sync_options_2_));
@@ -646,15 +620,15 @@ TEST_F(BackgroundSyncManagerTest, GetRegistrationBadBackend) {
TEST_F(BackgroundSyncManagerTest, GetRegistrationsZero) {
EXPECT_TRUE(GetRegistrations());
- EXPECT_EQ(0u, callback_registration_handles_->size());
+ EXPECT_EQ(0u, callback_registrations_->size());
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsOne) {
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_TRUE(GetRegistrations());
- EXPECT_EQ(1u, callback_registration_handles_->size());
- sync_options_1_.Equals(*(*callback_registration_handles_)[0]->options());
+ EXPECT_EQ(1u, callback_registrations_->size());
+ sync_options_1_.Equals(*(*callback_registrations_)[0]->options());
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsTwo) {
@@ -662,9 +636,9 @@ TEST_F(BackgroundSyncManagerTest, GetRegistrationsTwo) {
EXPECT_TRUE(Register(sync_options_2_));
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());
+ EXPECT_EQ(2u, callback_registrations_->size());
+ sync_options_1_.Equals(*(*callback_registrations_)[0]->options());
+ sync_options_2_.Equals(*(*callback_registrations_)[1]->options());
}
TEST_F(BackgroundSyncManagerTest, GetRegistrationsBadBackend) {
@@ -703,14 +677,12 @@ TEST_F(BackgroundSyncManagerTest, RegisterMaxTagLength) {
TEST_F(BackgroundSyncManagerTest, RegistrationIncreasesId) {
EXPECT_TRUE(Register(sync_options_1_));
- scoped_ptr<BackgroundSyncRegistrationHandle> registered_handle =
- std::move(callback_registration_handle_);
BackgroundSyncRegistration::RegistrationId cur_id =
- registered_handle->handle_id();
+ callback_registration_->id();
EXPECT_TRUE(GetRegistration(sync_options_1_));
EXPECT_TRUE(Register(sync_options_2_));
- EXPECT_LT(cur_id, callback_registration_handle_->handle_id());
+ EXPECT_LT(cur_id, callback_registration_->id());
}
TEST_F(BackgroundSyncManagerTest, RebootRecovery) {
@@ -907,15 +879,14 @@ TEST_F(BackgroundSyncManagerTest, StoreAndRetrievePreservesValues) {
SetupBackgroundSyncManager();
EXPECT_TRUE(GetRegistration(options));
- EXPECT_TRUE(options.Equals(*callback_registration_handle_->options()));
+ EXPECT_TRUE(options.Equals(*callback_registration_->options()));
}
TEST_F(BackgroundSyncManagerTest, EmptyTagSupported) {
sync_options_1_.tag = "";
EXPECT_TRUE(Register(sync_options_1_));
EXPECT_TRUE(GetRegistration(sync_options_1_));
- EXPECT_TRUE(
- sync_options_1_.Equals(*callback_registration_handle_->options()));
+ EXPECT_TRUE(sync_options_1_.Equals(*callback_registration_->options()));
}
TEST_F(BackgroundSyncManagerTest, FiresOnRegistration) {

Powered by Google App Engine
This is Rietveld 408576698