| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 void NetworkStateHandler::SetTechnologyEnabled( | 125 void NetworkStateHandler::SetTechnologyEnabled( |
| 126 const NetworkTypePattern& type, | 126 const NetworkTypePattern& type, |
| 127 bool enabled, | 127 bool enabled, |
| 128 const network_handler::ErrorCallback& error_callback) { | 128 const network_handler::ErrorCallback& error_callback) { |
| 129 std::string technology = GetTechnologyForType(type); | 129 std::string technology = GetTechnologyForType(type); |
| 130 NET_LOG_USER("SetTechnologyEnabled", | 130 NET_LOG_USER("SetTechnologyEnabled", |
| 131 base::StringPrintf("%s:%d", technology.c_str(), enabled)); | 131 base::StringPrintf("%s:%d", technology.c_str(), enabled)); |
| 132 shill_property_handler_->SetTechnologyEnabled( | 132 shill_property_handler_->SetTechnologyEnabled( |
| 133 technology, enabled, error_callback); | 133 technology, enabled, error_callback); |
| 134 // Signal Technology state changed -> ENABLING | 134 // Signal Device/Technology state changed. |
| 135 NotifyManagerPropertyChanged(); | 135 NotifyDeviceListChanged(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 const DeviceState* NetworkStateHandler::GetDeviceState( | 138 const DeviceState* NetworkStateHandler::GetDeviceState( |
| 139 const std::string& device_path) const { | 139 const std::string& device_path) const { |
| 140 const DeviceState* device = GetModifiableDeviceState(device_path); | 140 const DeviceState* device = GetModifiableDeviceState(device_path); |
| 141 DCHECK(!device || device->update_received()); | 141 DCHECK(!device || device->update_received()); |
| 142 return device; | 142 return device; |
| 143 } | 143 } |
| 144 | 144 |
| 145 const DeviceState* NetworkStateHandler::GetDeviceStateByType( | 145 const DeviceState* NetworkStateHandler::GetDeviceStateByType( |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 DeviceState* device = GetModifiableDeviceState(device_path); | 550 DeviceState* device = GetModifiableDeviceState(device_path); |
| 551 if (!device) | 551 if (!device) |
| 552 return; | 552 return; |
| 553 if (!device->PropertyChanged(key, value)) | 553 if (!device->PropertyChanged(key, value)) |
| 554 return; | 554 return; |
| 555 | 555 |
| 556 std::string detail = device->name() + "." + key; | 556 std::string detail = device->name() + "." + key; |
| 557 detail += " = " + network_event_log::ValueAsString(value); | 557 detail += " = " + network_event_log::ValueAsString(value); |
| 558 NET_LOG_EVENT("DevicePropertyUpdated", detail); | 558 NET_LOG_EVENT("DevicePropertyUpdated", detail); |
| 559 | 559 |
| 560 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 560 NotifyDeviceListChanged(); |
| 561 DeviceListChanged()); | |
| 562 | 561 |
| 563 if (key == flimflam::kScanningProperty && device->scanning() == false) | 562 if (key == flimflam::kScanningProperty && device->scanning() == false) |
| 564 ScanCompleted(device->type()); | 563 ScanCompleted(device->type()); |
| 565 } | 564 } |
| 566 | 565 |
| 567 void NetworkStateHandler::CheckPortalListChanged( | 566 void NetworkStateHandler::CheckPortalListChanged( |
| 568 const std::string& check_portal_list) { | 567 const std::string& check_portal_list) { |
| 569 check_portal_list_ = check_portal_list; | 568 check_portal_list_ = check_portal_list; |
| 570 } | 569 } |
| 571 | 570 |
| 572 void NetworkStateHandler::NotifyManagerPropertyChanged() { | 571 void NetworkStateHandler::TechnologyListChanged() { |
| 573 NET_LOG_DEBUG("NotifyManagerPropertyChanged", ""); | 572 // Eventually we would like to replace Technology state with Device state. |
| 574 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 573 // For now, treat technology state changes as device list changes. |
| 575 NetworkManagerChanged()); | 574 NotifyDeviceListChanged(); |
| 576 } | 575 } |
| 577 | 576 |
| 578 void NetworkStateHandler::ManagedStateListChanged( | 577 void NetworkStateHandler::ManagedStateListChanged( |
| 579 ManagedState::ManagedType type) { | 578 ManagedState::ManagedType type) { |
| 580 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 579 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
| 581 // Notify observers that the list of networks has changed. | 580 // Notify observers that the list of networks has changed. |
| 582 NET_LOG_EVENT("NetworkListChanged", | 581 NET_LOG_EVENT("NetworkListChanged", |
| 583 base::StringPrintf("Size:%" PRIuS, network_list_.size())); | 582 base::StringPrintf("Size:%" PRIuS, network_list_.size())); |
| 584 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 583 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 585 NetworkListChanged()); | 584 NetworkListChanged()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 602 if (!favorite->is_favorite()) | 601 if (!favorite->is_favorite()) |
| 603 continue; | 602 continue; |
| 604 if (favorite->IsPrivate()) | 603 if (favorite->IsPrivate()) |
| 605 ++unshared; | 604 ++unshared; |
| 606 else | 605 else |
| 607 ++shared; | 606 ++shared; |
| 608 } | 607 } |
| 609 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); | 608 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedShared", shared); |
| 610 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); | 609 UMA_HISTOGRAM_COUNTS_100("Networks.RememberedUnshared", unshared); |
| 611 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { | 610 } else if (type == ManagedState::MANAGED_TYPE_DEVICE) { |
| 612 NET_LOG_DEBUG("DeviceListChanged", | 611 NotifyDeviceListChanged(); |
| 613 base::StringPrintf("Size:%" PRIuS, device_list_.size())); | |
| 614 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | |
| 615 DeviceListChanged()); | |
| 616 } else { | 612 } else { |
| 617 NOTREACHED(); | 613 NOTREACHED(); |
| 618 } | 614 } |
| 619 } | 615 } |
| 620 | 616 |
| 621 //------------------------------------------------------------------------------ | 617 //------------------------------------------------------------------------------ |
| 622 // Private methods | 618 // Private methods |
| 623 | 619 |
| 620 void NetworkStateHandler::NotifyDeviceListChanged() { |
| 621 NET_LOG_DEBUG("NotifyDeviceListChanged", |
| 622 base::StringPrintf("Size:%" PRIuS, device_list_.size())); |
| 623 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 624 DeviceListChanged()); |
| 625 } |
| 626 |
| 624 DeviceState* NetworkStateHandler::GetModifiableDeviceState( | 627 DeviceState* NetworkStateHandler::GetModifiableDeviceState( |
| 625 const std::string& device_path) const { | 628 const std::string& device_path) const { |
| 626 ManagedState* managed = GetModifiableManagedState(&device_list_, device_path); | 629 ManagedState* managed = GetModifiableManagedState(&device_list_, device_path); |
| 627 if (!managed) | 630 if (!managed) |
| 628 return NULL; | 631 return NULL; |
| 629 return managed->AsDeviceState(); | 632 return managed->AsDeviceState(); |
| 630 } | 633 } |
| 631 | 634 |
| 632 NetworkState* NetworkStateHandler::GetModifiableNetworkState( | 635 NetworkState* NetworkStateHandler::GetModifiableNetworkState( |
| 633 const std::string& service_path) const { | 636 const std::string& service_path) const { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 736 } |
| 734 | 737 |
| 735 if (type.MatchesType(flimflam::kTypeCellular)) | 738 if (type.MatchesType(flimflam::kTypeCellular)) |
| 736 return flimflam::kTypeCellular; | 739 return flimflam::kTypeCellular; |
| 737 | 740 |
| 738 NOTREACHED(); | 741 NOTREACHED(); |
| 739 return std::string(); | 742 return std::string(); |
| 740 } | 743 } |
| 741 | 744 |
| 742 } // namespace chromeos | 745 } // namespace chromeos |
| OLD | NEW |