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

Side by Side Diff: net/base/logging_network_change_observer.cc

Issue 1971853002: Move IOThread::LoggingNetworkChangeObserver to net/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 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/base/logging_network_change_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/base/logging_network_change_observer.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "net/log/net_log.h"
11
12 namespace net {
13
14 LoggingNetworkChangeObserver::LoggingNetworkChangeObserver(net::NetLog* net_log)
15 : net_log_(net_log) {
16 net::NetworkChangeNotifier::AddIPAddressObserver(this);
17 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
18 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
19 }
20
21 LoggingNetworkChangeObserver::~LoggingNetworkChangeObserver() {
22 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
23 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
24 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
25 }
26
27 void LoggingNetworkChangeObserver::OnIPAddressChanged() {
28 VLOG(1) << "Observed a change to the network IP addresses";
29
30 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
31 }
32
33 void LoggingNetworkChangeObserver::OnConnectionTypeChanged(
34 net::NetworkChangeNotifier::ConnectionType type) {
35 std::string type_as_string =
36 net::NetworkChangeNotifier::ConnectionTypeToString(type);
37
38 VLOG(1) << "Observed a change to network connectivity state "
39 << type_as_string;
40
41 net_log_->AddGlobalEntry(
42 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED,
43 net::NetLog::StringCallback("new_connection_type", &type_as_string));
44 }
45
46 void LoggingNetworkChangeObserver::OnNetworkChanged(
47 net::NetworkChangeNotifier::ConnectionType type) {
48 std::string type_as_string =
49 net::NetworkChangeNotifier::ConnectionTypeToString(type);
50
51 VLOG(1) << "Observed a network change to state " << type_as_string;
52
53 net_log_->AddGlobalEntry(
54 net::NetLog::TYPE_NETWORK_CHANGED,
55 net::NetLog::StringCallback("new_connection_type", &type_as_string));
56 }
57
58 } // namespace net
OLDNEW
« no previous file with comments | « net/base/logging_network_change_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698