OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
7 #include "components/offline_pages/offline_event_logger.h" | 7 #include "components/offline_pages/core/offline_event_logger.h" |
8 | 8 |
9 namespace offline_pages { | 9 namespace offline_pages { |
10 | 10 |
11 OfflineEventLogger::OfflineEventLogger() | 11 OfflineEventLogger::OfflineEventLogger() |
12 : activities_(kMaxLogCount), is_logging_(false) {} | 12 : activities_(kMaxLogCount), is_logging_(false) {} |
13 | 13 |
14 OfflineEventLogger::~OfflineEventLogger() {} | 14 OfflineEventLogger::~OfflineEventLogger() {} |
15 | 15 |
16 void OfflineEventLogger::SetIsLogging(bool is_logging) { | 16 void OfflineEventLogger::SetIsLogging(bool is_logging) { |
17 is_logging_ = is_logging; | 17 is_logging_ = is_logging; |
(...skipping 11 matching lines...) Expand all Loading... |
29 if (!is_logging_) { | 29 if (!is_logging_) { |
30 return; | 30 return; |
31 } | 31 } |
32 if (activities_.size() == kMaxLogCount) | 32 if (activities_.size() == kMaxLogCount) |
33 activities_.pop_back(); | 33 activities_.pop_back(); |
34 | 34 |
35 base::Time::Exploded current_time; | 35 base::Time::Exploded current_time; |
36 base::Time::Now().LocalExplode(¤t_time); | 36 base::Time::Now().LocalExplode(¤t_time); |
37 | 37 |
38 std::string date_string = base::StringPrintf( | 38 std::string date_string = base::StringPrintf( |
39 "%d %02d %02d %02d:%02d:%02d", | 39 "%d %02d %02d %02d:%02d:%02d", current_time.year, current_time.month, |
40 current_time.year, | 40 current_time.day_of_month, current_time.hour, current_time.minute, |
41 current_time.month, | |
42 current_time.day_of_month, | |
43 current_time.hour, | |
44 current_time.minute, | |
45 current_time.second); | 41 current_time.second); |
46 | 42 |
47 activities_.push_front(date_string + ": " + activity); | 43 activities_.push_front(date_string + ": " + activity); |
48 } | 44 } |
49 | 45 |
50 void OfflineEventLogger::GetLogs(std::vector<std::string>* records) { | 46 void OfflineEventLogger::GetLogs(std::vector<std::string>* records) { |
51 DCHECK(records); | 47 DCHECK(records); |
52 for (std::deque<std::string>::iterator it = activities_.begin(); | 48 for (std::deque<std::string>::iterator it = activities_.begin(); |
53 it != activities_.end(); it++) { | 49 it != activities_.end(); it++) { |
54 if (!it->empty()) | 50 if (!it->empty()) |
55 records->push_back(*it); | 51 records->push_back(*it); |
56 } | 52 } |
57 } | 53 } |
58 | 54 |
59 } // namespace offline_pages | 55 } // namespace offline_pages |
OLD | NEW |