Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/db_service.cc |
| diff --git a/components/data_reduction_proxy/core/browser/db_service.cc b/components/data_reduction_proxy/core/browser/db_service.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b37fef9659e0cfff7dbbf215d42acc4eb686a5c1 |
| --- /dev/null |
| +++ b/components/data_reduction_proxy/core/browser/db_service.cc |
| @@ -0,0 +1,49 @@ |
| +// 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 "components/data_reduction_proxy/core/browser/db_service.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/threading/sequenced_worker_pool.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_store.h" |
| +#include "components/data_reduction_proxy/core/browser/data_usage_store.h" |
| +#include "components/data_reduction_proxy/proto/store.pb.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace data_reduction_proxy { |
| + |
| +DBService::DBService(scoped_ptr<DataReductionProxyStore> store) |
| + : store_(store.Pass()), |
| + data_usage_(new DataUsageStore(store_.get())), |
| + weak_factory_(this) { |
| +} |
| + |
| +DBService::~DBService() { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
|
jeremyim
2015/07/01 21:31:01
Use task_runner, not the named thread pool.
Not at Google. Contact bengr
2015/07/01 23:17:38
Used sequence_checker.
|
| +} |
| + |
| +void DBService::InitializeOnDBThread() { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + |
| + store_->InitializeOnDBThread(); |
| +} |
| + |
| +void DBService::LoadCurrentDataUsageBucket(DataUsageBucket* bucket) { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + |
| + data_usage_->LoadCurrentDataUsageBucket(bucket); |
| +} |
| + |
| +void DBService::StoreCurrentDataUsageBucket( |
| + scoped_ptr<DataUsageBucket> current) { |
| + DCHECK(content::BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| + |
| + data_usage_->StoreCurrentDataUsageBucket(*current.get()); |
| +} |
| + |
| +base::WeakPtr<DBService> DBService::GetWeakPtr() { |
| + return weak_factory_.GetWeakPtr(); |
| +} |
| + |
| +} // namespace data_reduction_proxy |