Roll src/third_party/WebKit 48de1d8:ada7a3d (svn 202597:202598)
[chromium-blink-merge.git] / components / net_log / chrome_net_log.h
blobeae245d45e43a6e883715e62d073c257213045eb
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_
8 #include <string>
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"
15 namespace base {
16 class FilePath;
17 class Value;
20 namespace net {
21 class WriteToFileNetLogObserver;
22 class TraceNetLogObserver;
25 namespace net_log {
27 class NetLogTempFile;
29 // ChromeNetLog is an implementation of NetLog that adds file loggers
30 // as its observers.
31 class ChromeNetLog : public net::NetLog {
32 public:
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);
51 private:
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_