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