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 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
14 if (IsValid() && background_sync_manager_) | |
15 background_sync_manager_->ReleaseRegistrationHandle(handle_id_); | |
16 } | |
17 | |
18 bool BackgroundSyncRegistrationHandle::IsValid() const { | |
19 return registration_ != nullptr; | |
20 } | |
21 | |
22 BackgroundSyncRegistrationHandle::BackgroundSyncRegistrationHandle( | |
23 base::WeakPtr<BackgroundSyncManager> background_sync_manager, | |
24 HandleId handle_id) | |
25 : background_sync_manager_(background_sync_manager), | |
26 handle_id_(handle_id), | |
27 registration_( | |
28 background_sync_manager_->GetRegistrationForHandle(handle_id_)) { | |
29 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
30 DCHECK(background_sync_manager_); | |
31 } | |
32 | |
33 } // namespace content | |
OLD | NEW |