Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 1 | // Copyright 2014 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 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 5 | #ifndef BUFFET_DEVICE_REGISTRATION_INFO_H_ |
| 6 | #define BUFFET_DEVICE_REGISTRATION_INFO_H_ |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 7 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 8 | #include <map> |
| 9 | #include <memory> |
Alex Vakulenko | 5841c30 | 2014-07-23 10:49:49 -0700 | [diff] [blame] | 10 | #include <string> |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 11 | #include <utility> |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 12 | #include <vector> |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 13 | |
Alex Vakulenko | 132617a | 2014-09-04 08:59:43 -0700 | [diff] [blame] | 14 | #include <base/macros.h> |
Christopher Wiley | cd41966 | 2015-02-06 17:51:43 -0800 | [diff] [blame] | 15 | #include <base/memory/weak_ptr.h> |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 16 | #include <base/time/time.h> |
Christopher Wiley | 34eae04 | 2015-03-18 10:25:08 -0700 | [diff] [blame] | 17 | #include <base/timer/timer.h> |
Alex Vakulenko | e4879a2 | 2014-08-20 15:47:36 -0700 | [diff] [blame] | 18 | #include <chromeos/data_encoding.h> |
Alex Vakulenko | a8b95bc | 2014-08-27 11:00:57 -0700 | [diff] [blame] | 19 | #include <chromeos/errors/error.h> |
| 20 | #include <chromeos/http/http_transport.h> |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 21 | |
Christopher Wiley | 583d64b | 2015-03-24 14:30:17 -0700 | [diff] [blame] | 22 | #include "buffet/buffet_config.h" |
Alex Vakulenko | 9ea5a32 | 2015-04-17 15:35:34 -0700 | [diff] [blame] | 23 | #include "buffet/commands/command_manager.h" |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 24 | #include "buffet/notification/notification_channel.h" |
| 25 | #include "buffet/notification/notification_delegate.h" |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 26 | #include "buffet/registration_status.h" |
Christopher Wiley | 006e94e | 2014-05-02 13:44:48 -0700 | [diff] [blame] | 27 | #include "buffet/storage_interface.h" |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 28 | |
| 29 | namespace base { |
Vitaly Buka | 6ca3ad6 | 2015-03-11 17:03:23 -0700 | [diff] [blame] | 30 | class DictionaryValue; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 31 | } // namespace base |
| 32 | |
Anton Muhin | 332df19 | 2014-11-22 05:59:14 +0400 | [diff] [blame] | 33 | namespace chromeos { |
| 34 | class KeyValueStore; |
| 35 | } // namespace chromeos |
| 36 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 37 | namespace buffet { |
| 38 | |
Alex Vakulenko | 07216fe | 2014-09-19 15:31:09 -0700 | [diff] [blame] | 39 | class StateManager; |
Alex Vakulenko | 1f30a62 | 2014-07-23 11:13:15 -0700 | [diff] [blame] | 40 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 41 | extern const char kErrorDomainOAuth2[]; |
| 42 | extern const char kErrorDomainGCD[]; |
| 43 | extern const char kErrorDomainGCDServer[]; |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 44 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 45 | // The DeviceRegistrationInfo class represents device registration information. |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 46 | class DeviceRegistrationInfo : public NotificationDelegate { |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 47 | public: |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 48 | using OnRegistrationChangedCallback = |
| 49 | base::Callback<void(RegistrationStatus)>; |
Christopher Wiley | e0fdeee | 2015-02-07 18:29:32 -0800 | [diff] [blame] | 50 | |
Alex Vakulenko | cca2093 | 2014-08-20 17:35:12 -0700 | [diff] [blame] | 51 | DeviceRegistrationInfo( |
| 52 | const std::shared_ptr<CommandManager>& command_manager, |
Anton Muhin | b831562 | 2014-11-20 03:17:05 +0400 | [diff] [blame] | 53 | const std::shared_ptr<StateManager>& state_manager, |
Vitaly Buka | 867b088 | 2015-04-16 10:03:26 -0700 | [diff] [blame] | 54 | std::unique_ptr<BuffetConfig> config, |
Alex Vakulenko | cca2093 | 2014-08-20 17:35:12 -0700 | [diff] [blame] | 55 | const std::shared_ptr<chromeos::http::Transport>& transport, |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 56 | bool notifications_enabled); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 57 | |
Alex Vakulenko | 534a312 | 2015-05-22 15:48:53 -0700 | [diff] [blame] | 58 | ~DeviceRegistrationInfo() override; |
Anton Muhin | 332df19 | 2014-11-22 05:59:14 +0400 | [diff] [blame] | 59 | |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 60 | // Add callback to listen for changes in registration status. |
| 61 | void AddOnRegistrationChangedCallback( |
| 62 | const OnRegistrationChangedCallback& callback); |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 63 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 64 | // Returns the authorization HTTP header that can be used to talk |
| 65 | // to GCD server for authenticated device communication. |
Alex Vakulenko | 8e34d39 | 2014-04-29 11:02:56 -0700 | [diff] [blame] | 66 | // Make sure ValidateAndRefreshAccessToken() is called before this call. |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 67 | std::pair<std::string, std::string> GetAuthorizationHeader() const; |
| 68 | |
| 69 | // Returns the GCD service request URL. If |subpath| is specified, it is |
| 70 | // appended to the base URL which is normally |
| 71 | // https://www.googleapis.com/clouddevices/v1/". |
| 72 | // If |params| are specified, each key-value pair is formatted using |
Alex Vakulenko | e4879a2 | 2014-08-20 15:47:36 -0700 | [diff] [blame] | 73 | // chromeos::data_encoding::WebParamsEncode() and appended to URL as a query |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 74 | // string. |
| 75 | // So, calling: |
| 76 | // GetServiceURL("ticket", {{"key","apiKey"}}) |
| 77 | // will return something like: |
| 78 | // https://www.googleapis.com/clouddevices/v1/ticket?key=apiKey |
| 79 | std::string GetServiceURL( |
| 80 | const std::string& subpath = {}, |
Alex Vakulenko | e4879a2 | 2014-08-20 15:47:36 -0700 | [diff] [blame] | 81 | const chromeos::data_encoding::WebParamList& params = {}) const; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 82 | |
| 83 | // Returns a service URL to access the registered device on GCD server. |
| 84 | // The base URL used to construct the full URL looks like this: |
| 85 | // https://www.googleapis.com/clouddevices/v1/devices/<device_id>/ |
| 86 | std::string GetDeviceURL( |
| 87 | const std::string& subpath = {}, |
Alex Vakulenko | e4879a2 | 2014-08-20 15:47:36 -0700 | [diff] [blame] | 88 | const chromeos::data_encoding::WebParamList& params = {}) const; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 89 | |
| 90 | // Similar to GetServiceURL, GetOAuthURL() returns a URL of OAuth 2.0 server. |
| 91 | // The base URL used is https://accounts.google.com/o/oauth2/. |
| 92 | std::string GetOAuthURL( |
| 93 | const std::string& subpath = {}, |
Alex Vakulenko | e4879a2 | 2014-08-20 15:47:36 -0700 | [diff] [blame] | 94 | const chromeos::data_encoding::WebParamList& params = {}) const; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 95 | |
Alex Vakulenko | 6e3c30e | 2015-05-21 17:39:25 -0700 | [diff] [blame] | 96 | // Starts GCD device if credentials available. |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 97 | void Start(); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 98 | |
Nathan Bullock | 5e022a3 | 2015-04-08 15:13:07 -0400 | [diff] [blame] | 99 | // Checks whether we have credentials generated during registration. |
| 100 | bool HaveRegistrationCredentials(chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 101 | |
| 102 | // Gets the full device description JSON object, or nullptr if |
| 103 | // the device is not registered or communication failure. |
Vitaly Buka | 6ca3ad6 | 2015-03-11 17:03:23 -0700 | [diff] [blame] | 104 | std::unique_ptr<base::DictionaryValue> GetDeviceInfo( |
| 105 | chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 106 | |
Anton Muhin | beb1c5b | 2014-10-16 18:59:57 +0400 | [diff] [blame] | 107 | // Registers the device. |
Anton Muhin | beb1c5b | 2014-10-16 18:59:57 +0400 | [diff] [blame] | 108 | // Returns a device ID on success. |
Vitaly Buka | cad2e33 | 2015-05-14 23:33:32 -0700 | [diff] [blame] | 109 | std::string RegisterDevice(const std::string& ticket_id, |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 110 | chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 111 | |
Anton Muhin | 5975552 | 2014-11-05 21:30:12 +0400 | [diff] [blame] | 112 | // Updates a command. |
Anton Muhin | 5975552 | 2014-11-05 21:30:12 +0400 | [diff] [blame] | 113 | void UpdateCommand(const std::string& command_id, |
Alex Vakulenko | b211c10 | 2015-04-21 11:43:23 -0700 | [diff] [blame] | 114 | const base::DictionaryValue& command_patch, |
| 115 | const base::Closure& on_success, |
| 116 | const base::Closure& on_error); |
Anton Muhin | 5975552 | 2014-11-05 21:30:12 +0400 | [diff] [blame] | 117 | |
Vitaly Buka | fa94706 | 2015-04-17 00:41:31 -0700 | [diff] [blame] | 118 | // Updates basic device information. |
| 119 | bool UpdateDeviceInfo(const std::string& name, |
| 120 | const std::string& description, |
| 121 | const std::string& location, |
| 122 | chromeos::ErrorPtr* error); |
| 123 | |
Vitaly Buka | ff81db6 | 2015-05-14 21:25:45 -0700 | [diff] [blame] | 124 | // Updates GCD service configuration. Usually for testing. |
| 125 | bool UpdateServiceConfig(const std::string& client_id, |
| 126 | const std::string& client_secret, |
| 127 | const std::string& api_key, |
| 128 | const std::string& oauth_url, |
| 129 | const std::string& service_url, |
| 130 | chromeos::ErrorPtr* error); |
| 131 | |
Vitaly Buka | 72410b2 | 2015-05-13 13:48:59 -0700 | [diff] [blame] | 132 | const BuffetConfig& GetConfig() const { return *config_; } |
| 133 | |
| 134 | base::WeakPtr<DeviceRegistrationInfo> AsWeakPtr() { |
| 135 | return weak_factory_.GetWeakPtr(); |
| 136 | } |
| 137 | |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 138 | private: |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 139 | friend class DeviceRegistrationInfoTest; |
| 140 | |
Christopher Wiley | ba983c8 | 2015-03-05 16:32:23 -0800 | [diff] [blame] | 141 | // Cause DeviceRegistrationInfo to attempt to StartDevice on its own later. |
| 142 | void ScheduleStartDevice(const base::TimeDelta& later); |
| 143 | |
| 144 | // Starts device execution. |
| 145 | // Device will do required start up chores and then start to listen |
| 146 | // to new commands. |
| 147 | // TODO(antonm): Consider moving into some other class. |
| 148 | void StartDevice(chromeos::ErrorPtr* error, |
| 149 | const base::TimeDelta& retry_delay); |
| 150 | |
Nathan Bullock | 5e022a3 | 2015-04-08 15:13:07 -0400 | [diff] [blame] | 151 | // Checks for the valid device registration as well as refreshes |
| 152 | // the device access token, if available. |
| 153 | bool CheckRegistration(chromeos::ErrorPtr* error); |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 154 | |
Nathan Bullock | 5e022a3 | 2015-04-08 15:13:07 -0400 | [diff] [blame] | 155 | // If we currently have an access token and it doesn't look like it |
David Zeuthen | 390d191 | 2015-03-03 14:54:48 -0500 | [diff] [blame] | 156 | // has expired yet, returns true immediately. Otherwise calls |
| 157 | // RefreshAccessToken(). |
| 158 | bool MaybeRefreshAccessToken(chromeos::ErrorPtr* error); |
| 159 | |
| 160 | // Forcibly refreshes the access token. |
| 161 | bool RefreshAccessToken(chromeos::ErrorPtr* error); |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 162 | |
Nathan Bullock | 24d189f | 2015-02-26 13:09:18 -0500 | [diff] [blame] | 163 | // Parse the OAuth response, and sets registration status to |
| 164 | // kInvalidCredentials if our registration is no longer valid. |
| 165 | std::unique_ptr<base::DictionaryValue> ParseOAuthResponse( |
Alex Vakulenko | f71cca6 | 2015-04-09 15:17:17 -0700 | [diff] [blame] | 166 | chromeos::http::Response* response, chromeos::ErrorPtr* error); |
Nathan Bullock | 24d189f | 2015-02-26 13:09:18 -0500 | [diff] [blame] | 167 | |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 168 | // This attempts to open a notification channel. The channel needs to be |
Nathan Bullock | bea9113 | 2015-02-19 09:13:33 -0500 | [diff] [blame] | 169 | // restarted anytime the access_token is refreshed. |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 170 | void StartNotificationChannel(); |
Nathan Bullock | bea9113 | 2015-02-19 09:13:33 -0500 | [diff] [blame] | 171 | |
Anton Muhin | ac661ab | 2014-10-03 20:29:48 +0400 | [diff] [blame] | 172 | using CloudRequestCallback = |
| 173 | base::Callback<void(const base::DictionaryValue&)>; |
Alex Vakulenko | 0357c03 | 2015-01-06 16:32:31 -0800 | [diff] [blame] | 174 | using CloudRequestErrorCallback = |
| 175 | base::Callback<void(const chromeos::Error* error)>; |
Anton Muhin | ac661ab | 2014-10-03 20:29:48 +0400 | [diff] [blame] | 176 | |
| 177 | // Do a HTTPS request to cloud services. |
| 178 | // Handles many cases like reauthorization, 5xx HTTP response codes |
| 179 | // and device removal. It is a recommended way to do cloud API |
| 180 | // requests. |
| 181 | // TODO(antonm): Consider moving into some other class. |
| 182 | void DoCloudRequest( |
Anton Muhin | 233d2ee | 2014-10-22 15:16:24 +0400 | [diff] [blame] | 183 | const std::string& method, |
Anton Muhin | ac661ab | 2014-10-03 20:29:48 +0400 | [diff] [blame] | 184 | const std::string& url, |
| 185 | const base::DictionaryValue* body, |
Alex Vakulenko | 0357c03 | 2015-01-06 16:32:31 -0800 | [diff] [blame] | 186 | const CloudRequestCallback& success_callback, |
| 187 | const CloudRequestErrorCallback& error_callback); |
Anton Muhin | ac661ab | 2014-10-03 20:29:48 +0400 | [diff] [blame] | 188 | |
Christopher Wiley | ba983c8 | 2015-03-05 16:32:23 -0800 | [diff] [blame] | 189 | void UpdateDeviceResource(const base::Closure& on_success, |
| 190 | const CloudRequestErrorCallback& on_failure); |
Anton Muhin | c635c59 | 2014-10-28 21:48:08 +0400 | [diff] [blame] | 191 | |
Christopher Wiley | ba983c8 | 2015-03-05 16:32:23 -0800 | [diff] [blame] | 192 | void FetchCommands( |
| 193 | const base::Callback<void(const base::ListValue&)>& on_success, |
| 194 | const CloudRequestErrorCallback& on_failure); |
Anton Muhin | c635c59 | 2014-10-28 21:48:08 +0400 | [diff] [blame] | 195 | |
Christopher Wiley | ba983c8 | 2015-03-05 16:32:23 -0800 | [diff] [blame] | 196 | void AbortLimboCommands(const base::Closure& callback, |
Anton Muhin | c635c59 | 2014-10-28 21:48:08 +0400 | [diff] [blame] | 197 | const base::ListValue& commands); |
| 198 | |
| 199 | void PeriodicallyPollCommands(); |
| 200 | |
Anton Muhin | d07e206 | 2014-10-27 10:53:29 +0400 | [diff] [blame] | 201 | void PublishCommands(const base::ListValue& commands); |
Alex Vakulenko | 6e3c30e | 2015-05-21 17:39:25 -0700 | [diff] [blame] | 202 | void PublishCommand(const base::DictionaryValue& command); |
Anton Muhin | d07e206 | 2014-10-27 10:53:29 +0400 | [diff] [blame] | 203 | |
Anton Muhin | b831562 | 2014-11-20 03:17:05 +0400 | [diff] [blame] | 204 | void PublishStateUpdates(); |
| 205 | |
Alex Vakulenko | d1978d3 | 2015-04-29 17:33:26 -0700 | [diff] [blame] | 206 | // If unrecoverable error occurred (e.g. error parsing command instance), |
| 207 | // notify the server that the command is aborted by the device. |
| 208 | void NotifyCommandAborted(const std::string& command_id, |
| 209 | chromeos::ErrorPtr error); |
| 210 | |
| 211 | // When NotifyCommandAborted() fails, RetryNotifyCommandAborted() schedules |
| 212 | // a retry attempt. |
| 213 | void RetryNotifyCommandAborted(const std::string& command_id, |
| 214 | chromeos::ErrorPtr error); |
| 215 | |
Alex Vakulenko | 9ea5a32 | 2015-04-17 15:35:34 -0700 | [diff] [blame] | 216 | // Builds Cloud API devices collection REST resource which matches |
Anton Muhin | d8d3216 | 2014-10-02 20:37:00 +0400 | [diff] [blame] | 217 | // current state of the device including command definitions |
| 218 | // for all supported commands and current device state. |
| 219 | std::unique_ptr<base::DictionaryValue> BuildDeviceResource( |
| 220 | chromeos::ErrorPtr* error); |
| 221 | |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 222 | void SetRegistrationStatus(RegistrationStatus new_status); |
Vitaly Buka | 620bd7e | 2015-03-16 01:07:01 -0700 | [diff] [blame] | 223 | void SetDeviceId(const std::string& device_id); |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 224 | |
Alex Vakulenko | 9ea5a32 | 2015-04-17 15:35:34 -0700 | [diff] [blame] | 225 | // Callback called when command definitions are changed to re-publish new CDD. |
| 226 | void OnCommandDefsChanged(); |
Vitaly Buka | c903d28 | 2015-05-26 17:03:08 -0700 | [diff] [blame] | 227 | void OnStateChanged(); |
Alex Vakulenko | 9ea5a32 | 2015-04-17 15:35:34 -0700 | [diff] [blame] | 228 | |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 229 | // Overrides from NotificationDelegate |
| 230 | void OnConnected(const std::string& channel_name) override; |
| 231 | void OnDisconnected() override; |
| 232 | void OnPermanentFailure() override; |
Alex Vakulenko | 6e3c30e | 2015-05-21 17:39:25 -0700 | [diff] [blame] | 233 | void OnCommandCreated(const base::DictionaryValue& command) override; |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 234 | |
Nathan Bullock | d9e0bcd | 2015-02-11 11:36:39 -0500 | [diff] [blame] | 235 | // Transient data |
| 236 | std::string access_token_; |
| 237 | base::Time access_token_expiration_; |
Nathan Bullock | d9e0bcd | 2015-02-11 11:36:39 -0500 | [diff] [blame] | 238 | |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 239 | // HTTP transport used for communications. |
Alex Vakulenko | cca2093 | 2014-08-20 17:35:12 -0700 | [diff] [blame] | 240 | std::shared_ptr<chromeos::http::Transport> transport_; |
Alex Vakulenko | 1f30a62 | 2014-07-23 11:13:15 -0700 | [diff] [blame] | 241 | // Global command manager. |
| 242 | std::shared_ptr<CommandManager> command_manager_; |
Alex Vakulenko | 07216fe | 2014-09-19 15:31:09 -0700 | [diff] [blame] | 243 | // Device state manager. |
Anton Muhin | b831562 | 2014-11-20 03:17:05 +0400 | [diff] [blame] | 244 | std::shared_ptr<StateManager> state_manager_; |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 245 | |
Vitaly Buka | 867b088 | 2015-04-16 10:03:26 -0700 | [diff] [blame] | 246 | std::unique_ptr<BuffetConfig> config_; |
Anton Muhin | 332df19 | 2014-11-22 05:59:14 +0400 | [diff] [blame] | 247 | |
Alex Vakulenko | eedf3be | 2015-05-13 17:52:02 -0700 | [diff] [blame] | 248 | const bool notifications_enabled_; |
| 249 | std::unique_ptr<NotificationChannel> primary_notification_channel_; |
Christopher Wiley | d732bd0 | 2015-04-07 11:11:18 -0700 | [diff] [blame] | 250 | |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 251 | // Tracks our current registration status. |
Vitaly Buka | b055f15 | 2015-03-12 13:41:43 -0700 | [diff] [blame] | 252 | RegistrationStatus registration_status_{RegistrationStatus::kUnconfigured}; |
Christopher Wiley | c900e48 | 2015-02-15 15:42:04 -0800 | [diff] [blame] | 253 | |
Christopher Wiley | 34eae04 | 2015-03-18 10:25:08 -0700 | [diff] [blame] | 254 | base::RepeatingTimer<DeviceRegistrationInfo> command_poll_timer_; |
Christopher Wiley | 34eae04 | 2015-03-18 10:25:08 -0700 | [diff] [blame] | 255 | |
Vitaly Buka | ee7a3af | 2015-05-14 16:57:23 -0700 | [diff] [blame] | 256 | std::vector<OnRegistrationChangedCallback> on_registration_changed_; |
| 257 | |
Christopher Wiley | cd41966 | 2015-02-06 17:51:43 -0800 | [diff] [blame] | 258 | base::WeakPtrFactory<DeviceRegistrationInfo> weak_factory_{this}; |
Alex Vakulenko | 3cb466c | 2014-04-15 11:36:32 -0700 | [diff] [blame] | 259 | DISALLOW_COPY_AND_ASSIGN(DeviceRegistrationInfo); |
| 260 | }; |
| 261 | |
| 262 | } // namespace buffet |
| 263 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 264 | #endif // BUFFET_DEVICE_REGISTRATION_INFO_H_ |