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

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

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/history_report/usage_reports_buffer_service.h" 5 #include "chrome/browser/android/history_report/usage_reports_buffer_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/android/history_report/usage_reports_buffer_backend.h" 10 #include "chrome/browser/android/history_report/usage_reports_buffer_backend.h"
11 #include "chrome/browser/android/proto/delta_file.pb.h" 11 #include "chrome/browser/android/proto/delta_file.pb.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 13
14 14
15 namespace { 15 namespace {
16 16
17 void DoInit(history_report::UsageReportsBufferBackend* backend) { 17 void DoInit(history_report::UsageReportsBufferBackend* backend) {
18 backend->Init(); 18 backend->Init();
19 } 19 }
20 20
21 void DoAddVisit(history_report::UsageReportsBufferBackend* backend, 21 void DoAddVisit(history_report::UsageReportsBufferBackend* backend,
22 const std::string id, 22 const std::string id,
23 int64 timestamp_ms, 23 int64_t timestamp_ms,
24 bool typed_visit) { 24 bool typed_visit) {
25 backend->AddVisit(id, timestamp_ms, typed_visit); 25 backend->AddVisit(id, timestamp_ms, typed_visit);
26 } 26 }
27 27
28 void DoRemove(history_report::UsageReportsBufferBackend* backend, 28 void DoRemove(history_report::UsageReportsBufferBackend* backend,
29 const std::vector<std::string>* reports, 29 const std::vector<std::string>* reports,
30 base::WaitableEvent* finished) { 30 base::WaitableEvent* finished) {
31 backend->Remove(*reports); 31 backend->Remove(*reports);
32 finished->Signal(); 32 finished->Signal();
33 } 33 }
34 34
35 void DoGetUsageReportsBatch( 35 void DoGetUsageReportsBatch(
36 history_report::UsageReportsBufferBackend* backend, 36 history_report::UsageReportsBufferBackend* backend,
37 int32 batch_size, 37 int32_t batch_size,
38 base::WaitableEvent* finished, 38 base::WaitableEvent* finished,
39 scoped_ptr<std::vector<history_report::UsageReport> >* result) { 39 scoped_ptr<std::vector<history_report::UsageReport>>* result) {
40 *result = backend->GetUsageReportsBatch(batch_size).Pass(); 40 *result = backend->GetUsageReportsBatch(batch_size).Pass();
41 finished->Signal(); 41 finished->Signal();
42 } 42 }
43 43
44 void DoClear( 44 void DoClear(
45 history_report::UsageReportsBufferBackend* backend, 45 history_report::UsageReportsBufferBackend* backend,
46 base::WaitableEvent* finished) { 46 base::WaitableEvent* finished) {
47 backend->Clear(); 47 backend->Clear();
48 finished->Signal(); 48 finished->Signal();
49 } 49 }
(...skipping 22 matching lines...) Expand all
72 void UsageReportsBufferService::Init() { 72 void UsageReportsBufferService::Init() {
73 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 73 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
74 pool->PostSequencedWorkerTaskWithShutdownBehavior( 74 pool->PostSequencedWorkerTaskWithShutdownBehavior(
75 worker_pool_token_, 75 worker_pool_token_,
76 FROM_HERE, 76 FROM_HERE,
77 base::Bind(&DoInit, base::Unretained(backend_.get())), 77 base::Bind(&DoInit, base::Unretained(backend_.get())),
78 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 78 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
79 } 79 }
80 80
81 void UsageReportsBufferService::AddVisit(const std::string& id, 81 void UsageReportsBufferService::AddVisit(const std::string& id,
82 int64 timestamp_ms, 82 int64_t timestamp_ms,
83 bool typed_visit) { 83 bool typed_visit) {
84 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 84 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
85 pool->PostSequencedWorkerTaskWithShutdownBehavior( 85 pool->PostSequencedWorkerTaskWithShutdownBehavior(
86 worker_pool_token_, 86 worker_pool_token_,
87 FROM_HERE, 87 FROM_HERE,
88 base::Bind(&DoAddVisit, 88 base::Bind(&DoAddVisit,
89 base::Unretained(backend_.get()), 89 base::Unretained(backend_.get()),
90 id, 90 id,
91 timestamp_ms, 91 timestamp_ms,
92 typed_visit), 92 typed_visit),
93 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 93 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
94 } 94 }
95 95
96 scoped_ptr<std::vector<UsageReport> > 96 scoped_ptr<std::vector<UsageReport>>
97 UsageReportsBufferService::GetUsageReportsBatch(int32 batch_size) { 97 UsageReportsBufferService::GetUsageReportsBatch(int32_t batch_size) {
98 scoped_ptr<std::vector<UsageReport> > result; 98 scoped_ptr<std::vector<UsageReport> > result;
99 base::WaitableEvent finished(false, false); 99 base::WaitableEvent finished(false, false);
100 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); 100 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
101 // It's ok to pass unretained pointers here because this is a synchronous 101 // It's ok to pass unretained pointers here because this is a synchronous
102 // call. 102 // call.
103 pool->PostSequencedWorkerTaskWithShutdownBehavior( 103 pool->PostSequencedWorkerTaskWithShutdownBehavior(
104 worker_pool_token_, 104 worker_pool_token_,
105 FROM_HERE, 105 FROM_HERE,
106 base::Bind(&DoGetUsageReportsBatch, 106 base::Bind(&DoGetUsageReportsBatch,
107 base::Unretained(backend_.get()), 107 base::Unretained(backend_.get()),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 base::Bind(&DoDump, 157 base::Bind(&DoDump,
158 base::Unretained(backend_.get()), 158 base::Unretained(backend_.get()),
159 base::Unretained(&finished), 159 base::Unretained(&finished),
160 base::Unretained(&dump)), 160 base::Unretained(&dump)),
161 base::SequencedWorkerPool::BLOCK_SHUTDOWN); 161 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
162 finished.Wait(); 162 finished.Wait();
163 return dump; 163 return dump;
164 } 164 }
165 165
166 } // namespace history_report 166 } // namespace history_report
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698