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

Unified Diff: components/data_reduction_proxy/core/browser/db_service.cc

Issue 1173343009: LevelDB storage for data reduction proxy to store data usage stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing include Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698