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

Side by Side Diff: chrome/browser/budget_service/budget_database.h

Issue 2107173002: Add the future storage framework for the BudgetDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits and fix path error Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_
6 #define CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_
7
8 #include <memory>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "components/leveldb_proto/proto_database.h"
14
15 namespace base {
16 class SequencedTaskRunner;
17 }
18
19 namespace budget_service {
20 class Budget;
21 }
22
23 class GURL;
24
25 // A class used to asynchronously read and write details of the budget
26 // assigned to an origin. The class uses an underlying LevelDB.
27 class BudgetDatabase {
28 public:
29 // Callback for the basic GetBudget call.
30 using GetValueCallback =
31 base::Callback<void(bool success,
32 std::unique_ptr<budget_service::Budget>)>;
33
34 // Callback for setting a budget value.
35 using SetValueCallback = base::Callback<void(bool success)>;
36
37 // The database_dir specifies the location of the budget information on
38 // disk. The task_runner is used by the ProtoDatabase to handle all blocking
39 // calls and disk access.
40 BudgetDatabase(const base::FilePath& database_dir,
41 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
42 ~BudgetDatabase();
43
44 void GetValue(const GURL& origin, const GetValueCallback& callback);
45 void SetValue(const GURL& origin,
46 const budget_service::Budget& budget,
47 const SetValueCallback& callback);
48
49 private:
50 void OnDatabaseInit(bool success);
51
52 // The database for storing budget information.
53 std::unique_ptr<leveldb_proto::ProtoDatabase<budget_service::Budget>> db_;
54
55 base::WeakPtrFactory<BudgetDatabase> weak_ptr_factory_;
56
57 DISALLOW_COPY_AND_ASSIGN(BudgetDatabase);
58 };
59
60 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/budget_service/budget.proto ('k') | chrome/browser/budget_service/budget_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698