| Index: chrome/browser/net/chrome_net_log.cc
|
| diff --git a/chrome/browser/net/chrome_net_log.cc b/chrome/browser/net/chrome_net_log.cc
|
| index 1dda8cce8f78e17571b7324e4fef2da936a75abf..674ee64a72e9df096506edb4043014a5fc0adbcf 100644
|
| --- a/chrome/browser/net/chrome_net_log.cc
|
| +++ b/chrome/browser/net/chrome_net_log.cc
|
| @@ -19,14 +19,52 @@
|
| #include "net/log/trace_net_log_observer.h"
|
| #include "net/log/write_to_file_net_log_observer.h"
|
|
|
| +namespace {
|
| +
|
| +net::NetLogCaptureMode GetCaptureModeFromCommandLine(
|
| + const base::CommandLine& command_line) {
|
| + const net::NetLogCaptureMode kDefault = net::NetLogCaptureMode::Default();
|
| +
|
| + // TODO(eroman): The NetLog "capture mode" used to be called the "log
|
| + // level". To preserve backwards compatibility the log level of old is
|
| + // converted into a capture mode.
|
| + if (!command_line.HasSwitch(switches::kNetLogLevel))
|
| + return kDefault;
|
| +
|
| + std::string log_level_string =
|
| + command_line.GetSwitchValueASCII(switches::kNetLogLevel);
|
| +
|
| + int level;
|
| + if (!base::StringToInt(log_level_string, &level))
|
| + return kDefault;
|
| +
|
| + switch (level) {
|
| + case 0:
|
| + return net::NetLogCaptureMode::IncludeSocketBytes();
|
| + case 1:
|
| + return net::NetLogCaptureMode::IncludeCookiesAndCredentials();
|
| + case 2:
|
| + return net::NetLogCaptureMode::Default();
|
| + case 3:
|
| + return net::NetLogCaptureMode::None();
|
| + default:
|
| + LOG(ERROR) << "Unrecognized --" << switches::kNetLogLevel;
|
| + break;
|
| + }
|
| +
|
| + return kDefault;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| ChromeNetLog::ChromeNetLog()
|
| : net_log_temp_file_(new NetLogTempFile(this)) {
|
| - const base::CommandLine* command_line =
|
| - base::CommandLine::ForCurrentProcess();
|
| + const base::CommandLine& command_line =
|
| + *base::CommandLine::ForCurrentProcess();
|
|
|
| - if (command_line->HasSwitch(switches::kLogNetLog)) {
|
| + if (command_line.HasSwitch(switches::kLogNetLog)) {
|
| base::FilePath log_path =
|
| - command_line->GetSwitchValuePath(switches::kLogNetLog);
|
| + command_line.GetSwitchValuePath(switches::kLogNetLog);
|
| // Much like logging.h, bypass threading restrictions by using fopen
|
| // directly. Have to write on a thread that's shutdown to handle events on
|
| // shutdown properly, and posting events to another thread as they occur
|
| @@ -46,17 +84,11 @@ ChromeNetLog::ChromeNetLog()
|
| } else {
|
| scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants());
|
| net_log_logger_.reset(new net::WriteToFileNetLogObserver());
|
| - if (command_line->HasSwitch(switches::kNetLogLevel)) {
|
| - std::string log_level_string =
|
| - command_line->GetSwitchValueASCII(switches::kNetLogLevel);
|
| - int command_line_log_level;
|
| - if (base::StringToInt(log_level_string, &command_line_log_level) &&
|
| - command_line_log_level >= LOG_ALL &&
|
| - command_line_log_level <= LOG_NONE) {
|
| - net_log_logger_->set_log_level(
|
| - static_cast<LogLevel>(command_line_log_level));
|
| - }
|
| - }
|
| +
|
| + net::NetLogCaptureMode capture_mode =
|
| + GetCaptureModeFromCommandLine(command_line);
|
| + net_log_logger_->set_capture_mode(capture_mode);
|
| +
|
| net_log_logger_->StartObserving(this, file.Pass(), constants.get(),
|
| nullptr);
|
| }
|
|
|