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

Unified Diff: content/browser/background_sync/background_sync_manager.h

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.h
diff --git a/content/browser/background_sync/background_sync_manager.h b/content/browser/background_sync/background_sync_manager.h
index 3af826299c7bcc1c93259702c167b2659d05e9f8..2bb28ee8a7a780482401ffd4d07ef554aa4754d7 100644
--- a/content/browser/background_sync/background_sync_manager.h
+++ b/content/browser/background_sync/background_sync_manager.h
@@ -22,7 +22,6 @@
#include "base/time/clock.h"
#include "content/browser/background_sync/background_sync.pb.h"
#include "content/browser/background_sync/background_sync_registration.h"
-#include "content/browser/background_sync/background_sync_registration_handle.h"
#include "content/browser/background_sync/background_sync_status.h"
#include "content/browser/cache_storage/cache_storage_scheduler.h"
#include "content/browser/service_worker/service_worker_context_observer.h"
@@ -52,10 +51,10 @@ class CONTENT_EXPORT BackgroundSyncManager
using StatusCallback = base::Callback<void(BackgroundSyncStatus)>;
using StatusAndRegistrationCallback =
base::Callback<void(BackgroundSyncStatus,
- scoped_ptr<BackgroundSyncRegistrationHandle>)>;
+ scoped_ptr<BackgroundSyncRegistration>)>;
using StatusAndRegistrationsCallback = base::Callback<void(
BackgroundSyncStatus,
- scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>;
+ scoped_ptr<ScopedVector<BackgroundSyncRegistration>>)>;
static scoped_ptr<BackgroundSyncManager> Create(
const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context);
@@ -79,11 +78,6 @@ class CONTENT_EXPORT BackgroundSyncManager
void GetRegistrations(int64_t sw_registration_id,
const StatusAndRegistrationsCallback& callback);
- // Given a HandleId |handle_id|, return a new handle for the same
- // registration.
- scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle(
- BackgroundSyncRegistrationHandle::HandleId handle_id);
-
// ServiceWorkerContextObserver overrides.
void OnRegistrationDeleted(int64_t sw_registration_id,
const GURL& pattern) override;
@@ -103,14 +97,6 @@ class CONTENT_EXPORT BackgroundSyncManager
}
protected:
- // A registration might be referenced by the client longer than
- // the BackgroundSyncManager needs to keep track of it (e.g., the event has
- // finished firing). The BackgroundSyncManager reference counts its
- // registrations internally and every BackgroundSyncRegistrationHandle has a
- // unique handle id which maps to a locally maintained (in
- // client_registration_ids_) scoped_refptr.
- class RefCountedRegistration;
-
explicit BackgroundSyncManager(
const scoped_refptr<ServiceWorkerContextWrapper>& context);
@@ -129,7 +115,7 @@ class CONTENT_EXPORT BackgroundSyncManager
const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback&
callback);
virtual void DispatchSyncEvent(
- BackgroundSyncRegistrationHandle::HandleId handle_id,
+ const std::string& tag,
const scoped_refptr<ServiceWorkerVersion>& active_version,
BackgroundSyncEventLastChance last_chance,
const ServiceWorkerVersion::StatusCallback& callback);
@@ -141,7 +127,6 @@ class CONTENT_EXPORT BackgroundSyncManager
private:
friend class TestBackgroundSyncManager;
friend class BackgroundSyncManagerTest;
- friend class BackgroundSyncRegistrationHandle;
class RegistrationKey {
public:
@@ -161,7 +146,7 @@ class CONTENT_EXPORT BackgroundSyncManager
struct BackgroundSyncRegistrations {
using RegistrationMap =
- std::map<RegistrationKey, scoped_refptr<RefCountedRegistration>>;
+ std::map<RegistrationKey, BackgroundSyncRegistration>;
BackgroundSyncRegistrations();
BackgroundSyncRegistrations(const BackgroundSyncRegistrations& other);
@@ -177,19 +162,6 @@ class CONTENT_EXPORT BackgroundSyncManager
static const size_t kMaxTagLength = 10240;
- scoped_ptr<BackgroundSyncRegistrationHandle> CreateRegistrationHandle(
- const scoped_refptr<RefCountedRegistration>& registration);
-
- // Returns the BackgroundSyncRegistration corresponding to |handle_id|.
- // Returns nullptr if the registration is not found.
- BackgroundSyncRegistration* GetRegistrationForHandle(
- BackgroundSyncRegistrationHandle::HandleId handle_id) const;
-
- // The BackgroundSyncManager holds references to registrations that have
- // active Handles. The handles must call this on destruction.
- void ReleaseRegistrationHandle(
- BackgroundSyncRegistrationHandle::HandleId handle_id);
-
// Disable the manager. Already queued operations will abort once they start
// to run (in their impl methods). Future operations will not queue.
// The list of active registrations is cleared and the backend is also cleared
@@ -204,7 +176,7 @@ class CONTENT_EXPORT BackgroundSyncManager
ServiceWorkerStatusCode status);
// Returns the existing registration or nullptr if it cannot be found.
- RefCountedRegistration* LookupActiveRegistration(
+ BackgroundSyncRegistration* LookupActiveRegistration(
int64_t sw_registration_id,
const RegistrationKey& registration_key);
@@ -220,7 +192,7 @@ class CONTENT_EXPORT BackgroundSyncManager
void AddActiveRegistration(
int64_t sw_registration_id,
const GURL& origin,
- const scoped_refptr<RefCountedRegistration>& sync_registration);
+ const BackgroundSyncRegistration& sync_registration);
void InitImpl(const base::Closure& callback);
void InitDidGetControllerParameters(
@@ -244,11 +216,10 @@ class CONTENT_EXPORT BackgroundSyncManager
void RegisterImpl(int64_t sw_registration_id,
const BackgroundSyncRegistrationOptions& options,
const StatusAndRegistrationCallback& callback);
- void RegisterDidStore(
- int64_t sw_registration_id,
- const scoped_refptr<RefCountedRegistration>& new_registration_ref,
- const StatusAndRegistrationCallback& callback,
- ServiceWorkerStatusCode status);
+ void RegisterDidStore(int64_t sw_registration_id,
+ const BackgroundSyncRegistration& new_registration,
+ const StatusAndRegistrationCallback& callback,
+ ServiceWorkerStatusCode status);
// GetRegistrations callbacks
void GetRegistrationsImpl(int64_t sw_registration_id,
@@ -282,18 +253,16 @@ class CONTENT_EXPORT BackgroundSyncManager
void FireReadyEventsAllEventsFiring(const base::Closure& callback);
// Called when a sync event has completed.
- void EventComplete(
- const scoped_refptr<ServiceWorkerRegistration>&
- service_worker_registration,
- int64_t service_worker_id,
- scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle,
- const base::Closure& callback,
- ServiceWorkerStatusCode status_code);
- void EventCompleteImpl(
- int64_t service_worker_id,
- scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle,
- ServiceWorkerStatusCode status_code,
- const base::Closure& callback);
+ void EventComplete(const scoped_refptr<ServiceWorkerRegistration>&
+ service_worker_registration,
+ int64_t service_worker_id,
+ const RegistrationKey& registration_key,
+ const base::Closure& callback,
+ ServiceWorkerStatusCode status_code);
+ void EventCompleteImpl(int64_t service_worker_id,
+ const RegistrationKey& registration_key,
+ ServiceWorkerStatusCode status_code,
+ const base::Closure& callback);
void EventCompleteDidStore(int64_t service_worker_id,
const base::Closure& callback,
ServiceWorkerStatusCode status_code);
@@ -322,11 +291,11 @@ class CONTENT_EXPORT BackgroundSyncManager
void CompleteStatusAndRegistrationCallback(
StatusAndRegistrationCallback callback,
BackgroundSyncStatus status,
- scoped_ptr<BackgroundSyncRegistrationHandle> result);
+ scoped_ptr<BackgroundSyncRegistration> registration);
void CompleteStatusAndRegistrationsCallback(
StatusAndRegistrationsCallback callback,
BackgroundSyncStatus status,
- scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> results);
+ scoped_ptr<ScopedVector<BackgroundSyncRegistration>> registrations);
base::Closure MakeEmptyCompletion();
base::Closure MakeClosureCompletion(const base::Closure& callback);
StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion(
@@ -352,11 +321,6 @@ class CONTENT_EXPORT BackgroundSyncManager
scoped_ptr<BackgroundSyncNetworkObserver> network_observer_;
- // The registrations that clients have handles to.
- IDMap<scoped_refptr<RefCountedRegistration>,
- IDMapOwnPointer,
- BackgroundSyncRegistrationHandle::HandleId> registration_handle_ids_;
-
scoped_ptr<base::Clock> clock_;
base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_;

Powered by Google App Engine
This is Rietveld 408576698