OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/background_sync/client_background_sync_registration.h" |
| 6 |
| 7 #include "content/browser/background_sync/background_sync_manager.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 ClientBackgroundSyncRegistration::ClientBackgroundSyncRegistration( |
| 13 BackgroundSyncManager* background_sync_manager) |
| 14 : background_sync_manager_(background_sync_manager) { |
| 15 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 16 } |
| 17 |
| 18 ClientBackgroundSyncRegistration::~ClientBackgroundSyncRegistration() { |
| 19 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 20 DCHECK(background_sync_manager_); |
| 21 if (IsValid()) |
| 22 background_sync_manager_->ReleaseClientRegistration(id()); |
| 23 } |
| 24 |
| 25 void ClientBackgroundSyncRegistration::Unregister( |
| 26 int64 sw_registration_id, |
| 27 const StatusCallback& callback) { |
| 28 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 29 DCHECK(IsValid()); |
| 30 |
| 31 background_sync_manager_->Unregister(sw_registration_id, |
| 32 options()->periodicity, id(), callback); |
| 33 } |
| 34 |
| 35 bool ClientBackgroundSyncRegistration::IsValid() const { |
| 36 return BackgroundSyncRegistration::IsValid() && |
| 37 background_sync_manager_->HasClientRegistration(id()); |
| 38 } |
| 39 |
| 40 } // namespace content |
OLD | NEW |