| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ | 5 #ifndef CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ |
| 6 #define CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ | 6 #define CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_handle.h" | 9 #include "base/memory/scoped_handle.h" |
| 10 #include "chrome/browser/net/chrome_net_log.h" | 10 #include "chrome/browser/net/chrome_net_log.h" |
| 11 | 11 |
| 12 class FilePath; | 12 class FilePath; |
| 13 | 13 |
| 14 // NetLogLogger watches the NetLog event stream, and sends all entries to | 14 // NetLogLogger watches the NetLog event stream, and sends all entries to |
| 15 // VLOG(1) or a path specified on creation. This is to debug errors that | 15 // VLOG(1) or a path specified on creation. This is to debug errors that |
| 16 // prevent getting to the about:net-internals page. | 16 // prevent getting to the about:net-internals page. |
| 17 // | 17 // |
| 18 // Relies on ChromeNetLog only calling an Observer once at a time for | 18 // Relies on ChromeNetLog only calling an Observer once at a time for |
| 19 // thread-safety. | 19 // thread-safety. |
| 20 class NetLogLogger : public ChromeNetLog::ThreadSafeObserver { | 20 class NetLogLogger : public ChromeNetLog::ThreadSafeObserver { |
| 21 public: | 21 public: |
| 22 // If |log_path| is empty or file creation fails, writes to VLOG(1). | 22 // If |log_path| is empty or file creation fails, writes to VLOG(1). |
| 23 // Otherwise, writes to |log_path|. Uses one line per entry, for | 23 // Otherwise, writes to |log_path|. Uses one line per entry, for |
| 24 // easy parsing. | 24 // easy parsing. |
| 25 explicit NetLogLogger(const FilePath &log_path); | 25 explicit NetLogLogger(const FilePath &log_path); |
| 26 ~NetLogLogger(); | 26 virtual ~NetLogLogger(); |
| 27 | 27 |
| 28 // ThreadSafeObserver implementation: | 28 // ThreadSafeObserver implementation: |
| 29 virtual void OnAddEntry(net::NetLog::EventType type, | 29 virtual void OnAddEntry(net::NetLog::EventType type, |
| 30 const base::TimeTicks& time, | 30 const base::TimeTicks& time, |
| 31 const net::NetLog::Source& source, | 31 const net::NetLog::Source& source, |
| 32 net::NetLog::EventPhase phase, | 32 net::NetLog::EventPhase phase, |
| 33 net::NetLog::EventParameters* params) OVERRIDE; | 33 net::NetLog::EventParameters* params) OVERRIDE; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 ScopedStdioHandle file_; | 36 ScopedStdioHandle file_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); | 38 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 #endif // CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ | 41 #endif // CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ |
| 42 | |
| OLD | NEW |