| Index: components/offline_pages/offline_event_logger.cc
|
| diff --git a/components/offline_pages/offline_event_logger.cc b/components/offline_pages/offline_event_logger.cc
|
| index 810c2a667e670621ca37eb0b15eff815388b3744..463ec0149efd1fa5b745e7f310e3aa251c04c3ca 100644
|
| --- a/components/offline_pages/offline_event_logger.cc
|
| +++ b/components/offline_pages/offline_event_logger.cc
|
| @@ -13,6 +13,10 @@ OfflineEventLogger::OfflineEventLogger()
|
|
|
| OfflineEventLogger::~OfflineEventLogger() {}
|
|
|
| +void OfflineEventLogger::Clear() {
|
| + activities_.clear();
|
| +}
|
| +
|
| void OfflineEventLogger::SetIsLogging(bool is_logging) {
|
| is_logging_ = is_logging;
|
| }
|
| @@ -21,16 +25,19 @@ bool OfflineEventLogger::GetIsLogging() {
|
| return is_logging_;
|
| }
|
|
|
| -void OfflineEventLogger::Clear() {
|
| - activities_.clear();
|
| +void OfflineEventLogger::GetLogs(std::vector<std::string>* records) {
|
| + DCHECK(records);
|
| + for (std::deque<std::string>::iterator it = activities_.begin();
|
| + it != activities_.end(); it++) {
|
| + if (!it->empty())
|
| + records->push_back(*it);
|
| + }
|
| }
|
|
|
| void OfflineEventLogger::RecordActivity(const std::string& activity) {
|
| if (!is_logging_) {
|
| return;
|
| }
|
| - if (activities_.size() == kMaxLogCount)
|
| - activities_.pop_back();
|
|
|
| base::Time::Exploded current_time;
|
| base::Time::Now().LocalExplode(¤t_time);
|
| @@ -44,16 +51,18 @@ void OfflineEventLogger::RecordActivity(const std::string& activity) {
|
| current_time.minute,
|
| current_time.second);
|
|
|
| + if (client_)
|
| + client_->CustomLog(activity);
|
| +
|
| + if (activities_.size() == kMaxLogCount)
|
| + activities_.pop_back();
|
| +
|
| activities_.push_front(date_string + ": " + activity);
|
| }
|
|
|
| -void OfflineEventLogger::GetLogs(std::vector<std::string>* records) {
|
| - DCHECK(records);
|
| - for (std::deque<std::string>::iterator it = activities_.begin();
|
| - it != activities_.end(); it++) {
|
| - if (!it->empty())
|
| - records->push_back(*it);
|
| - }
|
| +void OfflineEventLogger::SetClient(Client* client) {
|
| + SetIsLogging(true);
|
| + client_ = client;
|
| }
|
|
|
| } // namespace offline_pages
|
|
|