Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: net/tools/net_watcher/net_watcher.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/get_server_time/get_server_time.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This is a small utility that watches for and logs network changes. 5 // This is a small utility that watches for and logs network changes.
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 9
9 #include "base/at_exit.h" 10 #include "base/at_exit.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "net/base/network_change_notifier.h" 20 #include "net/base/network_change_notifier.h"
21 #include "net/proxy/proxy_config.h" 21 #include "net/proxy/proxy_config.h"
22 #include "net/proxy/proxy_config_service.h" 22 #include "net/proxy/proxy_config_service.h"
23 #include "net/proxy/proxy_service.h" 23 #include "net/proxy/proxy_service.h"
24 24
25 #if defined(USE_GLIB) && !defined(OS_CHROMEOS) 25 #if defined(USE_GLIB) && !defined(OS_CHROMEOS)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 case net::NetworkChangeNotifier::CONNECTION_NONE: 62 case net::NetworkChangeNotifier::CONNECTION_NONE:
63 return "CONNECTION_NONE"; 63 return "CONNECTION_NONE";
64 case net::NetworkChangeNotifier::CONNECTION_BLUETOOTH: 64 case net::NetworkChangeNotifier::CONNECTION_BLUETOOTH:
65 return "CONNECTION_BLUETOOTH"; 65 return "CONNECTION_BLUETOOTH";
66 default: 66 default:
67 return "CONNECTION_UNEXPECTED"; 67 return "CONNECTION_UNEXPECTED";
68 } 68 }
69 } 69 }
70 70
71 std::string ProxyConfigToString(const net::ProxyConfig& config) { 71 std::string ProxyConfigToString(const net::ProxyConfig& config) {
72 scoped_ptr<base::Value> config_value(config.ToValue()); 72 std::unique_ptr<base::Value> config_value(config.ToValue());
73 std::string str; 73 std::string str;
74 base::JSONWriter::Write(*config_value, &str); 74 base::JSONWriter::Write(*config_value, &str);
75 return str; 75 return str;
76 } 76 }
77 77
78 const char* ConfigAvailabilityToString( 78 const char* ConfigAvailabilityToString(
79 net::ProxyConfigService::ConfigAvailability availability) { 79 net::ProxyConfigService::ConfigAvailability availability) {
80 switch (availability) { 80 switch (availability) {
81 case net::ProxyConfigService::CONFIG_PENDING: 81 case net::ProxyConfigService::CONFIG_PENDING:
82 return "CONFIG_PENDING"; 82 return "CONFIG_PENDING";
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 command_line->GetSwitchValueASCII(kIgnoreNetifFlag); 170 command_line->GetSwitchValueASCII(kIgnoreNetifFlag);
171 base::hash_set<std::string> ignored_interfaces; 171 base::hash_set<std::string> ignored_interfaces;
172 if (!ignored_netifs_str.empty()) { 172 if (!ignored_netifs_str.empty()) {
173 for (const std::string& ignored_netif : 173 for (const std::string& ignored_netif :
174 base::SplitString(ignored_netifs_str, ",", base::TRIM_WHITESPACE, 174 base::SplitString(ignored_netifs_str, ",", base::TRIM_WHITESPACE,
175 base::SPLIT_WANT_ALL)) { 175 base::SPLIT_WANT_ALL)) {
176 LOG(INFO) << "Ignoring: " << ignored_netif; 176 LOG(INFO) << "Ignoring: " << ignored_netif;
177 ignored_interfaces.insert(ignored_netif); 177 ignored_interfaces.insert(ignored_netif);
178 } 178 }
179 } 179 }
180 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( 180 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
181 new net::NetworkChangeNotifierLinux(ignored_interfaces)); 181 new net::NetworkChangeNotifierLinux(ignored_interfaces));
182 #else 182 #else
183 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier( 183 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier(
184 net::NetworkChangeNotifier::Create()); 184 net::NetworkChangeNotifier::Create());
185 #endif 185 #endif
186 186
187 // Use the network loop as the file loop also. 187 // Use the network loop as the file loop also.
188 scoped_ptr<net::ProxyConfigService> proxy_config_service( 188 std::unique_ptr<net::ProxyConfigService> proxy_config_service(
189 net::ProxyService::CreateSystemProxyConfigService( 189 net::ProxyService::CreateSystemProxyConfigService(
190 network_loop.task_runner(), network_loop.task_runner())); 190 network_loop.task_runner(), network_loop.task_runner()));
191 191
192 // Uses |network_change_notifier|. 192 // Uses |network_change_notifier|.
193 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher); 193 net::NetworkChangeNotifier::AddIPAddressObserver(&net_watcher);
194 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher); 194 net::NetworkChangeNotifier::AddConnectionTypeObserver(&net_watcher);
195 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher); 195 net::NetworkChangeNotifier::AddDNSObserver(&net_watcher);
196 net::NetworkChangeNotifier::AddNetworkChangeObserver(&net_watcher); 196 net::NetworkChangeNotifier::AddNetworkChangeObserver(&net_watcher);
197 197
198 proxy_config_service->AddObserver(&net_watcher); 198 proxy_config_service->AddObserver(&net_watcher);
(...skipping 19 matching lines...) Expand all
218 proxy_config_service->RemoveObserver(&net_watcher); 218 proxy_config_service->RemoveObserver(&net_watcher);
219 219
220 // Uses |network_change_notifier|. 220 // Uses |network_change_notifier|.
221 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher); 221 net::NetworkChangeNotifier::RemoveDNSObserver(&net_watcher);
222 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher); 222 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(&net_watcher);
223 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher); 223 net::NetworkChangeNotifier::RemoveIPAddressObserver(&net_watcher);
224 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher); 224 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(&net_watcher);
225 225
226 return 0; 226 return 0;
227 } 227 }
OLDNEW
« no previous file with comments | « net/tools/get_server_time/get_server_time.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698