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