blob: 31ad2a0a99cad980f7716102345938974bd4fcbb (
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
54
55
56
57
58
59
60
|
// 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_context_impl.h"
#include "base/bind.h"
#include "content/browser/background_sync/background_sync_manager.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/public/browser/browser_thread.h"
namespace content {
BackgroundSyncContextImpl::BackgroundSyncContextImpl() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
BackgroundSyncContextImpl::~BackgroundSyncContextImpl() {
}
void BackgroundSyncContextImpl::Init(
const scoped_refptr<ServiceWorkerContextWrapper>& context) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&BackgroundSyncContextImpl::CreateBackgroundSyncManager, this,
context));
}
void BackgroundSyncContextImpl::Shutdown() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&BackgroundSyncContextImpl::ShutdownOnIO, this));
}
BackgroundSyncManager* BackgroundSyncContextImpl::background_sync_manager()
const {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return background_sync_manager_.get();
}
void BackgroundSyncContextImpl::CreateBackgroundSyncManager(
const scoped_refptr<ServiceWorkerContextWrapper>& context) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!background_sync_manager_);
background_sync_manager_ = BackgroundSyncManager::Create(context);
}
void BackgroundSyncContextImpl::ShutdownOnIO() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
background_sync_manager_.reset();
}
} // namespace content
|