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

Unified Diff: components/data_reduction_proxy/core/browser/db_data_owner.h

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: Remove wrong const Created 5 years, 5 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_data_owner.h
diff --git a/components/data_reduction_proxy/core/browser/db_data_owner.h b/components/data_reduction_proxy/core/browser/db_data_owner.h
new file mode 100644
index 0000000000000000000000000000000000000000..a3710fa8f162a393bd97b820ccd083ff39c3ffd2
--- /dev/null
+++ b/components/data_reduction_proxy/core/browser/db_data_owner.h
@@ -0,0 +1,53 @@
+// 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.
+
+#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DB_SERVICE_H_
+#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DB_SERVICE_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/sequence_checker.h"
+
+namespace base {
+class FilePath;
+} // namespace base
+
+namespace data_reduction_proxy {
+class DataStore;
+class DataUsageBucket;
+class DataUsageStore;
+
+typedef base::Callback<void(scoped_ptr<DataUsageBucket>)>
+ OnLoadDataUsageBucketCallback;
+
+// Contains and initializes all Data Reduction Proxy objects that have a
+// lifetime based on the DB task runner.
+class DBDataOwner {
+ public:
+ explicit DBDataOwner(scoped_ptr<DataStore> store);
+ virtual ~DBDataOwner();
+
+ // Initializes all the DB objects. Must be called on the DB task runner.
+ void InitializeOnDBThread();
+
+ // Loads the last stored data usage bucket from |DataStore| into |bucket|.
+ void LoadCurrentDataUsageBucket(DataUsageBucket* bucket);
+
+ // Stores |current| to |DataStore|.
+ void StoreCurrentDataUsageBucket(scoped_ptr<DataUsageBucket> current);
+
+ // Returns a weak pointer to self for use on UI thread.
+ base::WeakPtr<DBDataOwner> GetWeakPtr();
+
+ private:
+ scoped_ptr<DataStore> store_;
+ scoped_ptr<DataUsageStore> data_usage_;
+ base::SequenceChecker sequence_checker_;
+ base::WeakPtrFactory<DBDataOwner> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DBDataOwner);
+};
+
+} // namespace data_reduction_proxy
+#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DB_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698