Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 5 | #ifndef SHILL_SERVICE_H_ |
| 6 | #define SHILL_SERVICE_H_ |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 8 | #include <time.h> |
| 9 | |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 10 | #include <deque> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 11 | #include <map> |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 12 | #include <set> |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 13 | #include <string> |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 14 | #include <vector> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 15 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 16 | #include <base/cancelable_callback.h> |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 17 | #include <base/memory/ref_counted.h> |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 18 | #include <base/memory/scoped_ptr.h> |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 19 | #include <base/memory/weak_ptr.h> |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 20 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 21 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 22 | #include "shill/adaptor_interfaces.h" |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 23 | #include "shill/accessor_interface.h" |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 24 | #include "shill/callbacks.h" |
Chris Masone | b925cc8 | 2011-06-22 15:39:57 -0700 | [diff] [blame] | 25 | #include "shill/property_store.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 26 | #include "shill/refptr_types.h" |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 27 | #include "shill/shill_time.h" |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 28 | #include "shill/static_ip_parameters.h" |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 29 | #include "shill/technology.h" |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 30 | |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 31 | namespace chromeos_metrics { |
| 32 | class Timer; |
| 33 | } |
| 34 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | namespace shill { |
| 36 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 37 | class ControlInterface; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 38 | class DiagnosticsReporter; |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 39 | class EapCredentials; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 40 | class Endpoint; |
Chris Masone | 8fe2c7e | 2011-06-09 15:51:19 -0700 | [diff] [blame] | 41 | class Error; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 42 | class EventDispatcher; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 43 | class HTTPProxy; |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 44 | class KeyValueStore; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 45 | class Manager; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 46 | class Metrics; |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 47 | class MockManager; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 48 | class ServiceAdaptorInterface; |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 49 | class ServiceMockAdaptor; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 50 | class Sockets; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 51 | class StoreInterface; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 52 | |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 53 | // A Service is a uniquely named entity, which the system can |
| 54 | // connect in order to begin sending and receiving network traffic. |
| 55 | // All Services are bound to an Entry, which represents the persistable |
| 56 | // state of the Service. If the Entry is populated at the time of Service |
| 57 | // creation, that information is used to prime the Service. If not, the Entry |
| 58 | // becomes populated over time. |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 59 | class Service : public base::RefCounted<Service> { |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 60 | public: |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 61 | static const char kCheckPortalAuto[]; |
| 62 | static const char kCheckPortalFalse[]; |
| 63 | static const char kCheckPortalTrue[]; |
| 64 | |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 65 | static const char kErrorDetailsNone[]; |
| 66 | |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 67 | // TODO(pstew): Storage constants shouldn't need to be public |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 68 | // crbug.com/208736 |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 69 | static const char kStorageAutoConnect[]; |
| 70 | static const char kStorageCheckPortal[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 71 | static const char kStorageError[]; |
| 72 | static const char kStorageFavorite[]; |
| 73 | static const char kStorageGUID[]; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 74 | static const char kStorageHasEverConnected[]; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 75 | static const char kStorageName[]; |
| 76 | static const char kStoragePriority[]; |
| 77 | static const char kStorageProxyConfig[]; |
| 78 | static const char kStorageSaveCredentials[]; |
| 79 | static const char kStorageType[]; |
| 80 | static const char kStorageUIData[]; |
| 81 | |
mukesh agrawal | 8f3f775 | 2012-02-17 19:42:09 -0800 | [diff] [blame] | 82 | static const uint8 kStrengthMax; |
| 83 | static const uint8 kStrengthMin; |
| 84 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 85 | enum ConnectFailure { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 86 | kFailureUnknown, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 87 | kFailureAAA, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 88 | kFailureActivation, |
| 89 | kFailureBadPassphrase, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 90 | kFailureBadWEPKey, |
| 91 | kFailureConnect, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 92 | kFailureDHCP, |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 93 | kFailureDNSLookup, |
Paul Stewart | db0f917 | 2012-11-30 16:48:09 -0800 | [diff] [blame] | 94 | kFailureEAPAuthentication, |
| 95 | kFailureEAPLocalTLS, |
| 96 | kFailureEAPRemoteTLS, |
Darin Petkov | 1c049c7 | 2013-03-21 13:15:45 +0100 | [diff] [blame] | 97 | kFailureHTTPGet, |
| 98 | kFailureIPSecCertAuth, |
| 99 | kFailureIPSecPSKAuth, |
| 100 | kFailureInternal, |
| 101 | kFailureNeedEVDO, |
| 102 | kFailureNeedHomeNetwork, |
| 103 | kFailureOTASP, |
| 104 | kFailureOutOfRange, |
| 105 | kFailurePPPAuth, |
| 106 | kFailurePinMissing, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 107 | kFailureMax |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 108 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 109 | enum ConnectState { |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 110 | kStateUnknown, |
| 111 | kStateIdle, |
| 112 | kStateAssociating, |
| 113 | kStateConfiguring, |
| 114 | kStateConnected, |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 115 | kStatePortal, |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 116 | kStateFailure, |
| 117 | kStateOnline |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 118 | }; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 119 | enum CryptoAlgorithm { |
| 120 | kCryptoNone, |
| 121 | kCryptoRc4, |
| 122 | kCryptoAes |
| 123 | }; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 124 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 125 | static const int kPriorityNone; |
| 126 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 127 | // A constructor for the Service object |
| 128 | Service(ControlInterface *control_interface, |
| 129 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 130 | Metrics *metrics, |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 131 | Manager *manager, |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 132 | Technology::Identifier technology); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 133 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 134 | // AutoConnect MAY choose to ignore the connection request in some |
| 135 | // cases. For example, if the corresponding Device only supports one |
| 136 | // concurrent connection, and another Service is already connected |
| 137 | // or connecting. |
| 138 | // |
| 139 | // AutoConnect MAY issue RPCs immediately. So AutoConnect MUST NOT |
| 140 | // be called from a D-Bus signal handler context. |
| 141 | virtual void AutoConnect(); |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 142 | // Queue up a connection attempt. Derived classes SHOULD call the |
| 143 | // base class implementation before beginning a connect. The base |
| 144 | // class will log the connection attempt, and update base-class |
| 145 | // state. |
| 146 | virtual void Connect(Error *error, const char *reason); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 147 | // Disconnect this service. Override this method to add your service specific |
| 148 | // disconnect logic, but call the super class's Disconnect() first. |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 149 | virtual void Disconnect(Error *error); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 150 | // Disconnects this service via Disconnect(). Marks the service as having |
| 151 | // failed with |failure|. Do not override this method. |
| 152 | virtual void DisconnectWithFailure(ConnectFailure failure, Error *error); |
| 153 | // Disconnects this service via Disconnect(). The service will not be eligible |
| 154 | // for auto-connect until a subsequent call to Connect, or Load. Do not |
| 155 | // override this method. |
| 156 | virtual void UserInitiatedDisconnect(Error *error); |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 157 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 158 | // The default implementation returns the error kInvalidArguments. |
| 159 | virtual void ActivateCellularModem(const std::string &carrier, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 160 | Error *error, |
| 161 | const ResultCallback &callback); |
Ben Chan | 5d92454 | 2013-02-14 17:49:08 -0800 | [diff] [blame] | 162 | // The default implementation returns the error kNotSupported. |
| 163 | virtual void CompleteCellularActivation(Error *error); |
Darin Petkov | c408e69 | 2011-08-17 13:47:15 -0700 | [diff] [blame] | 164 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 165 | virtual bool IsActive(Error *error); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 166 | |
Paul Stewart | 7fb0938 | 2012-07-18 17:32:27 -0700 | [diff] [blame] | 167 | // Returns whether services of this type should be auto-connect by default. |
| 168 | virtual bool IsAutoConnectByDefault() const { return false; } |
| 169 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 170 | virtual ConnectState state() const { return state_; } |
| 171 | // Updates the state of the Service and alerts the manager. Also |
| 172 | // clears |failure_| if the new state isn't a failure. |
| 173 | virtual void SetState(ConnectState state); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 174 | std::string GetStateString() const; |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 175 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 176 | // State utility functions |
Darin Petkov | c8d91e5 | 2013-01-21 11:43:47 +0100 | [diff] [blame] | 177 | static bool IsConnectedState(ConnectState state); |
| 178 | static bool IsConnectingState(ConnectState state); |
| 179 | |
| 180 | virtual bool IsConnected() const; |
| 181 | virtual bool IsConnecting() const; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 182 | virtual bool IsFailed() const { |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 183 | // We sometimes lie about the failure state, to keep Chrome happy |
| 184 | // (see comment in WiFi::HandleDisconnect). Hence, we check both |
| 185 | // state and |failed_time_|. |
| 186 | return state() == kStateFailure || failed_time_ > 0; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 187 | } |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 188 | |
| 189 | // Returns true if the connection for |this| depends on service |b|. |
| 190 | virtual bool IsDependentOn(const ServiceRefPtr &b) const; |
| 191 | |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 192 | virtual bool IsPortalled() const { |
| 193 | return state() == kStatePortal; |
| 194 | } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 195 | |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 196 | virtual ConnectFailure failure() const { return failure_; } |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 197 | // Records the failure mode and time. Sets the Service state to "Failure". |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 198 | virtual void SetFailure(ConnectFailure failure); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 199 | // Records the failure mode and time. Sets the Service state to "Idle". |
| 200 | // Avoids showing a failure mole in the UI. |
| 201 | virtual void SetFailureSilent(ConnectFailure failure); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 202 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 203 | // Returns a string that is guaranteed to uniquely identify this Service |
| 204 | // instance. |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 205 | const std::string &unique_name() const { return unique_name_; } |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 206 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 207 | virtual std::string GetRpcIdentifier() const; |
Chris Masone | 3c3f6a1 | 2011-07-01 10:01:41 -0700 | [diff] [blame] | 208 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 209 | // Returns the unique persistent storage identifier for the service. |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 210 | virtual std::string GetStorageIdentifier() const = 0; |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 211 | |
Paul Stewart | e7de294 | 2013-04-25 17:07:31 -0700 | [diff] [blame] | 212 | // Returns the identifier within |storage| from which configuration for |
| 213 | // this service can be loaded. Returns an empty string if no entry in |
| 214 | // |storage| can be used. |
| 215 | virtual std::string GetLoadableStorageIdentifier( |
| 216 | const StoreInterface &storage) const; |
| 217 | |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 218 | // Returns whether the service configuration can be loaded from |storage|. |
Paul Stewart | e7de294 | 2013-04-25 17:07:31 -0700 | [diff] [blame] | 219 | virtual bool IsLoadableFrom(const StoreInterface &storage) const; |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 220 | |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 221 | // Returns true if the service uses 802.1x for key management. |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 222 | virtual bool Is8021x() const { return false; } |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 223 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 224 | // Loads the service from persistent |storage|. Returns true on success. |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 225 | virtual bool Load(StoreInterface *storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 226 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 227 | // Indicate to service that it is no longer persisted to storage. It |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 228 | // should purge any stored profile state (e.g., credentials). Returns |
| 229 | // true to indicate that this service should also be unregistered from |
| 230 | // the manager, false otherwise. |
| 231 | virtual bool Unload(); |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 232 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 233 | // Attempt to remove the service. On failure, no changes in state will occur. |
| 234 | virtual void Remove(Error *error); |
| 235 | |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 236 | // Saves the service to persistent |storage|. Returns true on success. |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 237 | virtual bool Save(StoreInterface *storage); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 238 | |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 239 | // Saves the service to the current profile. |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 240 | virtual void SaveToCurrentProfile(); |
Thieu Le | d4e9e55 | 2012-02-16 16:26:07 -0800 | [diff] [blame] | 241 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 242 | // Applies all the properties in |args| to this service object's mutable |
| 243 | // store, except for those in parameters_ignored_for_configure_. |
| 244 | // Returns an error in |error| if one or more parameter set attempts |
| 245 | // fails, but will only return the first error. |
| 246 | virtual void Configure(const KeyValueStore &args, Error *error); |
| 247 | |
Paul Stewart | 7a20aa4 | 2013-01-17 12:21:41 -0800 | [diff] [blame] | 248 | // Iterate over all the properties in |args| and test for an identical |
| 249 | // value in this service object's store. Returns false if one or more |
| 250 | // keys in |args| do not exist or have different values, true otherwise. |
| 251 | virtual bool DoPropertiesMatch(const KeyValueStore &args) const; |
| 252 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 253 | // Returns whether portal detection is explicitly disabled on this service |
| 254 | // via a property set on it. |
| 255 | virtual bool IsPortalDetectionDisabled() const; |
| 256 | |
| 257 | // Returns whether portal detection is set to follow the default setting |
| 258 | // of this service's technology via a property set on it. |
| 259 | virtual bool IsPortalDetectionAuto() const; |
| 260 | |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 261 | // Returns true if the service is persisted to a non-ephemeral profile. |
| 262 | virtual bool IsRemembered() const; |
| 263 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 264 | // Returns true if the service RPC identifier should be part of the |
| 265 | // manager's advertised services list, false otherwise. |
| 266 | virtual bool IsVisible() const { return true; } |
| 267 | |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 268 | // Returns true if there is a proxy configuration set on this service. |
| 269 | virtual bool HasProxyConfig() const { return !proxy_config_.empty(); } |
| 270 | |
Paul Stewart | a47c3c6 | 2012-12-18 12:14:29 -0800 | [diff] [blame] | 271 | // Returns whether this service has had recent connection issues. |
| 272 | virtual bool HasRecentConnectionIssues(); |
| 273 | |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 274 | virtual void MakeFavorite(); |
| 275 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 276 | // Set the connection for this service. If the connection is non-NULL, create |
| 277 | // an HTTP Proxy that will utilize this service's connection to serve |
| 278 | // requests. |
| 279 | virtual void SetConnection(const ConnectionRefPtr &connection); |
| 280 | virtual const ConnectionRefPtr &connection() const { return connection_; } |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 281 | |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 282 | // Examines the EAP credentials for the service and returns true if a |
| 283 | // connection attempt can be made. |
Paul Stewart | 9413bcc | 2013-04-04 16:12:43 -0700 | [diff] [blame] | 284 | virtual bool Is8021xConnectable() const; |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 285 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 286 | // Add an EAP certification id |name| at position |depth| in the stack. |
| 287 | // Returns true if entry was added, false otherwise. |
| 288 | virtual bool AddEAPCertification(const std::string &name, size_t depth); |
| 289 | // Clear all EAP certification elements. |
Paul Stewart | 9413bcc | 2013-04-04 16:12:43 -0700 | [diff] [blame] | 290 | virtual void ClearEAPCertification(); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 291 | |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 292 | // The inherited class should register any custom metrics in this method. |
| 293 | virtual void InitializeCustomMetrics() const {} |
| 294 | |
| 295 | // The inherited class that needs to send metrics after the service has |
Thieu Le | b84ba34 | 2012-03-02 15:15:19 -0800 | [diff] [blame] | 296 | // transitioned to the ready state should override this method. |
| 297 | // |time_resume_to_ready_milliseconds| holds the elapsed time from when |
| 298 | // the system was resumed until when the service transitioned to the |
| 299 | // connected state. This value is non-zero for the first service transition |
| 300 | // to the connected state after a resume. |
| 301 | virtual void SendPostReadyStateMetrics( |
| 302 | int64 /*time_resume_to_ready_milliseconds*/) const {} |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 303 | |
Darin Petkov | afa6fc4 | 2011-06-21 16:21:08 -0700 | [diff] [blame] | 304 | bool auto_connect() const { return auto_connect_; } |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 305 | void SetAutoConnect(bool connect); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 306 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 307 | bool connectable() const { return connectable_; } |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 308 | // Sets the connectable property of the service, and broadcast the |
| 309 | // new value. Does not update the manager. |
| 310 | // TODO(petkov): Remove this method in favor of SetConnectableFull. |
Darin Petkov | b2ba39f | 2012-06-06 10:33:43 +0200 | [diff] [blame] | 311 | void SetConnectable(bool connectable); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 312 | // Sets the connectable property of the service, broadcasts the new |
| 313 | // value, and alerts the manager if necessary. |
| 314 | void SetConnectableFull(bool connectable); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 315 | |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 316 | virtual bool explicitly_disconnected() const { |
| 317 | return explicitly_disconnected_; |
| 318 | } |
| 319 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 320 | bool favorite() const { return favorite_; } |
mukesh agrawal | 00917ce | 2011-11-22 23:56:55 +0000 | [diff] [blame] | 321 | // Setter is deliberately omitted; use MakeFavorite. |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 322 | |
Darin Petkov | 7f06033 | 2012-03-14 11:46:47 +0100 | [diff] [blame] | 323 | void set_friendly_name(const std::string &n) { friendly_name_ = n; } |
Darin Petkov | 9c6e981 | 2013-03-26 13:49:07 +0100 | [diff] [blame] | 324 | const std::string &friendly_name() const { return friendly_name_; } |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 325 | // Sets the flimflam::kNameProperty and broadcasts the change. |
| 326 | void SetFriendlyName(const std::string &friendly_name); |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 327 | |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 328 | const std::string &guid() const { return guid_; } |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 329 | bool SetGuid(const std::string &guid, Error *error); |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 330 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 331 | bool has_ever_connected() const { return has_ever_connected_; } |
| 332 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 333 | int32 priority() const { return priority_; } |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 334 | bool SetPriority(const int32 &priority, Error *error); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 335 | |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 336 | size_t crypto_algorithm() const { return crypto_algorithm_; } |
| 337 | bool key_rotation() const { return key_rotation_; } |
| 338 | bool endpoint_auth() const { return endpoint_auth_; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 339 | |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 340 | void SetStrength(uint8 strength); |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 341 | |
| 342 | // uint8 streams out as a char. Coerce to a larger type, so that |
| 343 | // it prints as a number. |
| 344 | uint16 strength() const { return strength_; } |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 345 | |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 346 | virtual Technology::Identifier technology() const { return technology_; } |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 347 | std::string GetTechnologyString() const; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 348 | |
Paul Stewart | 35eff13 | 2013-04-12 12:08:40 -0700 | [diff] [blame] | 349 | virtual const EapCredentials *eap() const { return eap_.get(); } |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 350 | void SetEapCredentials(EapCredentials *eap); |
Gaurav Shah | 10109f2 | 2011-11-11 20:16:22 -0800 | [diff] [blame] | 351 | |
Darin Petkov | cb71529 | 2012-04-25 13:04:37 +0200 | [diff] [blame] | 352 | bool save_credentials() const { return save_credentials_; } |
| 353 | void set_save_credentials(bool save) { save_credentials_ = save; } |
| 354 | |
Darin Petkov | 5148900 | 2011-08-18 13:13:20 -0700 | [diff] [blame] | 355 | const std::string &error() const { return error_; } |
| 356 | void set_error(const std::string &error) { error_ = error; } |
| 357 | |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 358 | const std::string &error_details() const { return error_details_; } |
| 359 | void SetErrorDetails(const std::string &details); |
| 360 | |
Gaurav Shah | c6d6c72 | 2011-11-17 18:59:39 -0800 | [diff] [blame] | 361 | static const char *ConnectFailureToString(const ConnectFailure &state); |
| 362 | static const char *ConnectStateToString(const ConnectState &state); |
| 363 | |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 364 | // Compare two services. Returns true if Service |a| should be displayed |
| 365 | // above |b|. If |compare_connectivity_state| is true, the connectivity |
| 366 | // state of the service (service->state()) is used as the most significant |
| 367 | // criteria for comparsion, otherwise the service state is ignored. Use |
| 368 | // |tech_order| to rank services if more decisive criteria do not yield a |
| 369 | // difference. |reason| is populated with the exact criteria used for the |
| 370 | // ultimate comparison. |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 371 | static bool Compare(ServiceRefPtr a, |
| 372 | ServiceRefPtr b, |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 373 | bool compare_connectivity_state, |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 374 | const std::vector<Technology::Identifier> &tech_order, |
| 375 | const char **reason); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 376 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 377 | // These are defined in service.cc so that we don't have to include profile.h |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 378 | // TODO(cmasone): right now, these are here only so that we can get the |
| 379 | // profile name as a property. Can we store just the name, and then handle |
| 380 | // setting the profile for this service via |manager_|? |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 381 | const ProfileRefPtr &profile() const; |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 382 | |
| 383 | // Sets the profile property of this service. Broadcasts the new value if it's |
| 384 | // not NULL. If the new value is NULL, the service will either be set to |
| 385 | // another profile afterwards or it will not be visible and not monitored |
| 386 | // anymore. |
| 387 | void SetProfile(const ProfileRefPtr &p); |
| 388 | |
| 389 | // This is called from tests and shouldn't be called otherwise. Use SetProfile |
| 390 | // instead. |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 391 | void set_profile(const ProfileRefPtr &p); |
| 392 | |
Paul Stewart | 4357f4e | 2012-04-26 17:39:26 -0700 | [diff] [blame] | 393 | // Notification that occurs when a service now has profile data saved |
| 394 | // on its behalf. Some service types like WiFi can choose to register |
| 395 | // themselves at this point. |
| 396 | virtual void OnProfileConfigured() {} |
| 397 | |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 398 | // Notification that occurs when a single property has been changed via |
| 399 | // the RPC adaptor. |
Paul Stewart | 8142613 | 2012-05-16 10:05:10 -0700 | [diff] [blame] | 400 | virtual void OnPropertyChanged(const std::string &property); |
Paul Stewart | ff14b02 | 2012-04-24 20:06:23 -0700 | [diff] [blame] | 401 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 402 | // Notification that occurs when an EAP credential property has been |
| 403 | // changed. Some service subclasses can choose to respond to this |
| 404 | // event. |
| 405 | virtual void OnEapCredentialsChanged() {} |
| 406 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 407 | // Called by the manager once after a resume. |
| 408 | virtual void OnAfterResume(); |
| 409 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 410 | EapCredentials *mutable_eap() { return eap_.get(); } |
| 411 | |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 412 | PropertyStore *mutable_store() { return &store_; } |
| 413 | const PropertyStore &store() const { return store_; } |
Paul Stewart | def189e | 2012-08-02 20:12:09 -0700 | [diff] [blame] | 414 | StaticIPParameters *mutable_static_ip_parameters() { |
| 415 | return &static_ip_parameters_; |
| 416 | } |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 417 | const StaticIPParameters &static_ip_parameters() const { |
| 418 | return static_ip_parameters_; |
| 419 | } |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 420 | |
Paul Stewart | c3dbff1 | 2013-07-17 10:32:48 -0700 | [diff] [blame] | 421 | // Retrieves |key| from |id| in |storage| to |value|. If this key does |
| 422 | // not exist, assign |default_value| to |value|. |
| 423 | static void LoadString(StoreInterface *storage, |
| 424 | const std::string &id, |
| 425 | const std::string &key, |
| 426 | const std::string &default_value, |
| 427 | std::string *value); |
| 428 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 429 | // Assigns |value| to |key| in |storage| if |value| is non-empty and |save| is |
| 430 | // true. Otherwise, removes |key| from |storage|. If |crypted| is true, the |
| 431 | // value is encrypted. |
| 432 | static void SaveString(StoreInterface *storage, |
| 433 | const std::string &id, |
| 434 | const std::string &key, |
| 435 | const std::string &value, |
| 436 | bool crypted, |
| 437 | bool save); |
| 438 | |
Paul Stewart | 967eaeb | 2013-04-25 19:53:07 -0700 | [diff] [blame] | 439 | // Called via RPC to get a dict containing profile-to-entry_name mappings |
| 440 | // of all the profile entires which contain configuration applicable to |
| 441 | // this service. |
| 442 | std::map<std::string, std::string> GetLoadableProfileEntries(); |
| 443 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 444 | protected: |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 445 | friend class base::RefCounted<Service>; |
| 446 | |
mukesh agrawal | 03c15ce | 2012-11-29 17:36:21 -0800 | [diff] [blame] | 447 | static const char kAutoConnBusy[]; |
| 448 | |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 449 | virtual ~Service(); |
| 450 | |
Chris Masone | 34af218 | 2011-08-22 11:59:36 -0700 | [diff] [blame] | 451 | // Returns true if a character is allowed to be in a service storage id. |
| 452 | static bool LegalChar(char a) { return isalnum(a) || a == '_'; } |
| 453 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 454 | // Returns true if a character is disallowed to be in a service storage id. |
| 455 | static bool IllegalChar(char a) { return !LegalChar(a); } |
| 456 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 457 | virtual std::string CalculateState(Error *error); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 458 | std::string CalculateTechnology(Error *error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 459 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 460 | // Returns whether this service is in a state conducive to auto-connect. |
| 461 | // This should include any tests used for computing connectable(), |
| 462 | // as well as other critera such as whether the device associated with |
| 463 | // this service is busy with another connection. |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 464 | // |
| 465 | // If the service is not auto-connectable, |*reason| will be set to |
| 466 | // point to C-string explaining why the service is not auto-connectable. |
| 467 | virtual bool IsAutoConnectable(const char **reason) const; |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 468 | |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 469 | // HelpRegisterDerived*: Expose a property over RPC, with the name |name|. |
| 470 | // |
| 471 | // Reads of the property will be handled by invoking |get|. |
| 472 | // Writes to the property will be handled by invoking |set|. |
| 473 | // Clearing the property will be handled by PropertyStore. |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 474 | void HelpRegisterDerivedBool( |
| 475 | const std::string &name, |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 476 | bool(Service::*get)(Error *error), |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 477 | bool(Service::*set)(const bool &value, Error *error)); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 478 | void HelpRegisterDerivedInt32( |
| 479 | const std::string &name, |
| 480 | int32(Service::*get)(Error *error), |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 481 | bool(Service::*set)(const int32 &value, Error *error)); |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 482 | void HelpRegisterDerivedString( |
| 483 | const std::string &name, |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 484 | std::string(Service::*get)(Error *error), |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 485 | bool(Service::*set)(const std::string &value, Error *error)); |
| 486 | void HelpRegisterConstDerivedUint16( |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 487 | const std::string &name, |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 488 | uint16(Service::*get)(Error *error)); |
| 489 | void HelpRegisterConstDerivedRpcIdentifier( |
Jason Glasgow | acdc11f | 2012-03-30 14:12:22 -0400 | [diff] [blame] | 490 | const std::string &name, |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 491 | std::string(Service::*get)(Error *)); |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 492 | void HelpRegisterConstDerivedStrings( |
| 493 | const std::string &name, Strings(Service::*get)(Error *error)); |
mukesh agrawal | 292dc0f | 2012-01-26 18:02:46 -0800 | [diff] [blame] | 494 | // Expose a property over RPC, with the name |name|. |
| 495 | // |
| 496 | // Reads of the property will be handled by invoking |get|. |
| 497 | // Writes to the property will be handled by invoking |set|. |
| 498 | // |
| 499 | // Clearing the property will be handled by invoking |clear|, or |
| 500 | // calling |set| with |default_value| (whichever is non-NULL). It |
| 501 | // is an error to call this method with both |clear| and |
| 502 | // |default_value| non-NULL. |
| 503 | void HelpRegisterWriteOnlyDerivedString( |
| 504 | const std::string &name, |
| 505 | void(Service::*set)(const std::string &value, Error *error), |
| 506 | void(Service::*clear)(Error *error), |
| 507 | const std::string *default_value); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 508 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 509 | ServiceAdaptorInterface *adaptor() const { return adaptor_.get(); } |
| 510 | |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 511 | void UnloadEapCredentials(); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 512 | |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 513 | // Ignore |parameter| when performing a Configure() operation. |
| 514 | void IgnoreParameterForConfigure(const std::string ¶meter); |
| 515 | |
Paul Stewart | f2d6091 | 2012-07-15 08:37:30 -0700 | [diff] [blame] | 516 | // Update the service's string-based "Error" RPC property based on the |
| 517 | // failure_ enum. |
| 518 | void UpdateErrorProperty(); |
| 519 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 520 | // RPC setter for the the "AutoConnect" property. Updates the |manager_|. |
| 521 | // (cf. SetAutoConnect, which does not update the manager.) |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 522 | virtual bool SetAutoConnectFull(const bool &connect, Error *error); |
Paul Stewart | cf199de | 2012-08-16 07:50:41 -0700 | [diff] [blame] | 523 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 524 | // Property accessors reserved for subclasses |
| 525 | EventDispatcher *dispatcher() const { return dispatcher_; } |
| 526 | const std::string &GetEAPKeyManagement() const; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 527 | virtual void SetEAPKeyManagement(const std::string &key_management); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 528 | Manager *manager() const { return manager_; } |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 529 | Metrics *metrics() const { return metrics_; } |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 530 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 531 | // Mark the serivce as a favorite, without affecting its auto_connect |
| 532 | // property. (cf. MakeFavorite) |
| 533 | void MarkAsFavorite(); |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 534 | // Inform base class of the security properties for the service. |
| 535 | // |
| 536 | // NB: When adding a call to this function from a subclass, please check |
| 537 | // that the semantics of SecurityLevel() are appropriate for the subclass. |
| 538 | void SetSecurity(CryptoAlgorithm crypt, bool rotation, bool endpoint_auth); |
Darin Petkov | 1d0080a | 2012-04-30 17:10:36 +0200 | [diff] [blame] | 539 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 540 | private: |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 541 | friend class EthernetEapServiceTest; |
Paul Stewart | cf199de | 2012-08-16 07:50:41 -0700 | [diff] [blame] | 542 | friend class EthernetServiceTest; |
Thieu Le | 48e6d6d | 2011-12-06 00:40:27 +0000 | [diff] [blame] | 543 | friend class MetricsTest; |
Paul Stewart | 9dd253e | 2013-04-22 08:32:59 -0700 | [diff] [blame] | 544 | friend class ManagerTest; |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 545 | friend class ServiceAdaptorInterface; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 546 | friend class ServiceTest; |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 547 | friend class VPNProviderTest; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 548 | friend class VPNServiceTest; |
mukesh agrawal | e1d90e9 | 2012-02-15 17:36:08 -0800 | [diff] [blame] | 549 | friend class WiFiServiceTest; |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 550 | friend class WiMaxProviderTest; |
Darin Petkov | 6b9b2e1 | 2012-07-10 15:51:42 +0200 | [diff] [blame] | 551 | friend class WiMaxServiceTest; |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 552 | friend void TestCommonPropertyChanges(ServiceRefPtr, ServiceMockAdaptor *); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 553 | friend void TestCustomSetterNoopChange(ServiceRefPtr, MockManager *); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 554 | friend void TestNamePropertyChange(ServiceRefPtr, ServiceMockAdaptor *); |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 555 | FRIEND_TEST(AllMockServiceTest, AutoConnectWithFailures); |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 556 | FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier); |
Liam McLoughlin | 0fec81c | 2013-02-28 10:31:47 -0500 | [diff] [blame] | 557 | FRIEND_TEST(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier); |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 558 | FRIEND_TEST(CellularServiceTest, IsAutoConnectable); |
mukesh agrawal | cc0fded | 2012-05-09 13:40:58 -0700 | [diff] [blame] | 559 | FRIEND_TEST(DeviceTest, IPConfigUpdatedFailureWithStatic); |
Paul Stewart | 39db5ca | 2013-03-18 14:15:17 -0700 | [diff] [blame] | 560 | FRIEND_TEST(ManagerTest, ConnectToBestServices); |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 561 | // TODO(quiche): The SortServices test should probably move into |
| 562 | // service_unittest.cc. Then the following line should be removed. |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 563 | // (crbug.com/206367) |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 564 | FRIEND_TEST(ManagerTest, SortServices); |
mukesh agrawal | 03c15ce | 2012-11-29 17:36:21 -0800 | [diff] [blame] | 565 | FRIEND_TEST(ServiceTest, AutoConnectLogging); |
Darin Petkov | 58f0b6d | 2012-06-12 12:52:30 +0200 | [diff] [blame] | 566 | FRIEND_TEST(ServiceTest, CalculateState); |
| 567 | FRIEND_TEST(ServiceTest, CalculateTechnology); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 568 | FRIEND_TEST(ServiceTest, Certification); |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 569 | FRIEND_TEST(ServiceTest, ConfigureEapStringProperty); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 570 | FRIEND_TEST(ServiceTest, ConfigureIgnoredProperty); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 571 | FRIEND_TEST(ServiceTest, Constructor); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 572 | FRIEND_TEST(ServiceTest, CustomSetterNoopChange); |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 573 | FRIEND_TEST(ServiceTest, GetIPConfigRpcIdentifier); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 574 | FRIEND_TEST(ServiceTest, GetProperties); |
mukesh agrawal | 76d1388 | 2012-01-12 15:23:11 -0800 | [diff] [blame] | 575 | FRIEND_TEST(ServiceTest, IsAutoConnectable); |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 576 | FRIEND_TEST(ServiceTest, IsDependentOn); |
Paul Stewart | c3dbff1 | 2013-07-17 10:32:48 -0700 | [diff] [blame] | 577 | FRIEND_TEST(ServiceTest, Load); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 578 | FRIEND_TEST(ServiceTest, RecheckPortal); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 579 | FRIEND_TEST(ServiceTest, Save); |
| 580 | FRIEND_TEST(ServiceTest, SaveString); |
| 581 | FRIEND_TEST(ServiceTest, SaveStringCrypted); |
| 582 | FRIEND_TEST(ServiceTest, SaveStringDontSave); |
| 583 | FRIEND_TEST(ServiceTest, SaveStringEmpty); |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 584 | FRIEND_TEST(ServiceTest, SecurityLevel); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 585 | FRIEND_TEST(ServiceTest, SetCheckPortal); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 586 | FRIEND_TEST(ServiceTest, SetConnectableFull); |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 587 | FRIEND_TEST(ServiceTest, SetFriendlyName); |
| 588 | FRIEND_TEST(ServiceTest, SetProperty); |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 589 | FRIEND_TEST(ServiceTest, State); |
Thieu Le | af47141 | 2013-06-27 14:12:37 -0700 | [diff] [blame] | 590 | FRIEND_TEST(ServiceTest, StateResetAfterFailure); |
Paul Stewart | d8ad3c4 | 2012-01-09 12:39:38 -0800 | [diff] [blame] | 591 | FRIEND_TEST(ServiceTest, Unload); |
Paul Stewart | bca08f8 | 2013-07-09 16:32:37 -0700 | [diff] [blame] | 592 | FRIEND_TEST(WiFiServiceTest, SuspectedCredentialFailure); |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 593 | FRIEND_TEST(WiFiTimerTest, ReconnectTimer); |
Darin Petkov | ba40dd3 | 2011-07-11 20:06:39 -0700 | [diff] [blame] | 594 | |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 595 | static const char kAutoConnConnected[]; |
| 596 | static const char kAutoConnConnecting[]; |
| 597 | static const char kAutoConnExplicitDisconnect[]; |
| 598 | static const char kAutoConnNotConnectable[]; |
Darin Petkov | 4cbff5b | 2013-01-29 16:29:05 +0100 | [diff] [blame] | 599 | static const char kAutoConnOffline[]; |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 600 | static const char kAutoConnThrottled[]; |
mukesh agrawal | bf14e94 | 2012-03-02 14:36:34 -0800 | [diff] [blame] | 601 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 602 | static const size_t kEAPMaxCertificationElements; |
| 603 | |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 604 | static const char kServiceSortAutoConnect[]; |
| 605 | static const char kServiceSortConnectable[]; |
| 606 | static const char kServiceSortFavorite[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 607 | static const char kServiceSortIsConnected[]; |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 608 | static const char kServiceSortDependency[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 609 | static const char kServiceSortIsConnecting[]; |
| 610 | static const char kServiceSortIsFailed[]; |
Paul Stewart | a121c44 | 2012-06-09 14:12:58 -0700 | [diff] [blame] | 611 | static const char kServiceSortIsPortalled[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 612 | static const char kServiceSortPriority[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 613 | static const char kServiceSortSecurityEtc[]; |
Darin Petkov | 2f903b3 | 2012-04-18 12:56:43 +0200 | [diff] [blame] | 614 | static const char kServiceSortTechnology[]; |
mukesh agrawal | ddc378f | 2012-02-17 18:26:20 -0800 | [diff] [blame] | 615 | static const char kServiceSortUniqueName[]; |
| 616 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 617 | static const uint64 kMaxAutoConnectCooldownTimeMilliseconds; |
| 618 | static const uint64 kMinAutoConnectCooldownTimeMilliseconds; |
| 619 | static const uint64 kAutoConnectCooldownBackoffFactor; |
| 620 | |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 621 | static const int kDisconnectsMonitorSeconds; |
| 622 | static const int kMisconnectsMonitorSeconds; |
| 623 | static const int kReportDisconnectsThreshold; |
| 624 | static const int kReportMisconnectsThreshold; |
| 625 | static const int kMaxDisconnectEventHistory; |
| 626 | |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 627 | bool GetAutoConnect(Error *error); |
Thieu Le | 284fe79 | 2012-01-31 17:53:19 -0800 | [diff] [blame] | 628 | |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 629 | std::string GetCheckPortal(Error *error); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 630 | bool SetCheckPortal(const std::string &check_portal, Error *error); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 631 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 632 | std::string GetGuid(Error *error); |
| 633 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 634 | virtual std::string GetDeviceRpcId(Error *error) = 0; |
Chris Masone | 95207da | 2011-06-29 16:50:49 -0700 | [diff] [blame] | 635 | |
Paul Stewart | 10241e3 | 2012-04-23 18:15:06 -0700 | [diff] [blame] | 636 | std::string GetIPConfigRpcIdentifier(Error *error); |
| 637 | |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 638 | std::string GetNameProperty(Error *error); |
Darin Petkov | 9c6e981 | 2013-03-26 13:49:07 +0100 | [diff] [blame] | 639 | // The base implementation asserts that |name| matches the current Name |
| 640 | // property value. |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 641 | virtual bool SetNameProperty(const std::string &name, Error *error); |
mukesh agrawal | cbfb34e | 2013-04-17 19:33:25 -0700 | [diff] [blame] | 642 | |
| 643 | int32 GetPriority(Error *error); |
Paul Stewart | 0c43833 | 2012-04-11 07:55:27 -0700 | [diff] [blame] | 644 | |
Paul Stewart | 1b1a7f2 | 2012-01-06 16:24:06 -0800 | [diff] [blame] | 645 | std::string GetProfileRpcId(Error *error); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 646 | bool SetProfileRpcId(const std::string &profile, Error *error); |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 647 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 648 | // Returns TCP port of service's HTTP proxy in host order. |
| 649 | uint16 GetHTTPProxyPort(Error *error); |
| 650 | |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 651 | std::string GetProxyConfig(Error *error); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 652 | bool SetProxyConfig(const std::string &proxy_config, Error *error); |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 653 | |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 654 | static Strings ExtractWallClockToStrings( |
| 655 | const std::deque<Timestamp> ×tamps); |
| 656 | Strings GetDisconnectsProperty(Error *error); |
| 657 | Strings GetMisconnectsProperty(Error *error); |
| 658 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 659 | void ReEnableAutoConnectTask(); |
| 660 | // Disables autoconnect and posts a task to re-enable it after a cooldown. |
| 661 | // Note that autoconnect could be disabled for other reasons as well. |
| 662 | void ThrottleFutureAutoConnects(); |
| 663 | |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 664 | // Saves settings to profile, if we have one. Unlike |
| 665 | // SaveServiceToProfile, SaveToProfile never assigns this service |
| 666 | // into a profile. |
| 667 | void SaveToProfile(); |
| 668 | |
Paul Stewart | 483e472 | 2012-12-18 10:23:17 -0800 | [diff] [blame] | 669 | // Start at the head of |events| and remove all entries that occurred |
| 670 | // more than |seconds_ago| prior to |now|. Also, the size of |events| |
| 671 | // is unconditionally trimmed below kMaxDisconnectEventHistory. |
| 672 | static void ExpireEventsBefore( |
| 673 | int seconds_ago, const Timestamp &now, std::deque<Timestamp> *events); |
| 674 | |
| 675 | // Qualify the conditions under which the most recent disconnect occurred. |
| 676 | // Make note ot the fact that there was a problem connecting / staying |
| 677 | // connected if the disconnection did not occur as a clear result of user |
| 678 | // action. |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 679 | void NoteDisconnectEvent(); |
| 680 | |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 681 | // Utility function that returns true if a is different from b. When they |
| 682 | // are, "decision" is populated with the boolean value of "a > b". |
| 683 | static bool DecideBetween(int a, int b, bool *decision); |
| 684 | |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 685 | // Linearize security parameters (crypto algorithm, key rotation, endpoint |
| 686 | // authentication) for comparison. |
| 687 | uint16 SecurityLevel(); |
| 688 | |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 689 | // WeakPtrFactory comes first, so that other fields can use it. |
| 690 | base::WeakPtrFactory<Service> weak_ptr_factory_; |
| 691 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 692 | ConnectState state_; |
Darin Petkov | c8d91e5 | 2013-01-21 11:43:47 +0100 | [diff] [blame] | 693 | ConnectState previous_state_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 694 | ConnectFailure failure_; |
| 695 | bool auto_connect_; |
| 696 | std::string check_portal_; |
| 697 | bool connectable_; |
| 698 | std::string error_; |
Darin Petkov | aba8932 | 2013-03-11 14:48:22 +0100 | [diff] [blame] | 699 | std::string error_details_; |
mukesh agrawal | adb6848 | 2012-01-17 16:31:51 -0800 | [diff] [blame] | 700 | bool explicitly_disconnected_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 701 | bool favorite_; |
| 702 | int32 priority_; |
mukesh agrawal | 43970a2 | 2013-02-15 16:00:07 -0800 | [diff] [blame] | 703 | uint8 crypto_algorithm_; |
| 704 | bool key_rotation_; |
| 705 | bool endpoint_auth_; |
| 706 | |
Darin Petkov | d78ee7e | 2012-01-12 11:21:10 +0100 | [diff] [blame] | 707 | uint8 strength_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 708 | std::string proxy_config_; |
Paul Stewart | 987e71e | 2011-12-05 09:45:06 -0800 | [diff] [blame] | 709 | std::string ui_data_; |
Paul Stewart | 4c56161 | 2012-03-21 12:49:01 -0700 | [diff] [blame] | 710 | std::string guid_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 711 | bool save_credentials_; |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 712 | scoped_ptr<EapCredentials> eap_; |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 713 | Technology::Identifier technology_; |
mukesh agrawal | 568b5c6 | 2012-02-28 14:44:47 -0800 | [diff] [blame] | 714 | // The time of the most recent failure. Value is 0 if the service is |
| 715 | // not currently failed. |
| 716 | time_t failed_time_; |
mukesh agrawal | cf24a24 | 2012-05-21 16:46:11 -0700 | [diff] [blame] | 717 | // Whether or not this service has ever reached kStateConnected. |
| 718 | bool has_ever_connected_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 719 | |
Darin Petkov | 0c65bdd | 2012-12-05 13:42:41 +0100 | [diff] [blame] | 720 | std::deque<Timestamp> disconnects_; // Connection drops. |
| 721 | std::deque<Timestamp> misconnects_; // Failures to connect. |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 722 | |
Christopher Wiley | 0801d19 | 2012-09-24 11:57:15 -0700 | [diff] [blame] | 723 | base::CancelableClosure reenable_auto_connect_task_; |
| 724 | uint64 auto_connect_cooldown_milliseconds_ ; |
| 725 | |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 726 | ProfileRefPtr profile_; |
| 727 | PropertyStore store_; |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 728 | std::set<std::string> parameters_ignored_for_configure_; |
Paul Stewart | ac4ac00 | 2011-08-26 12:04:26 -0700 | [diff] [blame] | 729 | |
| 730 | EventDispatcher *dispatcher_; |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 731 | static unsigned int serial_number_; |
mukesh agrawal | d835b20 | 2011-10-07 15:26:47 -0700 | [diff] [blame] | 732 | std::string unique_name_; // MUST be unique amongst service instances |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 733 | |
| 734 | // Service's friendly name is presented through the UI. By default it's the |
| 735 | // same as |unique_name_| but normally Service subclasses override |
| 736 | // it. WARNING: Don't log the friendly name at the default logging level due |
| 737 | // to PII concerns. |
| 738 | std::string friendly_name_; |
| 739 | |
Paul Stewart | c43cbbe | 2013-04-11 06:29:30 -0700 | [diff] [blame] | 740 | // List of subject names reported by remote entity during TLS setup. |
| 741 | std::vector<std::string> remote_certification_; |
| 742 | |
Paul Stewart | ba41b99 | 2011-05-26 07:02:46 -0700 | [diff] [blame] | 743 | scoped_ptr<ServiceAdaptorInterface> adaptor_; |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 744 | scoped_ptr<HTTPProxy> http_proxy_; |
Paul Stewart | c1dec4d | 2011-12-08 15:25:28 -0800 | [diff] [blame] | 745 | ConnectionRefPtr connection_; |
Paul Stewart | 1062d9d | 2012-04-27 10:42:27 -0700 | [diff] [blame] | 746 | StaticIPParameters static_ip_parameters_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 747 | Metrics *metrics_; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 748 | Manager *manager_; |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 749 | scoped_ptr<Sockets> sockets_; |
Darin Petkov | 385b9bc | 2012-12-03 15:25:05 +0100 | [diff] [blame] | 750 | Time *time_; |
| 751 | DiagnosticsReporter *diagnostics_reporter_; |
Chris Masone | 3bd3c8c | 2011-06-13 08:20:26 -0700 | [diff] [blame] | 752 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 753 | DISALLOW_COPY_AND_ASSIGN(Service); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 754 | }; |
| 755 | |
| 756 | } // namespace shill |
| 757 | |
Ben Chan | 19f8397 | 2012-10-03 23:25:56 -0700 | [diff] [blame] | 758 | #endif // SHILL_SERVICE_H_ |