| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H | 6 #define COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" | 10 #include "components/proximity_auth/cryptauth/cryptauth_access_token_fetcher.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class CryptAuthClientImpl : public CryptAuthClient { | 23 class CryptAuthClientImpl : public CryptAuthClient { |
| 24 public: | 24 public: |
| 25 typedef base::Callback<void(const std::string&)> ErrorCallback; | 25 typedef base::Callback<void(const std::string&)> ErrorCallback; |
| 26 | 26 |
| 27 // Creates the client using |url_request_context| to make the HTTP request | 27 // Creates the client using |url_request_context| to make the HTTP request |
| 28 // through |api_call_flow|. CryptAuthClientImpl takes ownership of | 28 // through |api_call_flow|. CryptAuthClientImpl takes ownership of |
| 29 // |access_token_fetcher|, which provides the access token authorizing | 29 // |access_token_fetcher|, which provides the access token authorizing |
| 30 // CryptAuth requests. The |device_classifier| argument contains basic device | 30 // CryptAuth requests. The |device_classifier| argument contains basic device |
| 31 // information of the caller (e.g. version and device type). | 31 // information of the caller (e.g. version and device type). |
| 32 CryptAuthClientImpl( | 32 CryptAuthClientImpl( |
| 33 scoped_ptr<CryptAuthApiCallFlow> api_call_flow, | 33 std::unique_ptr<CryptAuthApiCallFlow> api_call_flow, |
| 34 scoped_ptr<CryptAuthAccessTokenFetcher> access_token_fetcher, | 34 std::unique_ptr<CryptAuthAccessTokenFetcher> access_token_fetcher, |
| 35 scoped_refptr<net::URLRequestContextGetter> url_request_context, | 35 scoped_refptr<net::URLRequestContextGetter> url_request_context, |
| 36 const cryptauth::DeviceClassifier& device_classifier); | 36 const cryptauth::DeviceClassifier& device_classifier); |
| 37 ~CryptAuthClientImpl() override; | 37 ~CryptAuthClientImpl() override; |
| 38 | 38 |
| 39 // CryptAuthClient: | 39 // CryptAuthClient: |
| 40 void GetMyDevices(const cryptauth::GetMyDevicesRequest& request, | 40 void GetMyDevices(const cryptauth::GetMyDevicesRequest& request, |
| 41 const GetMyDevicesCallback& callback, | 41 const GetMyDevicesCallback& callback, |
| 42 const ErrorCallback& error_callback) override; | 42 const ErrorCallback& error_callback) override; |
| 43 void FindEligibleUnlockDevices( | 43 void FindEligibleUnlockDevices( |
| 44 const cryptauth::FindEligibleUnlockDevicesRequest& request, | 44 const cryptauth::FindEligibleUnlockDevicesRequest& request, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // return the result. | 81 // return the result. |
| 82 template <class ResponseProto> | 82 template <class ResponseProto> |
| 83 void OnFlowSuccess( | 83 void OnFlowSuccess( |
| 84 const base::Callback<void(const ResponseProto&)>& result_callback, | 84 const base::Callback<void(const ResponseProto&)>& result_callback, |
| 85 const std::string& serialized_response); | 85 const std::string& serialized_response); |
| 86 | 86 |
| 87 // Called when the current API call fails at any step. | 87 // Called when the current API call fails at any step. |
| 88 void OnApiCallFailed(const std::string& error_message); | 88 void OnApiCallFailed(const std::string& error_message); |
| 89 | 89 |
| 90 // Constructs and executes the actual HTTP request. | 90 // Constructs and executes the actual HTTP request. |
| 91 scoped_ptr<CryptAuthApiCallFlow> api_call_flow_; | 91 std::unique_ptr<CryptAuthApiCallFlow> api_call_flow_; |
| 92 | 92 |
| 93 // Fetches the access token authorizing the API calls. | 93 // Fetches the access token authorizing the API calls. |
| 94 scoped_ptr<CryptAuthAccessTokenFetcher> access_token_fetcher_; | 94 std::unique_ptr<CryptAuthAccessTokenFetcher> access_token_fetcher_; |
| 95 | 95 |
| 96 // The context for network requests. | 96 // The context for network requests. |
| 97 scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 97 scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
| 98 | 98 |
| 99 // Contains basic device info of the client making the request that is sent to | 99 // Contains basic device info of the client making the request that is sent to |
| 100 // CryptAuth with each API call. | 100 // CryptAuth with each API call. |
| 101 const cryptauth::DeviceClassifier device_classifier_; | 101 const cryptauth::DeviceClassifier device_classifier_; |
| 102 | 102 |
| 103 // True if an API call has been started. Remains true even after the API call | 103 // True if an API call has been started. Remains true even after the API call |
| 104 // completes. | 104 // completes. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 127 // |url_request_context|: The request context to make the HTTP requests. | 127 // |url_request_context|: The request context to make the HTTP requests. |
| 128 // |device_classifier|: Contains basic device information of the client. | 128 // |device_classifier|: Contains basic device information of the client. |
| 129 CryptAuthClientFactoryImpl( | 129 CryptAuthClientFactoryImpl( |
| 130 OAuth2TokenService* token_service, | 130 OAuth2TokenService* token_service, |
| 131 const std::string& account_id, | 131 const std::string& account_id, |
| 132 scoped_refptr<net::URLRequestContextGetter> url_request_context, | 132 scoped_refptr<net::URLRequestContextGetter> url_request_context, |
| 133 const cryptauth::DeviceClassifier& device_classifier); | 133 const cryptauth::DeviceClassifier& device_classifier); |
| 134 ~CryptAuthClientFactoryImpl() override; | 134 ~CryptAuthClientFactoryImpl() override; |
| 135 | 135 |
| 136 // CryptAuthClientFactory: | 136 // CryptAuthClientFactory: |
| 137 scoped_ptr<CryptAuthClient> CreateInstance() override; | 137 std::unique_ptr<CryptAuthClient> CreateInstance() override; |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 OAuth2TokenService* token_service_; | 140 OAuth2TokenService* token_service_; |
| 141 const std::string account_id_; | 141 const std::string account_id_; |
| 142 const scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 142 const scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
| 143 const cryptauth::DeviceClassifier device_classifier_; | 143 const cryptauth::DeviceClassifier device_classifier_; |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(CryptAuthClientFactoryImpl); | 145 DISALLOW_COPY_AND_ASSIGN(CryptAuthClientFactoryImpl); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 } // namespace proximity_auth | 148 } // namespace proximity_auth |
| 149 | 149 |
| 150 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H | 150 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPTAUTH_CLIENT_IMPL_H |
| OLD | NEW |