| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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 CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Fetches the device token that can be used for policy requests with the device | 24 // Fetches the device token that can be used for policy requests with the device |
| 25 // management server, either from disk if it already has been successfully | 25 // management server, either from disk if it already has been successfully |
| 26 // requested, otherwise from the device management server. An instance of the | 26 // requested, otherwise from the device management server. An instance of the |
| 27 // fetcher is shared as a singleton by all users of the device management token | 27 // fetcher is shared as a singleton by all users of the device management token |
| 28 // to ensure they all get the same token. | 28 // to ensure they all get the same token. |
| 29 class DeviceTokenFetcher | 29 class DeviceTokenFetcher |
| 30 : public NotificationObserver, | 30 : public NotificationObserver, |
| 31 public DeviceManagementBackend::DeviceRegisterResponseDelegate, | 31 public DeviceManagementBackend::DeviceRegisterResponseDelegate, |
| 32 public base::RefCountedThreadSafe<DeviceTokenFetcher> { | 32 public base::RefCountedThreadSafe<DeviceTokenFetcher> { |
| 33 public: | 33 public: |
| 34 // Requests to the device management server are sent through |backend|, which | 34 // Requests to the device management server are sent through |backend|. It |
| 35 // is passed in explicitly to simplify mocking of the backend for unit | 35 // obtains the authentication token from |token_service|. The fetcher stores |
| 36 // testing. The fetcher uses the directory in |token_dir| in which to store | 36 // the device token to |token_path| once it's retrieved from the server. |
| 37 // the device token once it's retrieved from the server. Should only be called | |
| 38 // by unit tests. | |
| 39 DeviceTokenFetcher(DeviceManagementBackend* backend, | 37 DeviceTokenFetcher(DeviceManagementBackend* backend, |
| 40 TokenService* token_service, | 38 TokenService* token_service, |
| 41 const FilePath& token_path); | 39 const FilePath& token_path); |
| 42 virtual ~DeviceTokenFetcher() {} | 40 virtual ~DeviceTokenFetcher() {} |
| 43 | 41 |
| 44 // NotificationObserver method overrides: | 42 // NotificationObserver method overrides: |
| 45 virtual void Observe(NotificationType type, | 43 virtual void Observe(NotificationType type, |
| 46 const NotificationSource& source, | 44 const NotificationSource& source, |
| 47 const NotificationDetails& details); | 45 const NotificationDetails& details); |
| 48 | 46 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // or it has been determined that there was an error during fetching. | 140 // or it has been determined that there was an error during fetching. |
| 143 base::WaitableEvent device_token_load_complete_event_; | 141 base::WaitableEvent device_token_load_complete_event_; |
| 144 | 142 |
| 145 // Registers the fetcher for notification of successful Gaia logins. | 143 // Registers the fetcher for notification of successful Gaia logins. |
| 146 NotificationRegistrar registrar_; | 144 NotificationRegistrar registrar_; |
| 147 }; | 145 }; |
| 148 | 146 |
| 149 } // namespace policy | 147 } // namespace policy |
| 150 | 148 |
| 151 #endif // CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ | 149 #endif // CHROME_BROWSER_POLICY_DEVICE_TOKEN_FETCHER_H_ |
| OLD | NEW |