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

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

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS10 Created 5 years, 4 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/client_background_sync_registration.cc
diff --git a/content/browser/background_sync/client_background_sync_registration.cc b/content/browser/background_sync/client_background_sync_registration.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ddf1523c204b5137c0f859cc70356bff05b0f5b6
--- /dev/null
+++ b/content/browser/background_sync/client_background_sync_registration.cc
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/background_sync/client_background_sync_registration.h"
+
+#include "content/browser/background_sync/background_sync_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+ClientBackgroundSyncRegistration::ClientBackgroundSyncRegistration(
+ BackgroundSyncManager* background_sync_manager)
+ : background_sync_manager_(background_sync_manager) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+ClientBackgroundSyncRegistration::~ClientBackgroundSyncRegistration() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(background_sync_manager_);
+ if (IsValid())
+ background_sync_manager_->ReleaseClientRegistration(id());
+}
+
+void ClientBackgroundSyncRegistration::Unregister(
+ int64 sw_registration_id,
+ const StatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(IsValid());
+
+ background_sync_manager_->Unregister(sw_registration_id,
+ options()->periodicity, id(), callback);
+}
+
+bool ClientBackgroundSyncRegistration::IsValid() const {
+ return BackgroundSyncRegistration::IsValid() &&
+ background_sync_manager_->HasClientRegistration(id());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698