OLD | NEW |
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_backend.h" | 5 #include "chrome/browser/android/history_report/usage_reports_buffer_backend.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 CHECK(db); | 51 CHECK(db); |
52 db_.reset(db); | 52 db_.reset(db); |
53 return true; | 53 return true; |
54 } | 54 } |
55 LOG(WARNING) << "Unable to open " << path << ": " | 55 LOG(WARNING) << "Unable to open " << path << ": " |
56 << status.ToString(); | 56 << status.ToString(); |
57 return false; | 57 return false; |
58 } | 58 } |
59 | 59 |
60 void UsageReportsBufferBackend::AddVisit(const std::string& id, | 60 void UsageReportsBufferBackend::AddVisit(const std::string& id, |
61 int64 timestamp_ms, | 61 int64_t timestamp_ms, |
62 bool typed_visit) { | 62 bool typed_visit) { |
63 if (!db_.get()) { | 63 if (!db_.get()) { |
64 LOG(WARNING) << "AddVisit db not initilized."; | 64 LOG(WARNING) << "AddVisit db not initilized."; |
65 return; | 65 return; |
66 } | 66 } |
67 history_report::UsageReport report; | 67 history_report::UsageReport report; |
68 report.set_id(id); | 68 report.set_id(id); |
69 report.set_timestamp_ms(timestamp_ms); | 69 report.set_timestamp_ms(timestamp_ms); |
70 report.set_typed_visit(typed_visit); | 70 report.set_typed_visit(typed_visit); |
71 leveldb::WriteOptions writeOptions; | 71 leveldb::WriteOptions writeOptions; |
72 leveldb::Status status = db_->Put( | 72 leveldb::Status status = db_->Put( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int num_entries = 0; | 137 int num_entries = 0; |
138 scoped_ptr<leveldb::Iterator> db_it(db_->NewIterator(options)); | 138 scoped_ptr<leveldb::Iterator> db_it(db_->NewIterator(options)); |
139 for (db_it->SeekToFirst(); db_it->Valid(); db_it->Next()) num_entries++; | 139 for (db_it->SeekToFirst(); db_it->Valid(); db_it->Next()) num_entries++; |
140 dump.append(base::IntToString(num_entries)); | 140 dump.append(base::IntToString(num_entries)); |
141 dump.append("]"); | 141 dump.append("]"); |
142 return dump; | 142 return dump; |
143 } | 143 } |
144 | 144 |
145 } // namespace history_report | 145 } // namespace history_report |
146 | 146 |
OLD | NEW |