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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 11360108: Start calculating new combined NetworkChangeNotifier signal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address szym's first round of comments Created 8 years 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 | Annotate | Revision Log
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 #include "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 context->set_network_delegate(globals->system_network_delegate.get()); 229 context->set_network_delegate(globals->system_network_delegate.get());
230 context->set_http_user_agent_settings( 230 context->set_http_user_agent_settings(
231 globals->http_user_agent_settings.get()); 231 globals->http_user_agent_settings.get());
232 return context; 232 return context;
233 } 233 }
234 234
235 } // namespace 235 } // namespace
236 236
237 class IOThread::LoggingNetworkChangeObserver 237 class IOThread::LoggingNetworkChangeObserver
238 : public net::NetworkChangeNotifier::IPAddressObserver, 238 : public net::NetworkChangeNotifier::IPAddressObserver,
239 public net::NetworkChangeNotifier::ConnectionTypeObserver { 239 public net::NetworkChangeNotifier::ConnectionTypeObserver,
240 public net::NetworkChangeNotifier::NetworkChangeObserver {
240 public: 241 public:
241 // |net_log| must remain valid throughout our lifetime. 242 // |net_log| must remain valid throughout our lifetime.
242 explicit LoggingNetworkChangeObserver(net::NetLog* net_log) 243 explicit LoggingNetworkChangeObserver(net::NetLog* net_log)
243 : net_log_(net_log) { 244 : net_log_(net_log) {
244 net::NetworkChangeNotifier::AddIPAddressObserver(this); 245 net::NetworkChangeNotifier::AddIPAddressObserver(this);
245 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 246 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
247 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
246 } 248 }
247 249
248 ~LoggingNetworkChangeObserver() { 250 ~LoggingNetworkChangeObserver() {
249 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 251 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
250 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 252 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
253 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
251 } 254 }
252 255
256 // NetworkChangeNotifier::IPAddressObserver implementation.
253 virtual void OnIPAddressChanged() OVERRIDE { 257 virtual void OnIPAddressChanged() OVERRIDE {
254 VLOG(1) << "Observed a change to the network IP addresses"; 258 VLOG(1) << "Observed a change to the network IP addresses";
255 259
256 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); 260 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
257 } 261 }
258 262
263 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
259 virtual void OnConnectionTypeChanged( 264 virtual void OnConnectionTypeChanged(
260 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE { 265 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE {
261 std::string type_as_string = 266 std::string type_as_string =
262 net::NetworkChangeNotifier::ConnectionTypeToString(type); 267 net::NetworkChangeNotifier::ConnectionTypeToString(type);
263 268
264 VLOG(1) << "Observed a change to network connectivity state " 269 VLOG(1) << "Observed a change to network connectivity state "
265 << type_as_string; 270 << type_as_string;
266 271
267 net_log_->AddGlobalEntry( 272 net_log_->AddGlobalEntry(
268 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, 273 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED,
269 net::NetLog::StringCallback("new_connection_type", &type_as_string)); 274 net::NetLog::StringCallback("new_connection_type", &type_as_string));
270 } 275 }
271 276
277 // NetworkChangeNotifier::NetworkChangeObserver implementation.
278 virtual void OnNetworkChanged(
279 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE {
280 std::string type_as_string =
281 net::NetworkChangeNotifier::ConnectionTypeToString(type);
282
283 VLOG(1) << "Observed a network change to state " << type_as_string;
284
285 net_log_->AddGlobalEntry(
286 net::NetLog::TYPE_NETWORK_CHANGED,
287 net::NetLog::StringCallback("new_connection_type", &type_as_string));
288 }
289
272 private: 290 private:
273 net::NetLog* net_log_; 291 net::NetLog* net_log_;
274 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver); 292 DISALLOW_COPY_AND_ASSIGN(LoggingNetworkChangeObserver);
275 }; 293 };
276 294
277 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { 295 class SystemURLRequestContextGetter : public net::URLRequestContextGetter {
278 public: 296 public:
279 explicit SystemURLRequestContextGetter(IOThread* io_thread); 297 explicit SystemURLRequestContextGetter(IOThread* io_thread);
280 298
281 // Implementation for net::UrlRequestContextGetter. 299 // Implementation for net::UrlRequestContextGetter.
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 new net::HttpNetworkLayer( 752 new net::HttpNetworkLayer(
735 new net::HttpNetworkSession(system_params))); 753 new net::HttpNetworkSession(system_params)));
736 globals_->system_ftp_transaction_factory.reset( 754 globals_->system_ftp_transaction_factory.reset(
737 new net::FtpNetworkLayer(globals_->host_resolver.get())); 755 new net::FtpNetworkLayer(globals_->host_resolver.get()));
738 globals_->system_request_context.reset( 756 globals_->system_request_context.reset(
739 ConstructSystemRequestContext(globals_, net_log_)); 757 ConstructSystemRequestContext(globals_, net_log_));
740 758
741 sdch_manager_->set_sdch_fetcher( 759 sdch_manager_->set_sdch_fetcher(
742 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 760 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
743 } 761 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698