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

Side by Side Diff: src/device.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/default_policy.cc ('k') | src/device.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_DEVICE_H_ 5 #ifndef SRC_DEVICE_H_
6 #define SRC_DEVICE_H_ 6 #define SRC_DEVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include <base/basictypes.h> // NOLINT 10 #include <base/basictypes.h> // NOLINT
11 #include <dbus-c++/dbus.h> // NOLINT 11 #include <dbus-c++/dbus.h> // NOLINT
12 12
13 #include "src/flimflam_device_client_glue.h" 13 #include "src/flimflam_device_client_glue.h"
14 14
15 namespace cashew { 15 namespace cashew {
16 16
17 class Service;
18
17 // represents a cellular device and monitors Flimflam state for that device 19 // represents a cellular device and monitors Flimflam state for that device
18 class Device : public org::chromium::flimflam::Device_proxy, 20 class Device : public org::chromium::flimflam::Device_proxy,
19 public DBus::IntrospectableProxy, 21 public DBus::IntrospectableProxy,
20 public DBus::ObjectProxy { 22 public DBus::ObjectProxy {
21 public: 23 public:
22 Device(DBus::Connection& connection, const DBus::Path& path); // NOLINT 24 Device(Service * const parent, DBus::Connection& connection, // NOLINT
25 const DBus::Path& path);
23 virtual ~Device(); 26 virtual ~Device();
24 27
25 // get D-Bus path for this device 28 // get D-Bus path for this device
26 virtual const DBus::Path& GetPath() const; 29 virtual const DBus::Path& GetPath() const;
27 30
28 // valid type values for this device 31 // valid type values for this device
29 typedef enum { 32 typedef enum {
30 kTypeUnknown = 0, 33 kTypeUnknown = 0,
31 kTypeEthernet, 34 kTypeEthernet,
32 kTypeWifi, 35 kTypeWifi,
33 kTypeWimax, 36 kTypeWimax,
34 kTypeBluetooth, 37 kTypeBluetooth,
35 kTypeGPS, 38 kTypeGPS,
36 kTypeCellular, 39 kTypeCellular,
37 kTypeVendor, 40 kTypeVendor,
38 } Type; 41 } Type;
39 42
40 // get type for this device 43 // get type for this device
41 // NOTE: for now, should always be kTypeCellular 44 // NOTE: for now, should always be kTypeCellular
42 virtual Type GetType() const; 45 virtual Type GetType() const;
43 46
44 static const char* kCarrierUnknown; 47 static const char *kCarrierUnknown;
45 48
46 // get cellular carrier for this device 49 // get cellular carrier for this device
47 // returns kCarrierUnknown if we don't know 50 // returns kCarrierUnknown if we don't know
48 virtual const std::string& GetCarrier() const; 51 virtual const std::string& GetCarrier() const;
49 52
50 // Flimflam Device D-Bus Proxy methods 53 // Flimflam Device D-Bus Proxy methods
51 virtual void PropertyChanged(const std::string& property_name, 54 virtual void PropertyChanged(const std::string& property_name,
52 const DBus::Variant& new_value); 55 const DBus::Variant& new_value);
53 56
54 private: 57 private:
58 // back pointer to our parent Service
59 Service * const parent_;
60
55 // D-Bus path for Flimflam device that we represent 61 // D-Bus path for Flimflam device that we represent
56 // this is our unique identifier 62 // this is our unique identifier
57 const DBus::Path path_; 63 const DBus::Path path_;
58 64
59 // device type 65 // device type
60 Type type_; 66 Type type_;
61 67
62 // cellular carrier 68 // cellular carrier
63 std::string carrier_; 69 std::string carrier_;
64 70
65 // convert type string to Type enum value 71 // convert type string to Type enum value
66 Type TypeFromString(const std::string& type) const; 72 Type TypeFromString(const std::string& type) const;
67 73
68 // we've received updated Cellular.Carrier info from Flimflam 74 // we've received updated Cellular.Carrier info from Flimflam
69 void OnCarrierUpdate(const std::string& carrier); 75 void OnCarrierUpdate(const std::string& carrier);
70 76
71 // we've received updated Type info from Flimflam 77 // we've received updated Type info from Flimflam
72 void OnTypeUpdate(const std::string& type); 78 void OnTypeUpdate(const std::string& type);
73 79
74 // get device properties from Flimflam 80 // get device properties from Flimflam
75 void GetDeviceProperties(); 81 void GetDeviceProperties();
76 82
77 DISALLOW_COPY_AND_ASSIGN(Device); 83 DISALLOW_COPY_AND_ASSIGN(Device);
78 }; 84 };
79 85
80 } // namespace cashew 86 } // namespace cashew
81 87
82 #endif // SRC_DEVICE_H_ 88 #endif // SRC_DEVICE_H_
OLDNEW
« no previous file with comments | « src/default_policy.cc ('k') | src/device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698