OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_EVENT_LOGGER_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_EVENT_LOGGER_H_ | |
7 | |
8 #include <deque> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/macros.h" | |
13 | |
14 namespace offline_pages { | |
15 | |
16 static const size_t kMaxLogCount = 20; | |
17 | |
18 // Maximum number of recorded Logs to keep track of at any moment. | |
fgorski
2016/06/24 18:17:33
I think you might want to put the documentation ab
chili
2016/06/24 20:30:11
Oops. I forgot to remove when I was debugging a di
| |
19 //static const size_t kMaxLogCount = 20; | |
20 | |
21 // Facilitates the logging of events. Subclasses should create methods that | |
22 // call RecordActivity to write into the log. SetIsLogging, GetLogs, and | |
fgorski
2016/06/24 18:17:33
|SetIsLogging|, ...
chili
2016/06/24 20:30:11
Done.
| |
23 // Clear are called from the chrome://offline-internals page. | |
24 // | |
25 // Logging should be done by calling the corresponding subclass methods when | |
26 // a loggable event occurs (i.e. when status has changed for a save request | |
27 // or when an offlined page has been accessed/saved) | |
fgorski
2016/06/24 18:17:34
nit: please put period at the end of a sentence.
chili
2016/06/24 20:30:11
Done.
| |
28 // | |
29 // This log only keeps track of the last 20 events. | |
fgorski
2016/06/24 18:17:33
last |kMaxLogCount| events.
chili
2016/06/24 20:30:11
Done.
| |
30 class OfflineEventLogger { | |
31 public: | |
32 OfflineEventLogger(); | |
33 | |
34 ~OfflineEventLogger(); | |
35 | |
36 // Clears the recorded activities. | |
37 void Clear(); | |
38 | |
39 // Turns logging on/off. | |
40 void SetIsLogging(bool is_logging); | |
41 | |
42 // Dumps the current activity list into |records|. | |
43 void GetLogs(std::vector<std::string>& records); | |
dewittj
2016/06/24 18:32:49
nit: use a pointer, non-const pass by reference is
chili
2016/06/24 20:30:11
Done.
| |
44 | |
45 protected: | |
46 // Write the activity into the cycling log if we are currently logging. | |
47 void RecordActivity(const std::string& activity); | |
48 | |
49 private: | |
50 // Recorded offline page activities. | |
51 std::deque<std::string> activities_; | |
52 | |
53 // Whether we are currently recording logs or not. | |
54 bool is_logging_; | |
55 }; | |
56 } // namespace offline_pages | |
57 | |
58 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_EVENT_LOGGER_H_ | |
OLD | NEW |