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

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

Issue 1344843003: [BackgroundSync] Add browser side support for SyncRegistration.done (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ncn_max
Patch Set: Address comments from PS7 Created 5 years, 3 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_registration.h
diff --git a/content/browser/background_sync/background_sync_registration.h b/content/browser/background_sync/background_sync_registration.h
index 91f5ded13b2dfde6495600ab926bc17d8ba680a9..741c88850e44a316e13e0ae1cccb820d20fe2a0a 100644
--- a/content/browser/background_sync/background_sync_registration.h
+++ b/content/browser/background_sync/background_sync_registration.h
@@ -5,6 +5,9 @@
#ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_
#define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_REGISTRATION_H_
+#include <list>
+
+#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "content/browser/background_sync/background_sync.pb.h"
@@ -18,13 +21,18 @@ namespace content {
class CONTENT_EXPORT BackgroundSyncRegistration {
public:
using RegistrationId = int64_t;
+ using StateCallback = base::Callback<void(BackgroundSyncState)>;
+
static const RegistrationId kInitialId;
- BackgroundSyncRegistration() = default;
- ~BackgroundSyncRegistration() = default;
+ BackgroundSyncRegistration();
+ ~BackgroundSyncRegistration();
bool Equals(const BackgroundSyncRegistration& other) const;
bool IsValid() const;
+ void AddDoneCallback(const StateCallback& callback);
+ void RunDoneCallbacks();
+ bool HasCompleted() const;
const BackgroundSyncRegistrationOptions* options() const { return &options_; }
BackgroundSyncRegistrationOptions* options() { return &options_; }
@@ -42,6 +50,8 @@ class CONTENT_EXPORT BackgroundSyncRegistration {
RegistrationId id_ = kInvalidRegistrationId;
BackgroundSyncState sync_state_ = BACKGROUND_SYNC_STATE_PENDING;
+ std::list<StateCallback> notify_done_callbacks_;
+
DISALLOW_COPY_AND_ASSIGN(BackgroundSyncRegistration);
};

Powered by Google App Engine
This is Rietveld 408576698