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

Side by Side Diff: components/offline_pages/core/offline_event_logger.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years 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 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 extern const size_t kMaxLogCount = 50; 11 extern const size_t kMaxLogCount = 50;
12 12
13 OfflineEventLogger::OfflineEventLogger() 13 OfflineEventLogger::OfflineEventLogger()
14 : activities_(0), is_logging_(false), client_(nullptr) {} 14 : activities_(0), is_logging_(false), client_(nullptr) {}
15 15
16 OfflineEventLogger::~OfflineEventLogger() {} 16 OfflineEventLogger::~OfflineEventLogger() {}
17 17
(...skipping 15 matching lines...) Expand all
33 } 33 }
34 34
35 void OfflineEventLogger::RecordActivity(const std::string& activity) { 35 void OfflineEventLogger::RecordActivity(const std::string& activity) {
36 if (!is_logging_ || activity.empty()) 36 if (!is_logging_ || activity.empty())
37 return; 37 return;
38 38
39 base::Time::Exploded current_time; 39 base::Time::Exploded current_time;
40 base::Time::Now().LocalExplode(&current_time); 40 base::Time::Now().LocalExplode(&current_time);
41 41
42 std::string date_string = base::StringPrintf( 42 std::string date_string = base::StringPrintf(
43 "%d %02d %02d %02d:%02d:%02d", 43 "%d %02d %02d %02d:%02d:%02d", current_time.year, current_time.month,
44 current_time.year, 44 current_time.day_of_month, current_time.hour, current_time.minute,
45 current_time.month,
46 current_time.day_of_month,
47 current_time.hour,
48 current_time.minute,
49 current_time.second); 45 current_time.second);
50 46
51 std::string log_message = date_string + ": " + activity; 47 std::string log_message = date_string + ": " + activity;
52 if (client_) 48 if (client_)
53 client_->CustomLog(log_message); 49 client_->CustomLog(log_message);
54 50
55 if (activities_.size() == kMaxLogCount) 51 if (activities_.size() == kMaxLogCount)
56 activities_.pop_back(); 52 activities_.pop_back();
57 53
58 activities_.push_front(log_message); 54 activities_.push_front(log_message);
59 } 55 }
60 56
61 void OfflineEventLogger::SetClient(Client* client) { 57 void OfflineEventLogger::SetClient(Client* client) {
62 DCHECK(client); 58 DCHECK(client);
63 SetIsLogging(true); 59 SetIsLogging(true);
64 client_ = client; 60 client_ = client;
65 } 61 }
66 62
67 } // namespace offline_pages 63 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/core/offline_event_logger.h ('k') | components/offline_pages/core/offline_page_archiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698