Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/browser/background_sync/background_sync_registration_handle.cc

Issue 1282013004: BackgroundSyncManager tracks client registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 void BackgroundSyncRegistrationHandle::Unregister(
19 int64_t sw_registration_id,
20 const StatusCallback& callback) {
21 DCHECK_CURRENTLY_ON(BrowserThread::IO);
22 DCHECK(IsValid());
23 DCHECK(background_sync_manager_);
24
25 background_sync_manager_->Unregister(
26 sw_registration_id, options()->periodicity, handle_id_, callback);
27 }
28
29 bool BackgroundSyncRegistrationHandle::IsValid() const {
30 return registration_ != nullptr;
31 }
32
33 BackgroundSyncRegistrationHandle::BackgroundSyncRegistrationHandle(
34 base::WeakPtr<BackgroundSyncManager> background_sync_manager,
35 HandleId handle_id)
36 : background_sync_manager_(background_sync_manager),
37 handle_id_(handle_id),
38 registration_(
39 background_sync_manager_->GetRegistrationForHandle(handle_id_)) {
40 DCHECK_CURRENTLY_ON(BrowserThread::IO);
41 DCHECK(background_sync_manager_);
42 }
43
44 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698