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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_NET_LOG_CHROME_NET_LOG_H_
6 #define COMPONENTS_NET_LOG_CHROME_NET_LOG_H_
10 #include "base/command_line.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/log/net_log.h"
21 class WriteToFileNetLogObserver
;
22 class TraceNetLogObserver
;
29 // ChromeNetLog is an implementation of NetLog that adds file loggers
31 class ChromeNetLog
: public net::NetLog
{
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
);
41 ~ChromeNetLog() override
;
43 NetLogTempFile
* net_log_temp_file() { return net_log_temp_file_
.get(); }
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
);
52 scoped_ptr
<net::WriteToFileNetLogObserver
> write_to_file_observer_
;
53 scoped_ptr
<NetLogTempFile
> net_log_temp_file_
;
54 scoped_ptr
<net::TraceNetLogObserver
> trace_net_log_observer_
;
56 DISALLOW_COPY_AND_ASSIGN(ChromeNetLog
);
59 } // namespace net_log
61 #endif // COMPONENTS_NET_LOG_CHROME_NET_LOG_H_