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_
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
19 namespace history_report
{
21 class DeltaFileEntryWithData
;
23 // Backend for delta file.
24 class DeltaFileBackend
{
26 explicit DeltaFileBackend(const base::FilePath
& dir
);
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
,
43 // Removes all entries from delta file
46 // Dumps internal state to string. For debuging.
50 // Starts delta file backend.
53 bool EnsureInitialized();
55 class DigitsComparator
;
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_