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

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

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up 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/background_sync_registration_handle.cc
diff --git a/content/browser/background_sync/background_sync_registration_handle.cc b/content/browser/background_sync/background_sync_registration_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..03bd15e5807eae26113a9bfa769edee403fe4353
--- /dev/null
+++ b/content/browser/background_sync/background_sync_registration_handle.cc
@@ -0,0 +1,43 @@
+// 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 "background_sync_registration_handle.h"
+
+#include "content/browser/background_sync/background_sync_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace content {
+
+BackgroundSyncRegistrationHandle::BackgroundSyncRegistrationHandle(
+ BackgroundSyncManager* background_sync_manager,
+ HandleId handle_id)
+ : background_sync_manager_(background_sync_manager),
+ handle_id_(handle_id),
+ registration_(
+ background_sync_manager_->GetRegistrationForHandle(handle_id_)) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+}
+
+BackgroundSyncRegistrationHandle::~BackgroundSyncRegistrationHandle() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(background_sync_manager_);
+ if (IsValid())
+ background_sync_manager_->ReleaseHandleId(handle_id_);
+}
+
+void BackgroundSyncRegistrationHandle::Unregister(
+ int64 sw_registration_id,
+ const StatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(IsValid());
+
+ background_sync_manager_->Unregister(
+ sw_registration_id, options()->periodicity, handle_id_, callback);
+}
+
+bool BackgroundSyncRegistrationHandle::IsValid() const {
+ return registration_ != nullptr;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698