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

Side by Side Diff: components/offline_pages/offline_event_logger.h

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
(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 // Maximum number of recorded Logs to keep track of at any moment. Defined in
17 // offline_event_logger.cc.
18 extern const size_t kMaxLogCount;
19
20 // Facilitates the logging of events. Subclasses should create methods that
21 // call RecordActivity to write into the log. |SetIsLogging|, |GetLogs|, and
22 // |Clear| are called from the chrome://offline-internals page.
23 //
24 // Logging should be done by calling the corresponding subclass methods when
25 // a loggable event occurs (i.e. when status has changed for a save request
26 // or when an offlined page has been accessed/saved).
27 //
28 // This log only keeps track of the last |kMaxLogCount| events.
29 class OfflineEventLogger {
30 public:
31 // This client interface should be implemented by the class which provides the
32 // ability to pipe the log somewhere else (Eg. a java class which can write
33 // logs into a file). It's optional and uses SetClient() to attach the client
34 // to the event logger instance.
35 class Client {
36 public:
37 virtual ~Client(){};
38 virtual void CustomLog(const std::string& message) = 0;
39 };
40
41 OfflineEventLogger();
42
43 ~OfflineEventLogger();
44
45 // Clears the recorded activities.
46 void Clear();
47
48 // Turns logging on/off.
49 void SetIsLogging(bool is_logging);
50
51 // Returns whether we are currently logging.
52 bool GetIsLogging();
53
54 // Dumps the current activity list into |records|.
55 void GetLogs(std::vector<std::string>* records);
56
57 // Write the activity into the cycling log if we are currently logging.
58 void RecordActivity(const std::string& activity);
59
60 // Sets the client for custom logging process if needed.
61 void SetClient(Client* client);
62
63 private:
64 // Recorded offline page activities.
65 std::deque<std::string> activities_;
66
67 // Whether we are currently recording logs or not.
68 bool is_logging_;
69
70 // Not owned.
71 Client* client_;
72 };
73 } // namespace offline_pages
74
75 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_EVENT_LOGGER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/downloads/offline_page_download_notifier.h ('k') | components/offline_pages/offline_event_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698