Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/net/net_log_temp_file.h" | 14 #include "chrome/browser/net/net_log_temp_file.h" |
| 15 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | 15 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "net/base/net_log_logger.h" | 18 #include "net/base/net_log_logger.h" |
| 19 #include "net/base/trace_net_log_observer.h" | |
| 19 | 20 |
| 20 ChromeNetLog::ChromeNetLog() | 21 ChromeNetLog::ChromeNetLog() |
| 21 : net_log_temp_file_(new NetLogTempFile(this)) { | 22 : net_log_temp_file_(new NetLogTempFile(this)) { |
| 22 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 23 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 23 // Adjust base log level based on command line switch, if present. | 24 // Adjust base log level based on command line switch, if present. |
| 24 // This is done before adding any observers so the call to UpdateLogLevel when | 25 // This is done before adding any observers so the call to UpdateLogLevel when |
| 25 // an observers is added will set |effective_log_level_| correctly. | 26 // an observers is added will set |effective_log_level_| correctly. |
| 26 if (command_line->HasSwitch(switches::kNetLogLevel)) { | 27 if (command_line->HasSwitch(switches::kNetLogLevel)) { |
| 27 std::string log_level_string = | 28 std::string log_level_string = |
| 28 command_line->GetSwitchValueASCII(switches::kNetLogLevel); | 29 command_line->GetSwitchValueASCII(switches::kNetLogLevel); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 52 | 53 |
| 53 if (file == NULL) { | 54 if (file == NULL) { |
| 54 LOG(ERROR) << "Could not open file " << log_path.value() | 55 LOG(ERROR) << "Could not open file " << log_path.value() |
| 55 << " for net logging"; | 56 << " for net logging"; |
| 56 } else { | 57 } else { |
| 57 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); | 58 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); |
| 58 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); | 59 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); |
| 59 net_log_logger_->StartObserving(this); | 60 net_log_logger_->StartObserving(this); |
| 60 } | 61 } |
| 61 } | 62 } |
| 63 | |
| 64 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); | |
| 65 trace_net_log_observer_->WatchForTraceStart(this); | |
| 62 } | 66 } |
| 63 | 67 |
| 64 ChromeNetLog::~ChromeNetLog() { | 68 ChromeNetLog::~ChromeNetLog() { |
| 65 net_log_temp_file_.reset(); | 69 net_log_temp_file_.reset(); |
| 66 // Remove the observers we own before we're destroyed. | 70 // Remove the observers we own before we're destroyed. |
| 67 if (net_log_logger_) | 71 if (net_log_logger_) |
| 68 RemoveThreadSafeObserver(net_log_logger_.get()); | 72 RemoveThreadSafeObserver(net_log_logger_.get()); |
| 73 if (trace_net_log_observer_) { | |
| 74 trace_net_log_observer_->StopWatchForTraceStart(); | |
| 75 } | |
|
mmenke
2014/08/15 20:42:53
nit: Don't use braces on if's when the conditiona
xunjieli
2014/08/15 21:55:15
Done. Thanks!
| |
| 69 } | 76 } |
| 70 | 77 |
| OLD | NEW |