| 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 "chromeos/network/network_state_handler.h" | 5 #include "chromeos/network/network_state_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" |
| 8 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 9 #include "base/guid.h" | 10 #include "base/guid.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
| 11 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chromeos/chromeos_switches.h" |
| 19 #include "chromeos/network/device_state.h" | 21 #include "chromeos/network/device_state.h" |
| 20 #include "chromeos/network/network_event_log.h" | 22 #include "chromeos/network/network_event_log.h" |
| 21 #include "chromeos/network/network_state.h" | 23 #include "chromeos/network/network_state.h" |
| 22 #include "chromeos/network/network_state_handler_observer.h" | 24 #include "chromeos/network/network_state_handler_observer.h" |
| 23 #include "third_party/cros_system_api/dbus/service_constants.h" | 25 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 24 | 26 |
| 25 namespace chromeos { | 27 namespace chromeos { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 shill_property_handler_->Init(); | 82 shill_property_handler_->Init(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 // static | 85 // static |
| 84 NetworkStateHandler* NetworkStateHandler::InitializeForTest() { | 86 NetworkStateHandler* NetworkStateHandler::InitializeForTest() { |
| 85 NetworkStateHandler* handler = new NetworkStateHandler(); | 87 NetworkStateHandler* handler = new NetworkStateHandler(); |
| 86 handler->InitShillPropertyHandler(); | 88 handler->InitShillPropertyHandler(); |
| 87 return handler; | 89 return handler; |
| 88 } | 90 } |
| 89 | 91 |
| 92 void NetworkStateHandler::DebugNotifyNetworkPropertiesUpdated() { |
| 93 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 94 chromeos::switches::kEnableDataSaverPrompt)) |
| 95 return; |
| 96 |
| 97 NetworkState network(kHotkeyDebugDataSaver); |
| 98 base::StringValue val(shill::kTypeCellular); |
| 99 network.PropertyChanged("Type", val); |
| 100 NotifyNetworkPropertiesUpdated(&network); |
| 101 } |
| 102 |
| 90 void NetworkStateHandler::AddObserver( | 103 void NetworkStateHandler::AddObserver( |
| 91 NetworkStateHandlerObserver* observer, | 104 NetworkStateHandlerObserver* observer, |
| 92 const tracked_objects::Location& from_here) { | 105 const tracked_objects::Location& from_here) { |
| 93 observers_.AddObserver(observer); | 106 observers_.AddObserver(observer); |
| 94 device_event_log::AddEntry(from_here.file_name(), from_here.line_number(), | 107 device_event_log::AddEntry(from_here.file_name(), from_here.line_number(), |
| 95 device_event_log::LOG_TYPE_NETWORK, | 108 device_event_log::LOG_TYPE_NETWORK, |
| 96 device_event_log::LOG_LEVEL_DEBUG, | 109 device_event_log::LOG_LEVEL_DEBUG, |
| 97 "NetworkStateHandler::AddObserver"); | 110 "NetworkStateHandler::AddObserver"); |
| 98 } | 111 } |
| 99 | 112 |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 if (type.MatchesType(shill::kTypeBluetooth)) | 979 if (type.MatchesType(shill::kTypeBluetooth)) |
| 967 technologies.push_back(new std::string(shill::kTypeBluetooth)); | 980 technologies.push_back(new std::string(shill::kTypeBluetooth)); |
| 968 if (type.MatchesType(shill::kTypeVPN)) | 981 if (type.MatchesType(shill::kTypeVPN)) |
| 969 technologies.push_back(new std::string(shill::kTypeVPN)); | 982 technologies.push_back(new std::string(shill::kTypeVPN)); |
| 970 | 983 |
| 971 CHECK_GT(technologies.size(), 0ul); | 984 CHECK_GT(technologies.size(), 0ul); |
| 972 return technologies.Pass(); | 985 return technologies.Pass(); |
| 973 } | 986 } |
| 974 | 987 |
| 975 } // namespace chromeos | 988 } // namespace chromeos |
| OLD | NEW |