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 "components/net_log/chrome_net_log.h" | 5 #include "components/net_log/chrome_net_log.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
43 file.reset(_wfopen(log_file.value().c_str(), L"w")); | 43 file.reset(_wfopen(log_file.value().c_str(), L"w")); |
44 #elif defined(OS_POSIX) | 44 #elif defined(OS_POSIX) |
45 file.reset(fopen(log_file.value().c_str(), "w")); | 45 file.reset(fopen(log_file.value().c_str(), "w")); |
46 #endif | 46 #endif |
47 | 47 |
48 if (!file) { | 48 if (!file) { |
49 LOG(ERROR) << "Could not open file " << log_file.value() | 49 LOG(ERROR) << "Could not open file " << log_file.value() |
50 << " for net logging"; | 50 << " for net logging"; |
51 } else { | 51 } else { |
52 scoped_ptr<base::Value> constants( | 52 std::unique_ptr<base::Value> constants( |
53 GetConstants(command_line_string, channel_string)); | 53 GetConstants(command_line_string, channel_string)); |
54 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); | 54 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); |
55 | 55 |
56 write_to_file_observer_->set_capture_mode(log_file_mode); | 56 write_to_file_observer_->set_capture_mode(log_file_mode); |
57 | 57 |
58 write_to_file_observer_->StartObserving(this, std::move(file), | 58 write_to_file_observer_->StartObserving(this, std::move(file), |
59 constants.get(), nullptr); | 59 constants.get(), nullptr); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); | 63 trace_net_log_observer_.reset(new net::TraceNetLogObserver()); |
64 trace_net_log_observer_->WatchForTraceStart(this); | 64 trace_net_log_observer_->WatchForTraceStart(this); |
65 } | 65 } |
66 | 66 |
67 ChromeNetLog::~ChromeNetLog() { | 67 ChromeNetLog::~ChromeNetLog() { |
68 net_log_temp_file_.reset(); | 68 net_log_temp_file_.reset(); |
69 // Remove the observers we own before we're destroyed. | 69 // Remove the observers we own before we're destroyed. |
70 if (write_to_file_observer_) | 70 if (write_to_file_observer_) |
71 write_to_file_observer_->StopObserving(nullptr); | 71 write_to_file_observer_->StopObserving(nullptr); |
72 if (trace_net_log_observer_) | 72 if (trace_net_log_observer_) |
73 trace_net_log_observer_->StopWatchForTraceStart(); | 73 trace_net_log_observer_->StopWatchForTraceStart(); |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 base::Value* ChromeNetLog::GetConstants( | 77 base::Value* ChromeNetLog::GetConstants( |
78 const base::CommandLine::StringType& command_line_string, | 78 const base::CommandLine::StringType& command_line_string, |
79 const std::string& channel_string) { | 79 const std::string& channel_string) { |
80 scoped_ptr<base::DictionaryValue> constants_dict = net::GetNetConstants(); | 80 std::unique_ptr<base::DictionaryValue> constants_dict = |
| 81 net::GetNetConstants(); |
81 DCHECK(constants_dict); | 82 DCHECK(constants_dict); |
82 | 83 |
83 // Add a dictionary with the version of the client and its command line | 84 // Add a dictionary with the version of the client and its command line |
84 // arguments. | 85 // arguments. |
85 { | 86 { |
86 base::DictionaryValue* dict = new base::DictionaryValue(); | 87 base::DictionaryValue* dict = new base::DictionaryValue(); |
87 | 88 |
88 // We have everything we need to send the right values. | 89 // We have everything we need to send the right values. |
89 dict->SetString("name", version_info::GetProductName()); | 90 dict->SetString("name", version_info::GetProductName()); |
90 dict->SetString("version", version_info::GetVersionNumber()); | 91 dict->SetString("version", version_info::GetVersionNumber()); |
(...skipping 11 matching lines...) Expand all Loading... |
102 constants_dict->Set("clientInfo", dict); | 103 constants_dict->Set("clientInfo", dict); |
103 | 104 |
104 data_reduction_proxy::DataReductionProxyEventStore::AddConstants( | 105 data_reduction_proxy::DataReductionProxyEventStore::AddConstants( |
105 constants_dict.get()); | 106 constants_dict.get()); |
106 } | 107 } |
107 | 108 |
108 return constants_dict.release(); | 109 return constants_dict.release(); |
109 } | 110 } |
110 | 111 |
111 } // namespace net_log | 112 } // namespace net_log |
OLD | NEW |