1 // Copyright 2014 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 "base/sequenced_task_runner.h"
6 #include "base/threading/sequenced_worker_pool.h"
7 #include "content/browser/service_worker/service_worker_database_task_manager.h"
11 ServiceWorkerDatabaseTaskManagerImpl::ServiceWorkerDatabaseTaskManagerImpl(
12 base::SequencedWorkerPool
* pool
) {
13 base::SequencedWorkerPool::SequenceToken token
= pool
->GetSequenceToken();
14 task_runner_
= pool
->GetSequencedTaskRunner(token
);
15 shutdown_blocking_task_runner_
=
16 pool
->GetSequencedTaskRunnerWithShutdownBehavior(
17 token
, base::SequencedWorkerPool::BLOCK_SHUTDOWN
);
20 ServiceWorkerDatabaseTaskManagerImpl::~ServiceWorkerDatabaseTaskManagerImpl() {
23 scoped_ptr
<ServiceWorkerDatabaseTaskManager
>
24 ServiceWorkerDatabaseTaskManagerImpl::Clone() {
25 return make_scoped_ptr(new ServiceWorkerDatabaseTaskManagerImpl(
26 task_runner_
, shutdown_blocking_task_runner_
));
29 base::SequencedTaskRunner
*
30 ServiceWorkerDatabaseTaskManagerImpl::GetTaskRunner() {
31 return task_runner_
.get();
34 base::SequencedTaskRunner
*
35 ServiceWorkerDatabaseTaskManagerImpl::GetShutdownBlockingTaskRunner() {
36 return shutdown_blocking_task_runner_
.get();
39 ServiceWorkerDatabaseTaskManagerImpl::ServiceWorkerDatabaseTaskManagerImpl(
40 const scoped_refptr
<base::SequencedTaskRunner
>& task_runner
,
41 const scoped_refptr
<base::SequencedTaskRunner
>&
42 shutdown_blocking_task_runner
)
43 : task_runner_(task_runner
),
44 shutdown_blocking_task_runner_(shutdown_blocking_task_runner
) {
47 MockServiceWorkerDatabaseTaskManager::MockServiceWorkerDatabaseTaskManager(
48 const scoped_refptr
<base::SequencedTaskRunner
>& task_runner
)
49 : task_runner_(task_runner
) {
52 MockServiceWorkerDatabaseTaskManager::~MockServiceWorkerDatabaseTaskManager() {
55 scoped_ptr
<ServiceWorkerDatabaseTaskManager
>
56 MockServiceWorkerDatabaseTaskManager::Clone() {
57 return make_scoped_ptr(
58 new MockServiceWorkerDatabaseTaskManager(task_runner_
));
61 base::SequencedTaskRunner
*
62 MockServiceWorkerDatabaseTaskManager::GetTaskRunner() {
63 return task_runner_
.get();
66 base::SequencedTaskRunner
*
67 MockServiceWorkerDatabaseTaskManager::GetShutdownBlockingTaskRunner() {
68 return task_runner_
.get();
71 } // namespace content