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 "chrome/browser/chromeos/cros/network_library_impl_cros.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" |
6 | 6 |
7 #include <dbus/dbus-glib.h> | 7 #include <dbus/dbus-glib.h> |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_writer.h" // for debug output only. | 9 #include "base/json/json_writer.h" // for debug output only. |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void NetworkLibraryImplCros::Init() { | 51 void NetworkLibraryImplCros::Init() { |
52 CHECK(CrosLibrary::Get()->libcros_loaded()) | 52 CHECK(CrosLibrary::Get()->libcros_loaded()) |
53 << "libcros must be loaded before NetworkLibraryImplCros::Init()"; | 53 << "libcros must be loaded before NetworkLibraryImplCros::Init()"; |
54 // First, get the currently available networks. This data is cached | 54 // First, get the currently available networks. This data is cached |
55 // on the connman side, so the call should be quick. | 55 // on the connman side, so the call should be quick. |
56 VLOG(1) << "Requesting initial network manager info from libcros."; | 56 VLOG(1) << "Requesting initial network manager info from libcros."; |
57 CrosRequestNetworkManagerProperties(base::Bind(&NetworkManagerUpdate, this)); | 57 CrosRequestNetworkManagerProperties(base::Bind(&NetworkManagerUpdate, this)); |
58 network_manager_watcher_.reset(CrosMonitorNetworkManagerProperties( | 58 network_manager_watcher_.reset(CrosMonitorNetworkManagerProperties( |
59 base::Bind(&NetworkManagerStatusChangedHandler, this))); | 59 base::Bind(&NetworkManagerStatusChangedHandler, this))); |
60 data_plan_watcher_.reset( | 60 data_plan_watcher_.reset( |
61 CrosMonitorCellularDataPlan(&DataPlanUpdateHandler, this)); | 61 CrosMonitorCellularDataPlan(base::Bind(&DataPlanUpdateHandler, this))); |
62 // Always have at least one device obsever so that device updates are | 62 // Always have at least one device obsever so that device updates are |
63 // always received. | 63 // always received. |
64 network_device_observer_.reset(new NetworkLibraryDeviceObserver()); | 64 network_device_observer_.reset(new NetworkLibraryDeviceObserver()); |
65 } | 65 } |
66 | 66 |
67 bool NetworkLibraryImplCros::IsCros() const { | 67 bool NetworkLibraryImplCros::IsCros() const { |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 ////////////////////////////////////////////////////////////////////////////// | 71 ////////////////////////////////////////////////////////////////////////////// |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 NetworkManagerStatusChanged(key, value); | 767 NetworkManagerStatusChanged(key, value); |
768 } | 768 } |
769 // If there is no Profiles entry, request remembered networks here. | 769 // If there is no Profiles entry, request remembered networks here. |
770 if (!dict.HasKey(flimflam::kProfilesProperty)) | 770 if (!dict.HasKey(flimflam::kProfilesProperty)) |
771 RequestRememberedNetworksUpdate(); | 771 RequestRememberedNetworksUpdate(); |
772 } | 772 } |
773 | 773 |
774 // static | 774 // static |
775 void NetworkLibraryImplCros::DataPlanUpdateHandler( | 775 void NetworkLibraryImplCros::DataPlanUpdateHandler( |
776 void* object, | 776 void* object, |
777 const char* modem_service_path, | 777 const std::string& modem_service_path, |
778 const chromeos::CellularDataPlanList* data_plan_list) { | 778 CellularDataPlanVector* data_plan_vector) { |
779 DCHECK(CrosLibrary::Get()->libcros_loaded()); | |
780 NetworkLibraryImplCros* networklib = | 779 NetworkLibraryImplCros* networklib = |
781 static_cast<NetworkLibraryImplCros*>(object); | 780 static_cast<NetworkLibraryImplCros*>(object); |
782 DCHECK(networklib); | 781 networklib->UpdateCellularDataPlan(modem_service_path, data_plan_vector); |
783 if (modem_service_path && data_plan_list) { | |
784 // Copy contents of |data_plan_list| from libcros to |data_plan_vector|. | |
785 CellularDataPlanVector* data_plan_vector = new CellularDataPlanVector; | |
786 for (size_t i = 0; i < data_plan_list->plans_size; ++i) { | |
787 const CellularDataPlanInfo* info(data_plan_list->GetCellularDataPlan(i)); | |
788 CellularDataPlan* plan = new CellularDataPlan(*info); | |
789 data_plan_vector->push_back(plan); | |
790 VLOG(2) << " Plan: " << plan->GetPlanDesciption() | |
791 << " : " << plan->GetDataRemainingDesciption(); | |
792 } | |
793 // |data_plan_vector| will become owned by networklib. | |
794 networklib->UpdateCellularDataPlan(std::string(modem_service_path), | |
795 data_plan_vector); | |
796 } | |
797 } | 782 } |
798 | 783 |
799 //////////////////////////////////////////////////////////////////////////// | 784 //////////////////////////////////////////////////////////////////////////// |
800 | 785 |
801 void NetworkLibraryImplCros::UpdateTechnologies( | 786 void NetworkLibraryImplCros::UpdateTechnologies( |
802 const ListValue* technologies, int* bitfieldp) { | 787 const ListValue* technologies, int* bitfieldp) { |
803 DCHECK(bitfieldp); | 788 DCHECK(bitfieldp); |
804 if (!technologies) | 789 if (!technologies) |
805 return; | 790 return; |
806 int bitfield = 0; | 791 int bitfield = 0; |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 // Switch back to signed settings value. | 1240 // Switch back to signed settings value. |
1256 SetCellularDataRoamingAllowed(settings_value); | 1241 SetCellularDataRoamingAllowed(settings_value); |
1257 } | 1242 } |
1258 } | 1243 } |
1259 } | 1244 } |
1260 NotifyNetworkManagerChanged(false); // Not forced. | 1245 NotifyNetworkManagerChanged(false); // Not forced. |
1261 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); | 1246 AddNetworkDeviceObserver(device_path, network_device_observer_.get()); |
1262 } | 1247 } |
1263 | 1248 |
1264 } // namespace chromeos | 1249 } // namespace chromeos |
OLD | NEW |