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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/history_report/usage_reports_buffer_service.h
diff --git a/chrome/browser/android/history_report/usage_reports_buffer_service.h b/chrome/browser/android/history_report/usage_reports_buffer_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..f98b3b5d3f47982506e05d82bfdc655a4a4c907b
--- /dev/null
+++ b/chrome/browser/android/history_report/usage_reports_buffer_service.h
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_SERVICE_H_
+#define CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_SERVICE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/sequenced_worker_pool.h"
+
+namespace base {
+class FilePath;
+} // namespace base
+
+namespace history_report {
+
+class UsageReport;
+class UsageReportsBufferBackend;
+
+// This class is intended to be created once and not destroyed until process is
+// killed. |backend_| is assumed to be a long lived pointer.
+class UsageReportsBufferService {
+ public:
+ explicit UsageReportsBufferService(const base::FilePath& dir);
+ ~UsageReportsBufferService();
+
+ // Init buffer. All calls to buffer before it's initialized are ignored. It's
+ // asynchronous.
+ void Init();
+
+ // Add report about page visit to the buffer. It's asynchronous.
+ void AddVisit(const std::string& id, int64 timestamp_ms, bool typed_visit);
+
+ // Get a batch of usage reports of size up to |batch_size|. It's synchronous.
+ scoped_ptr<std::vector<UsageReport> > GetUsageReportsBatch(int32 batch_size);
+
+ // Remove given usage reports from buffer. It's synchronous.
+ void Remove(const std::vector<std::string>& report_ids);
+
+ // Clears buffer by removing all usage reports from it.
+ void Clear();
+
+ // Dumps internal state to string.
+ std::string Dump();
+
+ private:
+ // Token used to serialize buffer operations.
+ base::SequencedWorkerPool::SequenceToken worker_pool_token_;
+ // Non thread safe backend.
+ scoped_ptr<UsageReportsBufferBackend> backend_;
+
+ DISALLOW_COPY_AND_ASSIGN(UsageReportsBufferService);
+};
+
+} // namespace history_report
+
+#endif // CHROME_BROWSER_ANDROID_HISTORY_REPORT_USAGE_REPORTS_BUFFER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698