| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo) |
| 6 |
| 5 #ifndef SRC_DATA_PLAN_H_ | 7 #ifndef SRC_DATA_PLAN_H_ |
| 6 #define SRC_DATA_PLAN_H_ | 8 #define SRC_DATA_PLAN_H_ |
| 7 | 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <string> | 11 #include <string> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include <base/basictypes.h> // NOLINT | 14 #include <base/basictypes.h> // NOLINT |
| 13 #include <base/time.h> // NOLINT | 15 #include <base/time.h> // NOLINT |
| 14 #include <dbus-c++/dbus.h> // NOLINT | 16 #include <dbus-c++/dbus.h> // NOLINT |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // get plan used bytes | 73 // get plan used bytes |
| 72 virtual Bytes GetDataBytesUsed() const; | 74 virtual Bytes GetDataBytesUsed() const; |
| 73 | 75 |
| 74 // get local used bytes | 76 // get local used bytes |
| 75 virtual Bytes GetLocalBytesUsed() const; | 77 virtual Bytes GetLocalBytesUsed() const; |
| 76 | 78 |
| 77 // set local used bytes | 79 // set local used bytes |
| 78 // must be >= 0 | 80 // must be >= 0 |
| 79 virtual void SetLocalBytesUsed(Bytes local_bytes_used); | 81 virtual void SetLocalBytesUsed(Bytes local_bytes_used); |
| 80 | 82 |
| 83 // get total used bytes |
| 84 virtual Bytes GetTotalBytesUsed() const; |
| 85 |
| 81 // is this an active plan? | 86 // is this an active plan? |
| 82 // we define active to mean that the plan is current and not exhausted | 87 // we define active to mean that the plan is current and not exhausted |
| 83 virtual bool IsActive() const; | 88 virtual bool IsActive() const; |
| 84 | 89 |
| 85 // return a{sv} representation for D-Bus | 90 // return a{sv} representation for D-Bus |
| 86 virtual DBusDataPlan ToDBusFormat() const; | 91 virtual DBusDataPlan ToDBusFormat() const; |
| 87 | 92 |
| 88 // construct DataPlan from DictionaryValue | 93 // construct DataPlan from DictionaryValue |
| 89 static DataPlan* FromDictionaryValue(const DictionaryValue *value, | 94 static DataPlan* FromDictionaryValue(const DictionaryValue *value, |
| 90 const Policy *policy); | 95 const Policy *policy); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const Bytes data_bytes_max_; | 127 const Bytes data_bytes_max_; |
| 123 | 128 |
| 124 // bytes consumed so far during plan period | 129 // bytes consumed so far during plan period |
| 125 // this measurement comes from the carrier API | 130 // this measurement comes from the carrier API |
| 126 Bytes data_bytes_used_; | 131 Bytes data_bytes_used_; |
| 127 | 132 |
| 128 // local measurement of bytes used since we received |data_bytes_used_| | 133 // local measurement of bytes used since we received |data_bytes_used_| |
| 129 // baseline from the carrier API | 134 // baseline from the carrier API |
| 130 Bytes local_bytes_used_; | 135 Bytes local_bytes_used_; |
| 131 | 136 |
| 137 // our best estimate of total bytes used for this plan |
| 138 // carrier baseline (|data_bytes_used_|) + |
| 139 // locally measured traffic (|local_bytes_used_|) |
| 140 Bytes total_bytes_used_; |
| 141 |
| 132 // convert plan type enum value to string formatted for libcros | 142 // convert plan type enum value to string formatted for libcros |
| 133 const char* TypeToLibcrosString(Type type) const; | 143 const char* TypeToLibcrosString(Type type) const; |
| 134 | 144 |
| 135 // convert string formatted for Cros Usage API to plan type enum value | 145 // convert string formatted for Cros Usage API to plan type enum value |
| 136 // returns true on success and false on failure | 146 // returns true on success and false on failure |
| 137 // |type_out| must not be NULL and is set on a successful return | 147 // |type_out| must not be NULL and is set on a successful return |
| 138 static bool CrosUsageStringToType(const std::string& type_string, | 148 static bool CrosUsageStringToType(const std::string& type_string, |
| 139 Type *type_out); | 149 Type *type_out); |
| 140 | 150 |
| 141 // converts the value associated with |key| in |dict| to an int64 | 151 // converts the value associated with |key| in |dict| to an int64 |
| 142 // returns true on success and false on failure | 152 // returns true on success and false on failure |
| 143 // |out_value| must not be NULL and is set on a successful return | 153 // |out_value| must not be NULL and is set on a successful return |
| 144 static bool GetInt64FromDictionary(const DictionaryValue& dict, | 154 static bool GetInt64FromDictionary(const DictionaryValue& dict, |
| 145 const std::string& key, | 155 const std::string& key, |
| 146 int64* out_value); | 156 int64* out_value); |
| 147 | 157 |
| 148 DISALLOW_COPY_AND_ASSIGN(DataPlan); | 158 DISALLOW_COPY_AND_ASSIGN(DataPlan); |
| 149 }; | 159 }; |
| 150 | 160 |
| 151 } // namespace cashew | 161 } // namespace cashew |
| 152 | 162 |
| 153 #endif // SRC_DATA_PLAN_H_ | 163 #endif // SRC_DATA_PLAN_H_ |
| OLD | NEW |