Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Unified Diff: chrome/browser/chromeos/cros/cros_network_functions.cc

Issue 10207006: Move CellularDataPlanInfo to CellularDataPlan conversion code to cros_network_functions.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/cros/cros_network_functions.cc
diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc
index 555e5a07f86c96adeca1b15aac800d95b1e61bd9..503221be06324c4020dfbee7bf83367003150f08 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,
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.h ('k') | chrome/browser/chromeos/cros/cros_network_functions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698