diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 15:40:41 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-25 15:40:41 +0000 |
commit | 6bfa994051b61f7b9b56b9de5e79af3563ea2202 (patch) | |
tree | a7f47d436efefc20eb225f2d544bb62bb6657525 /chrome/browser/chromeos/cros/cros_network_functions.cc | |
parent | 5d9a4b9c71a5a8916805274acf3e8ecea2a4b6ac (diff) | |
download | chromium_src-6bfa994051b61f7b9b56b9de5e79af3563ea2202.zip chromium_src-6bfa994051b61f7b9b56b9de5e79af3563ea2202.tar.gz chromium_src-6bfa994051b61f7b9b56b9de5e79af3563ea2202.tar.bz2 |
Move CellularDataPlanInfo to CellularDataPlan conversion code to cros_network_functions.cc
Move CellularDataPlan from network_library.* to its own files.
Move CellularDataInfo to CellularData conversion code to cros_network_functions.cc
BUG=chromium-os:16557
TEST=unit_tests --gtest_filter="CrosNetworkFunctionsLibcrosTest.CrosMonitorCellularDataPlan"
Review URL: https://chromiumcodereview.appspot.com/10207006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/cros/cros_network_functions.cc')
-rw-r--r-- | chrome/browser/chromeos/cros/cros_network_functions.cc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc index 555e5a0..503221b 100644 --- a/chrome/browser/chromeos/cros/cros_network_functions.cc +++ b/chrome/browser/chromeos/cros/cros_network_functions.cc @@ -138,13 +138,37 @@ class NetworkDevicePropertiesWatcher : public CrosNetworkWatcher { // Class to watch data plan update with Libcros. class CrosDataPlanUpdateWatcher : public CrosNetworkWatcher { public: - CrosDataPlanUpdateWatcher(MonitorDataPlanCallback callback, void* object) - : monitor_(chromeos::MonitorCellularDataPlan(callback, object)) {} + explicit CrosDataPlanUpdateWatcher( + const DataPlanUpdateWatcherCallback& callback) + : callback_(callback), + monitor_(chromeos::MonitorCellularDataPlan(&OnDataPlanUpdate, this)) {} virtual ~CrosDataPlanUpdateWatcher() { chromeos::DisconnectDataPlanUpdateMonitor(monitor_); } private: + static void OnDataPlanUpdate(void* object, + const char* modem_service_path, + const CellularDataPlanList* data_plan_list) { + CrosDataPlanUpdateWatcher* watcher = + static_cast<CrosDataPlanUpdateWatcher*>(object); + if (modem_service_path && data_plan_list) { + // Copy contents of |data_plan_list| from libcros to |data_plan_vector|. + CellularDataPlanVector* data_plan_vector = new CellularDataPlanVector; + for (size_t i = 0; i < data_plan_list->plans_size; ++i) { + const CellularDataPlanInfo* info = + data_plan_list->GetCellularDataPlan(i); + CellularDataPlan* plan = new CellularDataPlan(*info); + data_plan_vector->push_back(plan); + VLOG(2) << " Plan: " << plan->GetPlanDesciption() + << " : " << plan->GetDataRemainingDesciption(); + } + // |data_plan_vector| will be owned by callback. + watcher->callback_.Run(modem_service_path, data_plan_vector); + } + } + + DataPlanUpdateWatcherCallback callback_; DataPlanUpdateMonitor monitor_; }; @@ -396,8 +420,8 @@ CrosNetworkWatcher* CrosMonitorNetworkDeviceProperties( } CrosNetworkWatcher* CrosMonitorCellularDataPlan( - MonitorDataPlanCallback callback, void* object) { - return new CrosDataPlanUpdateWatcher(callback, object); + const DataPlanUpdateWatcherCallback& callback) { + return new CrosDataPlanUpdateWatcher(callback); } CrosNetworkWatcher* CrosMonitorSMS(const std::string& modem_device_path, |