| 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_CHROME_NET_LOG_H_ | 5 #ifndef COMPONENTS_NET_LOG_CHROME_NET_LOG_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_NET_LOG_H_ | 6 #define COMPONENTS_NET_LOG_CHROME_NET_LOG_H_ |
| 7 | 7 |
| 8 #include "base/atomicops.h" | 8 #include <string> |
| 9 |
| 10 #include "base/command_line.h" |
| 11 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | |
| 11 #include "base/synchronization/lock.h" | |
| 12 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
| 13 | 14 |
| 15 namespace base { |
| 16 class FilePath; |
| 17 class Value; |
| 18 } |
| 19 |
| 14 namespace net { | 20 namespace net { |
| 15 class WriteToFileNetLogObserver; | 21 class WriteToFileNetLogObserver; |
| 16 class TraceNetLogObserver; | 22 class TraceNetLogObserver; |
| 17 } | 23 } |
| 18 | 24 |
| 25 namespace net_log { |
| 26 |
| 19 class NetLogTempFile; | 27 class NetLogTempFile; |
| 20 | 28 |
| 21 // ChromeNetLog is an implementation of NetLog that adds file loggers | 29 // ChromeNetLog is an implementation of NetLog that adds file loggers |
| 22 // as its observers. | 30 // as its observers. |
| 23 class ChromeNetLog : public net::NetLog { | 31 class ChromeNetLog : public net::NetLog { |
| 24 public: | 32 public: |
| 25 ChromeNetLog(); | 33 // The log is saved to |log_file|. |
| 34 // |log_file_mode| is the mode used to log in |log_file|. |
| 35 // If |log_file| is empty, only a temporary log is created, and |
| 36 // |log_file_mode| is not used. |
| 37 ChromeNetLog(const base::FilePath& log_file, |
| 38 net::NetLogCaptureMode log_file_mode, |
| 39 const base::CommandLine::StringType& command_line_string, |
| 40 const std::string& channel_string); |
| 26 ~ChromeNetLog() override; | 41 ~ChromeNetLog() override; |
| 27 | 42 |
| 28 NetLogTempFile* net_log_temp_file() { | 43 NetLogTempFile* net_log_temp_file() { return net_log_temp_file_.get(); } |
| 29 return net_log_temp_file_.get(); | 44 |
| 30 } | 45 // Returns a Value containing constants needed to load a log file. |
| 46 // Safe to call on any thread. Caller takes ownership of the returned Value. |
| 47 static base::Value* GetConstants( |
| 48 const base::CommandLine::StringType& command_line_string, |
| 49 const std::string& channel_string); |
| 31 | 50 |
| 32 private: | 51 private: |
| 33 scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; | 52 scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; |
| 34 scoped_ptr<NetLogTempFile> net_log_temp_file_; | 53 scoped_ptr<NetLogTempFile> net_log_temp_file_; |
| 35 | |
| 36 scoped_ptr<net::TraceNetLogObserver> trace_net_log_observer_; | 54 scoped_ptr<net::TraceNetLogObserver> trace_net_log_observer_; |
| 37 | 55 |
| 38 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); | 56 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog); |
| 39 }; | 57 }; |
| 40 | 58 |
| 41 #endif // CHROME_BROWSER_NET_CHROME_NET_LOG_H_ | 59 } // namespace net_log |
| 60 |
| 61 #endif // COMPONENTS_NET_LOG_CHROME_NET_LOG_H_ |
| OLD | NEW |