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

Side by Side Diff: src/data_plan.h

Issue 3576011: Cashew: track cellular service state. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: Make debug logging less verbose 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SRC_DATA_PLAN_H_
6 #define SRC_DATA_PLAN_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include <base/basictypes.h> // NOLINT
13 #include <base/time.h> // NOLINT
14 #include <dbus-c++/dbus.h> // NOLINT
15
16 namespace cashew {
17
18 class DataPlan;
19
20 // byte count
21 // TODO(vlaviano): this should be a uint64, but libcros/Chrome expects this
22 typedef int64 Bytes;
23
24 // List of DataPlan objects
25 typedef std::vector<DataPlan*> DataPlanList;
26
27 // DataPlan object formatted for D-Bus (using DBus::Variants to wrap fields)
28 typedef std::map<std::string, DBus::Variant> DBusDataPlan;
29
30 // List of DataPlan objects formatted for D-Bus
31 typedef std::vector<DBusDataPlan> DBusDataPlanList;
32
33 // Represents a data plan associated with a cellular service
34 class DataPlan {
35 public:
36 // valid type values for this plan
37 typedef enum {
38 kTypeUnlimited = 0,
39 kTypeMeteredFree,
40 kTypeMeteredPaid,
41 } Type;
42
43 DataPlan(const std::string& name, DataPlan::Type type,
44 base::Time update_time, base::Time start_time,
45 base::Time end_time, Bytes data_bytes_max, Bytes data_bytes_used);
46 virtual ~DataPlan();
47
48 // get plan name
49 virtual const std::string& GetName() const;
50
51 // get plan type
52 virtual Type GetType() const;
53
54 // get last update time
55 virtual base::Time GetUpdateTime() const;
56
57 // get plan start time
58 virtual base::Time GetStartTime() const;
59
60 // get plan end time
61 virtual base::Time GetEndTime() const;
62
63 // get plan max bytes
64 virtual Bytes GetDataBytesMax() const;
65
66 // get plan used bytes
67 virtual Bytes GetDataBytesUsed() const;
68
69 // return a{sv} representation for D-Bus
70 virtual DBusDataPlan ToDBusFormat() const;
71
72 private:
73 // human-readable plan name
74 const std::string name_;
75
76 // plan type
77 const Type type_;
78
79 // last update time (i.e., how fresh is plan data)
80 base::Time update_time_;
81
82 // plan start time
83 const base::Time start_time_;
84
85 // plan end time
86 const base::Time end_time_;
87
88 // max bytes available during plan period
89 // irrelevant for plans of type kTypeUnlimited
90 const Bytes data_bytes_max_;
91
92 // bytes consumed so far during plan period
93 Bytes data_bytes_used_;
94
95 // convert plan type enum value to string
96 const char* TypeToString(Type) const;
97
98 DISALLOW_COPY_AND_ASSIGN(DataPlan);
99 };
100
101 } // namespace cashew
102
103 #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