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

Side by Side Diff: src/data_plan.h

Issue 6250171: cashew: reset local counter on plan transition (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 9 years, 10 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
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 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo) 5 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo)
6 6
7 #ifndef SRC_DATA_PLAN_H_ 7 #ifndef SRC_DATA_PLAN_H_
8 #define SRC_DATA_PLAN_H_ 8 #define SRC_DATA_PLAN_H_
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include <base/basictypes.h> // NOLINT 14 #include <base/basictypes.h> // NOLINT
15 #include <base/time.h> // NOLINT 15 #include <base/time.h> // NOLINT
16 #include <dbus-c++/dbus.h> // NOLINT 16 #include <dbus-c++/dbus.h> // NOLINT
17 17
18 #include "src/values.h" 18 #include "src/values.h"
19 19
20 namespace cashew { 20 namespace cashew {
21 21
22 class DataPlan; 22 class DataPlan;
23 class Device;
23 class Policy; 24 class Policy;
25 class Service;
26 class ServiceManager;
24 27
25 // byte count 28 // byte count
26 // TODO(vlaviano): this should be a uint64, but libcros/Chrome expects this 29 // TODO(vlaviano): this should be a uint64, but libcros/Chrome expects this
27 typedef int64 Bytes; 30 typedef int64 Bytes;
Eric Shienbrood 2011/02/10 18:47:00 Would "ByteCount" be a better name for this? "Byte
Vince Laviano 2011/02/10 22:29:19 Done.
28 31
29 // List of DataPlan objects 32 // List of DataPlan objects
30 // TODO(vlaviano): consider promoting this from a typedef to a class 33 // TODO(vlaviano): consider promoting this from a typedef to a class
31 typedef std::vector<DataPlan*> DataPlanList; 34 typedef std::vector<DataPlan*> DataPlanList;
32 35
33 // DataPlan object formatted for D-Bus (using DBus::Variants to wrap fields) 36 // DataPlan object formatted for D-Bus (using DBus::Variants to wrap fields)
34 typedef std::map<std::string, DBus::Variant> DBusDataPlan; 37 typedef std::map<std::string, DBus::Variant> DBusDataPlan;
35 38
36 // List of DataPlan objects formatted for D-Bus 39 // List of DataPlan objects formatted for D-Bus
37 typedef std::vector<DBusDataPlan> DBusDataPlanList; 40 typedef std::vector<DBusDataPlan> DBusDataPlanList;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // returns true on success and false on failure 101 // returns true on success and false on failure
99 // |time_out| must not be NULL and is set on a successful return 102 // |time_out| must not be NULL and is set on a successful return
100 static bool TimeFromIso8601(const std::string& time_8601, 103 static bool TimeFromIso8601(const std::string& time_8601,
101 base::Time *time_out, 104 base::Time *time_out,
102 bool zoneless_strings_are_local); 105 bool zoneless_strings_are_local);
103 106
104 // returns first active plan in |data_plans| 107 // returns first active plan in |data_plans|
105 // returns NULL if list is empty or contains no active plans 108 // returns NULL if list is empty or contains no active plans
106 static DataPlan* GetActivePlan(const DataPlanList& data_plans); 109 static DataPlan* GetActivePlan(const DataPlanList& data_plans);
107 110
111 // event handler for |service's| local byte counter on |device|
112 // updates active plans in |data_plans| based on the |rx_bytes| and
113 // |tx_bytes| values gathered during the most recent sample interval
114 // notifies |service_manager| if an active plan is completely consumed
115 // returns true if any plans were updated and false otherwise
116 // |data_plans|, |service|, |service_manager| and |device| must not be NULL
117 static bool OnByteCounterUpdate(DataPlanList *data_plans, Service *service,
118 ServiceManager *service_manager,
119 Device *device, uint64 rx_bytes,
120 uint64 tx_bytes);
121
108 private: 122 private:
109 // human-readable plan name 123 // human-readable plan name
110 const std::string name_; 124 const std::string name_;
111 125
112 // plan type 126 // plan type
113 const Type type_; 127 const Type type_;
114 128
115 // last update time (i.e., how fresh is plan data) 129 // last update time (i.e., how fresh is plan data)
116 // this refers to carrier API data, not local measurements 130 // this refers to carrier API data, not local measurements
117 base::Time update_time_; 131 base::Time update_time_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 static bool GetInt64FromDictionary(const DictionaryValue& dict, 168 static bool GetInt64FromDictionary(const DictionaryValue& dict,
155 const std::string& key, 169 const std::string& key,
156 int64* out_value); 170 int64* out_value);
157 171
158 DISALLOW_COPY_AND_ASSIGN(DataPlan); 172 DISALLOW_COPY_AND_ASSIGN(DataPlan);
159 }; 173 };
160 174
161 } // namespace cashew 175 } // namespace cashew
162 176
163 #endif // SRC_DATA_PLAN_H_ 177 #endif // SRC_DATA_PLAN_H_
OLDNEW
« no previous file with comments | « src/byte_counter.h ('k') | src/data_plan.cc » ('j') | src/device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698