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 |