OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ |
6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ | 6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 | 16 |
14 namespace base { | 17 namespace base { |
15 class FilePath; | 18 class FilePath; |
16 } // namespace base | 19 } // namespace base |
17 | 20 |
18 namespace leveldb { | 21 namespace leveldb { |
19 class DB; | 22 class DB; |
20 } // namespace leveldb | 23 } // namespace leveldb |
21 | 24 |
22 namespace history_report { | 25 namespace history_report { |
23 | 26 |
24 class UsageReport; | 27 class UsageReport; |
25 | 28 |
26 // Stores usage reports which will be sent for history reporting in batches. | 29 // Stores usage reports which will be sent for history reporting in batches. |
27 class UsageReportsBufferBackend { | 30 class UsageReportsBufferBackend { |
28 public: | 31 public: |
29 explicit UsageReportsBufferBackend(const base::FilePath& dir); | 32 explicit UsageReportsBufferBackend(const base::FilePath& dir); |
30 | 33 |
31 ~UsageReportsBufferBackend(); | 34 ~UsageReportsBufferBackend(); |
32 | 35 |
33 // Creates and initializes the internal data structures. | 36 // Creates and initializes the internal data structures. |
34 bool Init(); | 37 bool Init(); |
35 | 38 |
36 void AddVisit(const std::string& id, int64 timestamp_ms, bool typed_visit); | 39 void AddVisit(const std::string& id, int64_t timestamp_ms, bool typed_visit); |
37 | 40 |
38 // Returns a set of up to |amount| usage reports. | 41 // Returns a set of up to |amount| usage reports. |
39 scoped_ptr<std::vector<UsageReport> > GetUsageReportsBatch(int amount); | 42 scoped_ptr<std::vector<UsageReport> > GetUsageReportsBatch(int amount); |
40 | 43 |
41 void Remove(const std::vector<std::string>& reports); | 44 void Remove(const std::vector<std::string>& reports); |
42 | 45 |
43 // Clears the buffer by removing all its usage reports. | 46 // Clears the buffer by removing all its usage reports. |
44 void Clear(); | 47 void Clear(); |
45 | 48 |
46 // Dumps internal state to string. For debuging. | 49 // Dumps internal state to string. For debuging. |
47 std::string Dump(); | 50 std::string Dump(); |
48 | 51 |
49 private: | 52 private: |
50 // NULL until Init method is called. | 53 // NULL until Init method is called. |
51 scoped_ptr<leveldb::DB> db_; | 54 scoped_ptr<leveldb::DB> db_; |
52 base::FilePath db_file_name_; | 55 base::FilePath db_file_name_; |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(UsageReportsBufferBackend); | 57 DISALLOW_COPY_AND_ASSIGN(UsageReportsBufferBackend); |
55 }; | 58 }; |
56 | 59 |
57 } // namespace history_report | 60 } // namespace history_report |
58 | 61 |
59 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ | 62 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_BACKEND_H_ |
OLD | NEW |