Chromium Code Reviews| 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/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 155 |
| 156 void NetworkStateHandler::SetTechnologyEnabled( | 156 void NetworkStateHandler::SetTechnologyEnabled( |
| 157 const std::string& type, | 157 const std::string& type, |
| 158 bool enabled, | 158 bool enabled, |
| 159 const network_handler::ErrorCallback& error_callback) { | 159 const network_handler::ErrorCallback& error_callback) { |
| 160 std::string technology = GetTechnologyForType(type); | 160 std::string technology = GetTechnologyForType(type); |
| 161 NET_LOG_USER("SetTechnologyEnabled", | 161 NET_LOG_USER("SetTechnologyEnabled", |
| 162 base::StringPrintf("%s:%d", technology.c_str(), enabled)); | 162 base::StringPrintf("%s:%d", technology.c_str(), enabled)); |
| 163 shill_property_handler_->SetTechnologyEnabled( | 163 shill_property_handler_->SetTechnologyEnabled( |
| 164 technology, enabled, error_callback); | 164 technology, enabled, error_callback); |
| 165 // Signal Technology state changed -> ENABLING | 165 // Signal Device/Technology state changed. |
| 166 NotifyManagerPropertyChanged(); | 166 NotifyDeviceListChanged(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 const DeviceState* NetworkStateHandler::GetDeviceState( | 169 const DeviceState* NetworkStateHandler::GetDeviceState( |
| 170 const std::string& device_path) const { | 170 const std::string& device_path) const { |
| 171 const DeviceState* device = GetModifiableDeviceState(device_path); | 171 const DeviceState* device = GetModifiableDeviceState(device_path); |
| 172 DCHECK(!device || device->update_received()); | 172 DCHECK(!device || device->update_received()); |
| 173 return device; | 173 return device; |
| 174 } | 174 } |
| 175 | 175 |
| 176 const DeviceState* NetworkStateHandler::GetDeviceStateByType( | 176 const DeviceState* NetworkStateHandler::GetDeviceStateByType( |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 579 DeviceState* device = GetModifiableDeviceState(device_path); | 579 DeviceState* device = GetModifiableDeviceState(device_path); |
| 580 if (!device) | 580 if (!device) |
| 581 return; | 581 return; |
| 582 if (!device->PropertyChanged(key, value)) | 582 if (!device->PropertyChanged(key, value)) |
| 583 return; | 583 return; |
| 584 | 584 |
| 585 std::string detail = device->name() + "." + key; | 585 std::string detail = device->name() + "." + key; |
| 586 detail += " = " + network_event_log::ValueAsString(value); | 586 detail += " = " + network_event_log::ValueAsString(value); |
| 587 NET_LOG_EVENT("DevicePropertyUpdated", detail); | 587 NET_LOG_EVENT("DevicePropertyUpdated", detail); |
| 588 | 588 |
| 589 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 589 NotifyDeviceListChanged(); |
| 590 DeviceListChanged()); | |
| 591 | 590 |
| 592 if (key == flimflam::kScanningProperty && device->scanning() == false) | 591 if (key == flimflam::kScanningProperty && device->scanning() == false) |
| 593 ScanCompleted(device->type()); | 592 ScanCompleted(device->type()); |
| 594 } | 593 } |
| 595 | 594 |
| 596 void NetworkStateHandler::CheckPortalListChanged( | 595 void NetworkStateHandler::CheckPortalListChanged( |
| 597 const std::string& check_portal_list) { | 596 const std::string& check_portal_list) { |
| 598 check_portal_list_ = check_portal_list; | 597 check_portal_list_ = check_portal_list; |
| 599 } | 598 } |
| 600 | 599 |
| 601 void NetworkStateHandler::NotifyManagerPropertyChanged() { | 600 void NetworkStateHandler::TechnologyListChanged() { |
| 602 NET_LOG_DEBUG("NotifyManagerPropertyChanged", ""); | 601 // Eventually we would like to replace Technology state with Device state. |
| 603 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 602 // For now, treat technology state changes as device list changes. |
| 604 NetworkManagerChanged()); | 603 NotifyDeviceListChanged(); |
| 605 } | 604 } |
| 606 | 605 |
| 607 void NetworkStateHandler::ManagedStateListChanged( | 606 void NetworkStateHandler::ManagedStateListChanged( |
| 608 ManagedState::ManagedType type) { | 607 ManagedState::ManagedType type) { |
| 609 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 608 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
| 610 // Notify observers that the list of networks has changed. | 609 // Notify observers that the list of networks has changed. |
| 611 NET_LOG_EVENT("NetworkListChanged", | 610 NET_LOG_EVENT("NetworkListChanged", |
| 612 base::StringPrintf("Size:%" PRIuS, network_list_.size())); | 611 base::StringPrintf("Size:%" PRIuS, network_list_.size())); |
| 613 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 612 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 614 NetworkListChanged()); | 613 NetworkListChanged()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 631 if (!favorite->is_favorite()) | 630 if (!favorite->is_favorite()) |
| 632 continue; | 631 continue; |
| 633 if (favorite->IsPrivate()) | 632 if (favorite->IsPrivate()) |
| 634 ++unshared; | 633 ++unshared; |
| 635 else | 634 else |
| 636 ++shared; | 635 ++shared; |
| 637 } | 636 } |
| 638 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); | 637 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); |
| 639 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); | 638 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); |
| 640 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 639 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { |
| 641 NET_LOG_DEBUG("DeviceListChanged", | 640 NotifyDeviceListChanged(); |
| 642 base::StringPrintf("Size:%" PRIuS, device_list_.size())); | |
| 643 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | |
| 644 DeviceListChanged()); | |
| 645 } else { | 641 } else { |
| 646 NOTREACHED(); | 642 NOTREACHED(); |
| 647 } | 643 } |
| 648 } | 644 } |
| 649 | 645 |
| 650 //------------------------------------------------------------------------------ | 646 //------------------------------------------------------------------------------ |
| 651 // Private methods | 647 // Private methods |
| 652 | 648 |
| 649 void NetworkStateHandler::NotifyDeviceListChanged() { | |
| 650 NET_LOG_DEBUG("NotifyDeviceListChanged", | |
|
pneubeck (no reviews)
2013/09/11 20:13:35
nit: maybe log the current technology state as wel
stevenjb
2013/09/11 21:23:46
Right now we have 4 sets of technology states (ava
| |
| 651 base::StringPrintf("Size:%" PRIuS, device_list_.size())); | |
| 652 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | |
| 653 DeviceListChanged()); | |
| 654 } | |
| 655 | |
| 653 DeviceState* NetworkStateHandler::GetModifiableDeviceState( | 656 DeviceState* NetworkStateHandler::GetModifiableDeviceState( |
| 654 const std::string& device_path) const { | 657 const std::string& device_path) const { |
| 655 ManagedState* managed = GetModifiableManagedState(&device_list_, device_path); | 658 ManagedState* managed = GetModifiableManagedState(&device_list_, device_path); |
| 656 if (!managed) | 659 if (!managed) |
| 657 return NULL; | 660 return NULL; |
| 658 return managed->AsDeviceState(); | 661 return managed->AsDeviceState(); |
| 659 } | 662 } |
| 660 | 663 |
| 661 NetworkState* NetworkStateHandler::GetModifiableNetworkState( | 664 NetworkState* NetworkStateHandler::GetModifiableNetworkState( |
| 662 const std::string& service_path) const { | 665 const std::string& service_path) const { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 } | 757 } |
| 755 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || | 758 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || |
| 756 type == kMatchTypeWireless) { | 759 type == kMatchTypeWireless) { |
| 757 NOTREACHED(); | 760 NOTREACHED(); |
| 758 return flimflam::kTypeWifi; | 761 return flimflam::kTypeWifi; |
| 759 } | 762 } |
| 760 return type; | 763 return type; |
| 761 } | 764 } |
| 762 | 765 |
| 763 } // namespace chromeos | 766 } // namespace chromeos |
| OLD | NEW |