Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: chrome/browser/android/history_report/usage_reports_buffer_service.h

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_SERVICE_H_
6 #define CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_SERVICE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/sequenced_worker_pool.h"
13
14 namespace base {
15 class FilePath;
16 } // namespace base
17
18 namespace history_report {
19
20 class UsageReport;
21 class UsageReportsBufferBackend;
22
23 // This class is intended to be created once and not destroyed until process is
24 // killed. |backend_| is assumed to be a long lived pointer.
25 class UsageReportsBufferService {
26 public:
27 explicit UsageReportsBufferService(const base::FilePath& dir);
28 ~UsageReportsBufferService();
29
30 // Init buffer. All calls to buffer before it's initialized are ignored. It's
31 // asynchronous.
32 void Init();
33
34 // Add report about page visit to the buffer. It's asynchronous.
35 void AddVisit(const std::string& id, int64 timestamp_ms, bool typed_visit);
36
37 // Get a batch of usage reports of size up to |batch_size|. It's synchronous.
38 scoped_ptr<std::vector<UsageReport> > GetUsageReportsBatch(int32 batch_size);
39
40 // Remove given usage reports from buffer. It's synchronous.
41 void Remove(const std::vector<std::string>& report_ids);
42
43 // Clears buffer by removing all usage reports from it.
44 void Clear();
45
46 // Dumps internal state to string.
47 std::string Dump();
48
49 private:
50 // Token used to serialize buffer operations.
51 base::SequencedWorkerPool::SequenceToken worker_pool_token_;
52 // Non thread safe backend.
53 scoped_ptr<UsageReportsBufferBackend> backend_;
54
55 DISALLOW_COPY_AND_ASSIGN(UsageReportsBufferService);
56 };
57
58 } // namespace history_report
59
60 #endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698