| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_net_log.h" | 5 #include "content/shell/browser/shell_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/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "net/log/net_log_logger.h" | |
| 15 #include "net/log/net_log_util.h" | 14 #include "net/log/net_log_util.h" |
| 15 #include "net/log/write_to_file_net_log_observer.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 base::DictionaryValue* GetShellConstants(const std::string& app_name) { | 21 base::DictionaryValue* GetShellConstants(const std::string& app_name) { |
| 22 scoped_ptr<base::DictionaryValue> constants_dict = net::GetNetConstants(); | 22 scoped_ptr<base::DictionaryValue> constants_dict = net::GetNetConstants(); |
| 23 | 23 |
| 24 // Add a dictionary with client information | 24 // Add a dictionary with client information |
| 25 base::DictionaryValue* dict = new base::DictionaryValue(); | 25 base::DictionaryValue* dict = new base::DictionaryValue(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 file.reset(_wfopen(log_path.value().c_str(), L"w")); | 56 file.reset(_wfopen(log_path.value().c_str(), L"w")); |
| 57 #elif defined(OS_POSIX) | 57 #elif defined(OS_POSIX) |
| 58 file.reset(fopen(log_path.value().c_str(), "w")); | 58 file.reset(fopen(log_path.value().c_str(), "w")); |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 if (!file) { | 61 if (!file) { |
| 62 LOG(ERROR) << "Could not open file " << log_path.value() | 62 LOG(ERROR) << "Could not open file " << log_path.value() |
| 63 << " for net logging"; | 63 << " for net logging"; |
| 64 } else { | 64 } else { |
| 65 scoped_ptr<base::Value> constants(GetShellConstants(app_name)); | 65 scoped_ptr<base::Value> constants(GetShellConstants(app_name)); |
| 66 net_log_logger_.reset(new net::NetLogLogger()); | 66 net_log_logger_.reset(new net::WriteToFileNetLogObserver()); |
| 67 net_log_logger_->StartObserving(this, file.Pass(), constants.get(), | 67 net_log_logger_->StartObserving(this, file.Pass(), constants.get(), |
| 68 nullptr); | 68 nullptr); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 ShellNetLog::~ShellNetLog() { | 73 ShellNetLog::~ShellNetLog() { |
| 74 // Remove the observer we own before we're destroyed. | 74 // Remove the observer we own before we're destroyed. |
| 75 if (net_log_logger_) | 75 if (net_log_logger_) |
| 76 net_log_logger_->StopObserving(nullptr); | 76 net_log_logger_->StopObserving(nullptr); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace content | 79 } // namespace content |
| OLD | NEW |