| 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 #include "chrome/browser/net/chrome_net_log.h" | 5 #include "chrome/browser/net/chrome_net_log.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 LOG(ERROR) << "Could not open file " << log_path.value() | 44 LOG(ERROR) << "Could not open file " << log_path.value() |
| 45 << " for net logging"; | 45 << " for net logging"; |
| 46 } else { | 46 } else { |
| 47 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); | 47 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); |
| 48 net_log_logger_.reset(new net::NetLogLogger()); | 48 net_log_logger_.reset(new net::NetLogLogger()); |
| 49 if (command_line->HasSwitch(switches::kNetLogLevel)) { | 49 if (command_line->HasSwitch(switches::kNetLogLevel)) { |
| 50 std::string log_level_string = | 50 std::string log_level_string = |
| 51 command_line->GetSwitchValueASCII(switches::kNetLogLevel); | 51 command_line->GetSwitchValueASCII(switches::kNetLogLevel); |
| 52 int command_line_log_level; | 52 int command_line_log_level; |
| 53 if (base::StringToInt(log_level_string, &command_line_log_level) && | 53 if (base::StringToInt(log_level_string, &command_line_log_level) && |
| 54 command_line_log_level >= LOG_ALL && | 54 command_line_log_level >= net::NetLogCaptureMode::NONE && |
| 55 command_line_log_level <= LOG_NONE) { | 55 command_line_log_level <= net::NetLogCaptureMode::ALL) { |
| 56 net_log_logger_->set_log_level( | 56 // TODO(eroman): The level is inverted to maintain backwards |
| 57 static_cast<LogLevel>(command_line_log_level)); | 57 // compatibility (the log level values used to increase in the |
| 58 // opposite direction). |
| 59 command_line_log_level = |
| 60 net::NetLogCaptureMode::ALL - command_line_log_level; |
| 61 |
| 62 net_log_logger_->set_capture_mode( |
| 63 net::NetLogCaptureMode(static_cast<net::NetLogCaptureMode::Level>( |
| 64 command_line_log_level))); |
| 58 } | 65 } |
| 59 } | 66 } |
| 60 net_log_logger_->StartObserving(this, file.Pass(), constants.get(), | 67 net_log_logger_->StartObserving(this, file.Pass(), constants.get(), |
| 61 nullptr); | 68 nullptr); |
| 62 } | 69 } |
| 63 } | 70 } |
| 64 | 71 |
| 65 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); | 72 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); |
| 66 trace_net_log_observer_->WatchForTraceStart(this); | 73 trace_net_log_observer_->WatchForTraceStart(this); |
| 67 } | 74 } |
| 68 | 75 |
| 69 ChromeNetLog::~ChromeNetLog() { | 76 ChromeNetLog::~ChromeNetLog() { |
| 70 net_log_temp_file_.reset(); | 77 net_log_temp_file_.reset(); |
| 71 // Remove the observers we own before we're destroyed. | 78 // Remove the observers we own before we're destroyed. |
| 72 if (net_log_logger_) | 79 if (net_log_logger_) |
| 73 net_log_logger_->StopObserving(nullptr); | 80 net_log_logger_->StopObserving(nullptr); |
| 74 if (trace_net_log_observer_) | 81 if (trace_net_log_observer_) |
| 75 trace_net_log_observer_->StopWatchForTraceStart(); | 82 trace_net_log_observer_->StopWatchForTraceStart(); |
| 76 } | 83 } |
| 77 | 84 |
| OLD | NEW |