Roll DEPS for PDFium to 19ae17578f99621100a26dac3e2c7c3dbf7c7cd1
[chromium-blink-merge.git] / content / browser / background_sync / background_sync_context_impl.cc
blob31ad2a0a99cad980f7716102345938974bd4fcbb
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.
5 #include "content/browser/background_sync/background_sync_context_impl.h"
7 #include "base/bind.h"
8 #include "content/browser/background_sync/background_sync_manager.h"
9 #include "content/browser/service_worker/service_worker_context_wrapper.h"
10 #include "content/public/browser/browser_thread.h"
12 namespace content {
14 BackgroundSyncContextImpl::BackgroundSyncContextImpl() {
15 DCHECK_CURRENTLY_ON(BrowserThread::UI);
18 BackgroundSyncContextImpl::~BackgroundSyncContextImpl() {
21 void BackgroundSyncContextImpl::Init(
22 const scoped_refptr<ServiceWorkerContextWrapper>& context) {
23 DCHECK_CURRENTLY_ON(BrowserThread::UI);
25 BrowserThread::PostTask(
26 BrowserThread::IO, FROM_HERE,
27 base::Bind(&BackgroundSyncContextImpl::CreateBackgroundSyncManager, this,
28 context));
31 void BackgroundSyncContextImpl::Shutdown() {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
34 BrowserThread::PostTask(
35 BrowserThread::IO, FROM_HERE,
36 base::Bind(&BackgroundSyncContextImpl::ShutdownOnIO, this));
39 BackgroundSyncManager* BackgroundSyncContextImpl::background_sync_manager()
40 const {
41 DCHECK_CURRENTLY_ON(BrowserThread::IO);
43 return background_sync_manager_.get();
46 void BackgroundSyncContextImpl::CreateBackgroundSyncManager(
47 const scoped_refptr<ServiceWorkerContextWrapper>& context) {
48 DCHECK_CURRENTLY_ON(BrowserThread::IO);
49 DCHECK(!background_sync_manager_);
51 background_sync_manager_ = BackgroundSyncManager::Create(context);
54 void BackgroundSyncContextImpl::ShutdownOnIO() {
55 DCHECK_CURRENTLY_ON(BrowserThread::IO);
57 background_sync_manager_.reset();
60 } // namespace content