| 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_LOG_NET_LOG_LOGGER_H_ | 5 #ifndef NET_LOG_NET_LOG_LOGGER_H_ |
| 6 #define NET_LOG_NET_LOG_LOGGER_H_ | 6 #define NET_LOG_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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // NetLogLogger watches the NetLog event stream, and sends all entries to | 25 // NetLogLogger watches the NetLog event stream, and sends all entries to |
| 26 // a file specified on creation. | 26 // a file specified on creation. |
| 27 // | 27 // |
| 28 // The text file will contain a single JSON object. | 28 // The text file will contain a single JSON object. |
| 29 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver { | 29 class NET_EXPORT NetLogLogger : public NetLog::ThreadSafeObserver { |
| 30 public: | 30 public: |
| 31 NetLogLogger(); | 31 NetLogLogger(); |
| 32 ~NetLogLogger() override; | 32 ~NetLogLogger() override; |
| 33 | 33 |
| 34 // Sets the log level to log at. Must be called before StartObserving. | 34 // Sets the capture mode to log at. Must be called before StartObserving. |
| 35 void set_log_level(NetLog::LogLevel log_level); | 35 void set_capture_mode(NetLogCaptureMode capture_mode); |
| 36 | 36 |
| 37 // Starts observing |net_log| and writes output to |file|. Must not already | 37 // Starts observing |net_log| and writes output to |file|. Must not already |
| 38 // be watching a NetLog. Separate from constructor to enforce thread safety. | 38 // be watching a NetLog. Separate from constructor to enforce thread safety. |
| 39 // | 39 // |
| 40 // |file| must be a non-NULL empty file that's open for writing. | 40 // |file| must be a non-NULL empty file that's open for writing. |
| 41 // | 41 // |
| 42 // |constants| is an optional legend for decoding constant values used in the | 42 // |constants| is an optional legend for decoding constant values used in the |
| 43 // log. It should generally be a modified version of GetNetConstants(). If | 43 // log. It should generally be a modified version of GetNetConstants(). If |
| 44 // not present, the output of GetNetConstants() will be used. | 44 // not present, the output of GetNetConstants() will be used. |
| 45 // | 45 // |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 // network stack state to the log. If the context is non-NULL, this must be | 58 // network stack state to the log. If the context is non-NULL, this must be |
| 59 // called on the context's thread. | 59 // called on the context's thread. |
| 60 void StopObserving(net::URLRequestContext* url_request_context); | 60 void StopObserving(net::URLRequestContext* url_request_context); |
| 61 | 61 |
| 62 // net::NetLog::ThreadSafeObserver implementation: | 62 // net::NetLog::ThreadSafeObserver implementation: |
| 63 void OnAddEntry(const NetLog::Entry& entry) override; | 63 void OnAddEntry(const NetLog::Entry& entry) override; |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 base::ScopedFILE file_; | 66 base::ScopedFILE file_; |
| 67 | 67 |
| 68 // The LogLevel to log at. | 68 // The capture mode to log at. |
| 69 NetLog::LogLevel log_level_; | 69 NetLogCaptureMode capture_mode_; |
| 70 | 70 |
| 71 // True if OnAddEntry() has been called at least once. | 71 // True if OnAddEntry() has been called at least once. |
| 72 bool added_events_; | 72 bool added_events_; |
| 73 | 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); | 74 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 } // namespace net | 77 } // namespace net |
| 78 | 78 |
| 79 #endif // NET_LOG_NET_LOG_LOGGER_H_ | 79 #endif // NET_LOG_NET_LOG_LOGGER_H_ |
| OLD | NEW |