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

Unified Diff: components/offline_pages/offline_event_logger.cc

Issue 2529603004: [Offline Pages] Expanding event logger to be used by harness. (Closed)
Patch Set: comments. Created 4 years, 1 month 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: 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() {
fgorski 2016/11/30 17:30:47 Please explain why you are moving the code so much
romax 2016/12/01 01:47:53 I thought the order of the implementation should b
+ 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) {
fgorski 2016/11/30 17:30:47 I see you are moving this code, a few suggestions
romax 2016/12/01 01:47:53 Acknowledged.
+ DCHECK(records);
+ for (std::deque<std::string>::iterator it = activities_.begin();
fgorski 2016/11/30 17:30:47 you can probably use some form of auto here.
romax 2016/12/01 01:47:53 Done.
+ it != activities_.end(); it++) {
fgorski 2016/11/30 17:30:47 ++it
romax 2016/12/01 01:47:53 Done.
+ if (!it->empty())
fgorski 2016/11/30 17:30:47 This guard would be more reasonable in record acti
romax 2016/12/01 01:47:52 Done.
+ 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(&current_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);
fgorski 2016/11/30 17:30:47 what if client == nullptr?
romax 2016/12/01 01:47:53 then client_ would be set to nullptr. and nothing
+ client_ = client;
}
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698