Index: chrome/browser/budget_service/budget_database.h |
diff --git a/chrome/browser/budget_service/budget_database.h b/chrome/browser/budget_service/budget_database.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1c7c8b0c0be1b5353c80eeac43418edd2f8d1dc8 |
--- /dev/null |
+++ b/chrome/browser/budget_service/budget_database.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 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 CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_ |
+#define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_ |
+ |
+#include <memory> |
+ |
+#include "base/callback_forward.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/run_loop.h" |
+#include "base/sequenced_task_runner.h" |
+#include "components/leveldb_proto/proto_database.h" |
+#include "url/gurl.h" |
+ |
+namespace chrome_browser_budget_service { |
+class Budget; |
+} |
+ |
+using chrome_browser_budget_service::Budget; |
Peter Beverloo
2016/06/29 13:37:27
`using` declarations in headers are forbidden by o
harkness
2016/06/30 10:41:57
Yes, the package names was truly horrible.
|
+ |
+class BudgetDatabase { |
Peter Beverloo
2016/06/29 13:37:28
++docs (why does it do what it does, why does it n
harkness
2016/06/30 10:41:57
Done.
|
+ public: |
+ BudgetDatabase(const base::FilePath& database_dir, |
+ const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
+ ~BudgetDatabase(); |
+ |
+ // Callback for the basic GetBudget call. |
+ using GetValueCallback = |
+ base::Callback<void(bool success, std::unique_ptr<Budget>)>; |
+ |
+ // Callback for setting a budget value. |
+ using SetValueCallback = base::Callback<void(bool success)>; |
+ |
+ void OnDatabaseInit(bool success); |
Peter Beverloo
2016/06/29 13:37:27
This should be private.
harkness
2016/06/30 10:41:57
Done.
|
+ void GetValue(const GURL& origin, const GetValueCallback& callback); |
+ void SetValue(const GURL& origin, |
+ const Budget& budget, |
+ const SetValueCallback& callback); |
+ |
+ private: |
+ // The database for storing budget information. |
+ std::unique_ptr<leveldb_proto::ProtoDatabase<Budget>> db_; |
+ |
+ base::WeakPtrFactory<BudgetDatabase> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BudgetDatabase); |
+}; |
+ |
+#endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_ |