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