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

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: Code review feedback and added histograms.xml update. 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/memory/weak_ptr.h"
12 #include "base/run_loop.h"
13 #include "base/sequenced_task_runner.h"
14 #include "components/leveldb_proto/proto_database.h"
15 #include "url/gurl.h"
16
17 namespace budget_service {
18 class Budget;
19 }
20
21 // A class used to asynchronously read and write details of the budget
22 // assigned to service workers. The class uses an underlying levelDB.
Peter Beverloo 2016/06/30 13:12:46 service workers -> origins? Nothing in this class
harkness 2016/07/01 12:29:54 Good point. I tend to think of this applying to se
23 class BudgetDatabase {
24 public:
25 // The database_dir specifies the location of the budget information on
26 // disk. The task_runner is used by the ProtoDatabase to handle all blocking
27 // calls and disk access.
28 BudgetDatabase(const base::FilePath& database_dir,
29 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
30 ~BudgetDatabase();
31
32 // Callback for the basic GetBudget call.
33 using GetValueCallback =
34 base::Callback<void(bool success,
35 std::unique_ptr<budget_service::Budget>)>;
36
37 // Callback for setting a budget value.
38 using SetValueCallback = base::Callback<void(bool success)>;
Peter Beverloo 2016/06/30 13:12:46 micro nit: sorry for missing this earlier— types b
harkness 2016/07/01 12:29:54 Done.
39
40 void GetValue(const GURL& origin, const GetValueCallback& callback);
41 void SetValue(const GURL& origin,
42 const budget_service::Budget& budget,
43 const SetValueCallback& callback);
44
45 private:
46 void OnDatabaseInit(bool success);
Peter Beverloo 2016/06/30 13:12:46 optional bikeshedding to consider: DidInitializeDa
harkness 2016/07/01 12:29:54 I prefer the On* in this case, because I'm plannin
47
48 // The database for storing budget information.
49 std::unique_ptr<leveldb_proto::ProtoDatabase<budget_service::Budget>> db_;
50
51 base::WeakPtrFactory<BudgetDatabase> weak_ptr_factory_;
52
53 DISALLOW_COPY_AND_ASSIGN(BudgetDatabase);
54 };
55
56 #endif // CHROME_BROWSER_BUDGET_SERVICE_BUDGET_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698