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

Side by Side Diff: src/data_plan.h

Issue 3528016: Cashew: implement backend usage API (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: Fix code review nits and remove hardcoded usage URLs 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/cashew_server.cc ('k') | src/data_plan.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include <base/basictypes.h> // NOLINT 12 #include <base/basictypes.h> // NOLINT
13 #include <base/time.h> // NOLINT 13 #include <base/time.h> // NOLINT
14 #include <base/values.h> // NOLINT
14 #include <dbus-c++/dbus.h> // NOLINT 15 #include <dbus-c++/dbus.h> // NOLINT
15 16
16 namespace cashew { 17 namespace cashew {
17 18
18 class DataPlan; 19 class DataPlan;
19 20
20 // byte count 21 // byte count
21 // TODO(vlaviano): this should be a uint64, but libcros/Chrome expects this 22 // TODO(vlaviano): this should be a uint64, but libcros/Chrome expects this
22 typedef int64 Bytes; 23 typedef int64 Bytes;
23 24
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 // get plan max bytes 64 // get plan max bytes
64 virtual Bytes GetDataBytesMax() const; 65 virtual Bytes GetDataBytesMax() const;
65 66
66 // get plan used bytes 67 // get plan used bytes
67 virtual Bytes GetDataBytesUsed() const; 68 virtual Bytes GetDataBytesUsed() const;
68 69
69 // return a{sv} representation for D-Bus 70 // return a{sv} representation for D-Bus
70 virtual DBusDataPlan ToDBusFormat() const; 71 virtual DBusDataPlan ToDBusFormat() const;
71 72
73 // construct DataPlan from DictionaryValue
74 static DataPlan* FromDictionaryValue(const DictionaryValue *value);
75
76 // convert ISO8601 time value in UTC to base::Time
77 // returns true on success and false on failure
78 // |time_out| must not be NULL and is set on a successful return
79 static bool TimeFromISO8601UTC(const std::string& time_8601_utc,
80 base::Time *time_out);
81
72 private: 82 private:
73 // human-readable plan name 83 // human-readable plan name
74 const std::string name_; 84 const std::string name_;
75 85
76 // plan type 86 // plan type
77 const Type type_; 87 const Type type_;
78 88
79 // last update time (i.e., how fresh is plan data) 89 // last update time (i.e., how fresh is plan data)
80 base::Time update_time_; 90 base::Time update_time_;
81 91
82 // plan start time 92 // plan start time
83 const base::Time start_time_; 93 const base::Time start_time_;
84 94
85 // plan end time 95 // plan end time
86 const base::Time end_time_; 96 const base::Time end_time_;
87 97
88 // max bytes available during plan period 98 // max bytes available during plan period
89 // irrelevant for plans of type kTypeUnlimited 99 // irrelevant for plans of type kTypeUnlimited
90 const Bytes data_bytes_max_; 100 const Bytes data_bytes_max_;
91 101
92 // bytes consumed so far during plan period 102 // bytes consumed so far during plan period
93 Bytes data_bytes_used_; 103 Bytes data_bytes_used_;
94 104
95 // convert plan type enum value to string 105 // convert plan type enum value to string formatted for libcros
96 const char* TypeToString(Type) const; 106 const char* TypeToLibcrosString(Type type) const;
107
108 // convert string formatted for Cros Usage API to plan type enum value
109 // returns true on success and false on failure
110 // |type_out| must not be NULL and is set on a successful return
111 static bool CrosUsageStringToType(const std::string& type_string,
112 Type *type_out);
97 113
98 DISALLOW_COPY_AND_ASSIGN(DataPlan); 114 DISALLOW_COPY_AND_ASSIGN(DataPlan);
99 }; 115 };
100 116
101 } // namespace cashew 117 } // namespace cashew
102 118
103 #endif // SRC_DATA_PLAN_H_ 119 #endif // SRC_DATA_PLAN_H_
OLDNEW
« no previous file with comments | « src/cashew_server.cc ('k') | src/data_plan.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698