Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / history_report / delta_file_backend_leveldb.h
blob85f0f9116a5b771157279029c3e579db651b7275
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_
6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_
8 #include <vector>
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
13 class GURL;
15 namespace leveldb {
16 class DB;
19 namespace history_report {
21 class DeltaFileEntryWithData;
23 // Backend for delta file.
24 class DeltaFileBackend {
25 public:
26 explicit DeltaFileBackend(const base::FilePath& dir);
27 ~DeltaFileBackend();
29 // Adds new addition entry to delta file
30 void PageAdded(const GURL& url);
31 // Adds new deletion entry to delta file
32 void PageDeleted(const GURL& url);
33 // Removes all delta file entries with
34 // sequence number <= min(|lower_bound|, max sequence number - 1).
35 // Returns max sequence number in delta file.
36 int64 Trim(int64 lower_bound);
37 // Recreates delta file using given |urls|.
38 bool Recreate(const std::vector<std::string>& urls);
39 // Provides up to |limit| delta file entries with
40 // sequence number > |last_seq_no|.
41 scoped_ptr<std::vector<DeltaFileEntryWithData> > Query(int64 last_seq_no,
42 int32 limit);
43 // Removes all entries from delta file
44 void Clear();
46 // Dumps internal state to string. For debuging.
47 std::string Dump();
49 private:
50 // Starts delta file backend.
51 bool Init();
53 bool EnsureInitialized();
55 class DigitsComparator;
57 base::FilePath path_;
58 scoped_ptr<leveldb::DB> db_;
59 scoped_ptr<DigitsComparator> leveldb_cmp_;
61 DISALLOW_COPY_AND_ASSIGN(DeltaFileBackend);
64 } // namespace history_report
66 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_DELTA_FILE_BACKEND_LEVELDB_H_