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

Unified Diff: src/data_plan.h

Issue 5180003: cashew: add local byte counters (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years, 1 month 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 | « src/byte_counter.cc ('k') | src/data_plan.cc » ('j') | src/device.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/data_plan.h
diff --git a/src/data_plan.h b/src/data_plan.h
index 6f655791225b725c31015fe6c52204de9f8e84e7..f58d6f69b0f16a8873de491c61d6d569805e4b86 100644
--- a/src/data_plan.h
+++ b/src/data_plan.h
@@ -25,6 +25,7 @@ class Policy;
typedef int64 Bytes;
// List of DataPlan objects
+// TODO(vlaviano): consider promoting this from a typedef to a class
typedef std::vector<DataPlan*> DataPlanList;
// DataPlan object formatted for D-Bus (using DBus::Variants to wrap fields)
@@ -43,6 +44,7 @@ class DataPlan {
kTypeMeteredPaid,
} Type;
+ // |data_bytes_max| must be set to 0 for unlimited plans
DataPlan(const std::string& name, DataPlan::Type type,
base::Time update_time, base::Time start_time,
base::Time end_time, Bytes data_bytes_max, Bytes data_bytes_used);
@@ -69,6 +71,17 @@ class DataPlan {
// get plan used bytes
virtual Bytes GetDataBytesUsed() const;
+ // get local used bytes
+ virtual Bytes GetLocalBytesUsed() const;
+
+ // set local used bytes
+ // must be >= 0
+ virtual void SetLocalBytesUsed(Bytes local_bytes_used);
+
+ // is this an active plan?
+ // we define active to mean that the plan is current and not exhausted
+ virtual bool IsActive() const;
+
// return a{sv} representation for D-Bus
virtual DBusDataPlan ToDBusFormat() const;
@@ -83,6 +96,10 @@ class DataPlan {
base::Time *time_out,
bool zoneless_strings_are_local);
+ // returns first active plan in |data_plans|
+ // returns NULL if list is empty or contains no active plans
+ static DataPlan* GetActivePlan(const DataPlanList& data_plans);
+
private:
// human-readable plan name
const std::string name_;
@@ -91,6 +108,7 @@ class DataPlan {
const Type type_;
// last update time (i.e., how fresh is plan data)
+ // this refers to carrier API data, not local measurements
base::Time update_time_;
// plan start time
@@ -104,8 +122,13 @@ class DataPlan {
const Bytes data_bytes_max_;
// bytes consumed so far during plan period
+ // this measurement comes from the carrier API
Bytes data_bytes_used_;
+ // local measurement of bytes used since we received |data_bytes_used_|
+ // baseline from the carrier API
+ Bytes local_bytes_used_;
+
// convert plan type enum value to string formatted for libcros
const char* TypeToLibcrosString(Type type) const;
« no previous file with comments | « src/byte_counter.cc ('k') | src/data_plan.cc » ('j') | src/device.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698