OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef NET_BASE_NET_LOG_LOGGER_H_ | 5 #ifndef NET_BASE_NET_LOG_LOGGER_H_ |
6 #define NET_BASE_NET_LOG_LOGGER_H_ | 6 #define NET_BASE_NET_LOG_LOGGER_H_ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // NetLogLogger watches the NetLog event stream, and sends all entries to | 21 // NetLogLogger watches the NetLog event stream, and sends all entries to |
22 // a file specified on creation. | 22 // a file specified on creation. |
23 // | 23 // |
24 // The text file will contain a single JSON object. | 24 // The text file will contain a single JSON object. |
25 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver { | 25 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver { |
26 public: | 26 public: |
27 // Takes ownership of |file| and will write network events to it once logging | 27 // Takes ownership of |file| and will write network events to it once logging |
28 // starts. |file| must be non-NULL handle and be open for writing. | 28 // starts. |file| must be non-NULL handle and be open for writing. |
29 // |constants| is a legend for decoding constant values used in the log. | 29 // |constants| is a legend for decoding constant values used in the log. |
30 NetLogLogger(FILE* file, const base::Value& constants); | 30 NetLogLogger(FILE* file, const base::Value& constants); |
31 virtual ~NetLogLogger(); | 31 ~NetLogLogger() override; |
32 | 32 |
33 // Sets the log level to log at. Must be called before StartObserving. | 33 // Sets the log level to log at. Must be called before StartObserving. |
34 void set_log_level(NetLog::LogLevel log_level); | 34 void set_log_level(NetLog::LogLevel log_level); |
35 | 35 |
36 // Starts observing specified NetLog. Must not already be watching a NetLog. | 36 // Starts observing specified NetLog. Must not already be watching a NetLog. |
37 // Separate from constructor to enforce thread safety. | 37 // Separate from constructor to enforce thread safety. |
38 void StartObserving(NetLog* net_log); | 38 void StartObserving(NetLog* net_log); |
39 | 39 |
40 // Stops observing net_log(). Must already be watching. | 40 // Stops observing net_log(). Must already be watching. |
41 void StopObserving(); | 41 void StopObserving(); |
42 | 42 |
43 // net::NetLog::ThreadSafeObserver implementation: | 43 // net::NetLog::ThreadSafeObserver implementation: |
44 virtual void OnAddEntry(const NetLog::Entry& entry) override; | 44 void OnAddEntry(const NetLog::Entry& entry) override; |
45 | 45 |
46 // Create a dictionary containing legend for net/ constants. Caller takes | 46 // Create a dictionary containing legend for net/ constants. Caller takes |
47 // ownership of returned value. | 47 // ownership of returned value. |
48 static base::DictionaryValue* GetConstants(); | 48 static base::DictionaryValue* GetConstants(); |
49 | 49 |
50 private: | 50 private: |
51 base::ScopedFILE file_; | 51 base::ScopedFILE file_; |
52 | 52 |
53 // The LogLevel to log at. | 53 // The LogLevel to log at. |
54 NetLog::LogLevel log_level_; | 54 NetLog::LogLevel log_level_; |
55 | 55 |
56 // True if OnAddEntry() has been called at least once. | 56 // True if OnAddEntry() has been called at least once. |
57 bool added_events_; | 57 bool added_events_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); | 59 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); |
60 }; | 60 }; |
61 | 61 |
62 } // namespace net | 62 } // namespace net |
63 | 63 |
64 #endif // NET_BASE_NET_LOG_LOGGER_H_ | 64 #endif // NET_BASE_NET_LOG_LOGGER_H_ |
OLD | NEW |