Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/file_path.h" | |
| 8 #include "base/memory/scoped_handle.h" | 12 #include "base/memory/scoped_handle.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 9 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
| 10 | 15 |
| 11 class FilePath; | 16 class FilePath; |
| 12 | 17 |
| 13 // NetLogLogger watches the NetLog event stream, and sends all entries to | 18 // NetLogLogger watches the NetLog event stream, and sends all entries to |
| 14 // VLOG(1) or a path specified on creation. This is to debug errors that | 19 // VLOG(1) or a path specified on creation. This is to debug errors that |
| 15 // prevent getting to the about:net-internals page. | 20 // prevent getting to the about:net-internals page. |
| 16 // | 21 // |
| 17 // When writing directly to a file rather than VLOG(1), the text file will | 22 // When writing directly to a file rather than VLOG(1), the text file will |
| 18 // contain a single JSON object, with an extra comma on the end and missing | 23 // contain a single JSON object, with an extra comma on the end and missing |
| 19 // a terminal "]}". | 24 // a terminal "]}". |
| 20 // | 25 // |
| 21 // Relies on ChromeNetLog only calling an Observer once at a time for | 26 // Relies on ChromeNetLog only calling an Observer once at a time for |
| 22 // thread-safety. | 27 // thread-safety. |
| 23 class NetLogLogger : public net::NetLog::ThreadSafeObserver { | 28 class NetLogLogger : public net::NetLog::ThreadSafeObserver { |
| 24 public: | 29 public: |
| 25 // If |log_path| is empty or file creation fails, writes to VLOG(1). | 30 // If |log_path| is empty or file creation fails, writes to VLOG(1). |
| 26 // Otherwise, writes to |log_path|. Uses one line per entry, for | 31 // Otherwise, writes to |log_path|. Uses one line per entry, for |
| 27 // easy parsing. | 32 // easy parsing. |
| 28 explicit NetLogLogger(const FilePath &log_path); | 33 explicit NetLogLogger(const FilePath &log_path); |
| 29 virtual ~NetLogLogger(); | 34 virtual ~NetLogLogger(); |
| 30 | 35 |
| 31 // Starts observing specified NetLog. Must not already be watching a NetLog. | 36 // Starts observing specified NetLog. Must not already be watching a NetLog. |
| 32 // Separate from constructor to enforce thread safety. | 37 // Separate from constructor to enforce thread safety. |
| 33 void StartObserving(net::NetLog* net_log); | 38 void StartObserving(net::NetLog* net_log); |
| 34 | 39 |
| 35 // net::NetLog::ThreadSafeObserver implementation: | 40 // net::NetLog::ThreadSafeObserver implementation: |
| 36 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 41 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
| 37 | 42 |
| 43 // Start collecting NetLog data into a temporary file. | |
| 44 static void StartNetLog(); | |
|
qsr
2012/12/10 10:51:07
Did you see with any of the Owners if that is fine
| |
| 45 | |
| 46 // Stop collecting NetLog data into a temporary file. | |
| 47 static void StopNetLog(); | |
| 48 | |
| 49 // Send NetLog data that is in the temporary file. | |
| 50 static void SendNetLog(); | |
| 51 | |
| 38 private: | 52 private: |
| 53 // Open the file specified by |log_path_|. | |
| 54 void OpenFile(); | |
| 55 | |
| 56 // Send NetLog via email. | |
| 57 static void SendEmail(const FilePath::StringType& file_to_attch); | |
|
qsr
2012/12/10 10:51:07
1. attach
2. Why isn't this a const FilePath& ?
| |
| 58 | |
| 39 ScopedStdioHandle file_; | 59 ScopedStdioHandle file_; |
| 60 FilePath log_path_; | |
| 61 std::vector<FilePath::StringType> files_to_delete_; | |
|
qsr
2012/12/10 10:51:07
Same thing here, why isn't those FilePath?
| |
| 40 | 62 |
| 41 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); | 63 DISALLOW_COPY_AND_ASSIGN(NetLogLogger); |
| 42 }; | 64 }; |
| 43 | 65 |
| 44 #endif // CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ | 66 #endif // CHROME_BROWSER_NET_NET_LOG_LOGGER_H_ |
| OLD | NEW |