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_DELTA_FILE_BACKEND_LEVELDB_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_ |
6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_ | 6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
12 | 15 |
13 class GURL; | 16 class GURL; |
14 | 17 |
15 namespace leveldb { | 18 namespace leveldb { |
16 class DB; | 19 class DB; |
17 } | 20 } |
18 | 21 |
19 namespace history_report { | 22 namespace history_report { |
20 | 23 |
21 class DeltaFileEntryWithData; | 24 class DeltaFileEntryWithData; |
22 | 25 |
23 // Backend for delta file. | 26 // Backend for delta file. |
24 class DeltaFileBackend { | 27 class DeltaFileBackend { |
25 public: | 28 public: |
26 explicit DeltaFileBackend(const base::FilePath& dir); | 29 explicit DeltaFileBackend(const base::FilePath& dir); |
27 ~DeltaFileBackend(); | 30 ~DeltaFileBackend(); |
28 | 31 |
29 // Adds new addition entry to delta file | 32 // Adds new addition entry to delta file |
30 void PageAdded(const GURL& url); | 33 void PageAdded(const GURL& url); |
31 // Adds new deletion entry to delta file | 34 // Adds new deletion entry to delta file |
32 void PageDeleted(const GURL& url); | 35 void PageDeleted(const GURL& url); |
33 // Removes all delta file entries with | 36 // Removes all delta file entries with |
34 // sequence number <= min(|lower_bound|, max sequence number - 1). | 37 // sequence number <= min(|lower_bound|, max sequence number - 1). |
35 // Returns max sequence number in delta file. | 38 // Returns max sequence number in delta file. |
36 int64 Trim(int64 lower_bound); | 39 int64_t Trim(int64_t lower_bound); |
37 // Recreates delta file using given |urls|. | 40 // Recreates delta file using given |urls|. |
38 bool Recreate(const std::vector<std::string>& urls); | 41 bool Recreate(const std::vector<std::string>& urls); |
39 // Provides up to |limit| delta file entries with | 42 // Provides up to |limit| delta file entries with |
40 // sequence number > |last_seq_no|. | 43 // sequence number > |last_seq_no|. |
41 scoped_ptr<std::vector<DeltaFileEntryWithData> > Query(int64 last_seq_no, | 44 scoped_ptr<std::vector<DeltaFileEntryWithData>> Query(int64_t last_seq_no, |
42 int32 limit); | 45 int32_t limit); |
43 // Removes all entries from delta file | 46 // Removes all entries from delta file |
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 // Starts delta file backend. | 53 // Starts delta file backend. |
51 bool Init(); | 54 bool Init(); |
52 | 55 |
53 bool EnsureInitialized(); | 56 bool EnsureInitialized(); |
54 | 57 |
55 class DigitsComparator; | 58 class DigitsComparator; |
56 | 59 |
57 base::FilePath path_; | 60 base::FilePath path_; |
58 scoped_ptr<leveldb::DB> db_; | 61 scoped_ptr<leveldb::DB> db_; |
59 scoped_ptr<DigitsComparator> leveldb_cmp_; | 62 scoped_ptr<DigitsComparator> leveldb_cmp_; |
60 | 63 |
61 DISALLOW_COPY_AND_ASSIGN(DeltaFileBackend); | 64 DISALLOW_COPY_AND_ASSIGN(DeltaFileBackend); |
62 }; | 65 }; |
63 | 66 |
64 } // namespace history_report | 67 } // namespace history_report |
65 | 68 |
66 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_ | 69 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_ |
OLD | NEW |