blob: 7cb2672e3cb47fd1180cb4c8ab468c3ab1f1e4e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// 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/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() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (IsValid() && background_sync_manager_)
background_sync_manager_->ReleaseRegistrationHandle(handle_id_);
}
void BackgroundSyncRegistrationHandle::Unregister(
int64_t sw_registration_id,
const StatusCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(IsValid());
DCHECK(background_sync_manager_);
background_sync_manager_->Unregister(sw_registration_id, handle_id_,
callback);
}
void BackgroundSyncRegistrationHandle::NotifyWhenDone(
const StatusAndStateCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(IsValid());
DCHECK(background_sync_manager_);
background_sync_manager_->NotifyWhenDone(handle_id_, callback);
}
bool BackgroundSyncRegistrationHandle::IsValid() const {
return registration_ != nullptr;
}
BackgroundSyncRegistrationHandle::BackgroundSyncRegistrationHandle(
base::WeakPtr<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);
DCHECK(background_sync_manager_);
}
} // namespace content
|