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

Unified Diff: src/data_plan.cc

Issue 4114002: cashew: data plans: used bytes should be optional for unlimited plans (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: jglasgow review fixes Created 10 years, 2 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
« no previous file with comments | « no previous file | src/data_plan_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/data_plan.cc
diff --git a/src/data_plan.cc b/src/data_plan.cc
index 1a6b7f52b9f0b1fc323c9759452097dc3ef55ad3..6b74e4631deff14423311296ea692dfade1a05c8 100644
--- a/src/data_plan.cc
+++ b/src/data_plan.cc
@@ -97,10 +97,13 @@ DBusDataPlan DataPlan::ToDBusFormat() const {
plan[kCellularDataPlanEndTime].writer().append_int64(
end_time_.ToInternalValue());
// omit max bytes field for unlimited plans
- // can libcros/Chrome deal? if not, can set this to int64 max.
if (type_ != kTypeUnlimited) {
plan[kCellularDataPlanDataBytesMax].writer().append_int64(data_bytes_max_);
}
+ // always send used bytes field, even if we had to assume a value of 0
+ // because this is an unlimited plan and the property was absent in the
+ // usage API replies that we received
+ // TODO(vlaviano): we'll be able to do better when we have local counters
plan[kCellularDataPlanDataBytesUsed].writer().append_int64(data_bytes_used_);
return plan;
}
@@ -162,8 +165,14 @@ DataPlan* DataPlan::FromDictionaryValue(const DictionaryValue *value,
int used_bytes = 0;
if (!value->GetInteger(kCrosUsageDataPlanUsedBytesProperty, &used_bytes)) {
- LOG(WARNING) << "FromDictionaryValue: no used bytes property";
- return NULL;
+ // used bytes is required for metered plans, optional for unlimited plans
+ if (plan_type != kTypeUnlimited) {
+ LOG(WARNING) << "FromDictionaryValue: no used bytes property";
+ return NULL;
+ } else {
+ DLOG(INFO)
+ << "FromDictionaryValue: no used bytes property (using default of 0)";
+ }
}
if (used_bytes < 0) {
LOG(WARNING) << "FromDictionaryValue: used bytes is negative";
« no previous file with comments | « no previous file | src/data_plan_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698