Chromium Code Reviews| 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/background_sync_registration_handle.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 BackgroundSyncRegistrationHandle::BackgroundSyncRegistrationHandle( | |
| 13 base::WeakPtr<BackgroundSyncManager> background_sync_manager, | |
| 14 HandleId handle_id) | |
| 15 : background_sync_manager_(background_sync_manager), | |
| 16 handle_id_(handle_id), | |
| 17 registration_( | |
| 18 background_sync_manager_->GetRegistrationForHandle(handle_id_)) { | |
| 19 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 20 DCHECK(background_sync_manager_); | |
| 21 } | |
| 22 | |
| 23 BackgroundSyncRegistrationHandle::~BackgroundSyncRegistrationHandle() { | |
| 24 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 25 if (IsValid() && background_sync_manager_) | |
| 26 background_sync_manager_->ReleaseRegistrationHandle(handle_id_); | |
| 27 } | |
| 28 | |
| 29 void BackgroundSyncRegistrationHandle::Unregister( | |
| 30 int64_t sw_registration_id, | |
| 31 const StatusCallback& callback) { | |
| 32 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 33 DCHECK(IsValid()); | |
| 34 DCHECK(background_sync_manager_); | |
| 35 | |
| 36 background_sync_manager_->Unregister( | |
| 37 sw_registration_id, options()->periodicity, handle_id_, callback); | |
| 38 } | |
| 39 | |
| 40 bool BackgroundSyncRegistrationHandle::IsValid() const { | |
| 41 return registration_ != nullptr; | |
|
michaeln
2015/08/28 02:53:11
maybe test background_sync_mgr_ && registration_
| |
| 42 } | |
| 43 | |
| 44 } // namespace content | |
| OLD | NEW |