Index: components/proximity_auth/cryptauth/cryptauth_client_factory.h |
diff --git a/components/proximity_auth/cryptauth/cryptauth_client_factory.h b/components/proximity_auth/cryptauth/cryptauth_client_factory.h |
index c1dc95ba5f65edb61af9d045c46057fed01e563b..e1b9c805161a63048e9f35cbec3fdb0028e7497e 100644 |
--- a/components/proximity_auth/cryptauth/cryptauth_client_factory.h |
+++ b/components/proximity_auth/cryptauth/cryptauth_client_factory.h |
@@ -5,45 +5,40 @@ |
#ifndef COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_CLIENT_FACTORY_H |
#define COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_CLIENT_FACTORY_H |
-#include "base/macros.h" |
-#include "base/memory/weak_ptr.h" |
-#include "components/proximity_auth/cryptauth/cryptauth_client.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
#include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" |
-#include "google_apis/gaia/oauth2_token_service.h" |
-#include "net/url_request/url_request_context_getter.h" |
+ |
+class OAuth2TokenService; |
+ |
+namespace net { |
+class URLRequestContextGetter; |
+} |
namespace proximity_auth { |
class CryptAuthClient; |
-// Factory for creating CryptAuthClient instances. Because each CryptAuthClient |
-// instance can only be used for one API call, this class helps making multiple |
-// requests in sequence or parallel easier. |
+// Interface for creating CryptAuthClient instances. Because each |
+// CryptAuthClient instance can only be used for one API call, a factory helps |
+// making multiple requests in sequence or parallel easier. |
Ilya Sherman
2015/04/06 18:53:33
I don't see the advantage of creating an interface
Tim Song
2015/04/06 23:21:17
Discussed in person.
|
class CryptAuthClientFactory { |
public: |
- // Creates the factory. |
+ virtual ~CryptAuthClientFactory() {} |
+ |
+ virtual scoped_ptr<CryptAuthClient> CreateInstance() = 0; |
Ilya Sherman
2015/04/06 18:53:34
Why did you make this virtual?
Tim Song
2015/04/06 23:21:17
Discussed in person.
|
+ |
+ // Creates a default CryptAuthClientFactory. |
// |token_service|: Gets the user's access token. |
// Needs to outlive this object. |
// |account_id|: The account id of the user. |
// |url_request_context|: The request context to make the HTTP requests. |
// |device_classifier|: Contains basic device information of the client. |
- CryptAuthClientFactory( |
+ static scoped_ptr<CryptAuthClientFactory> CreateDefault( |
OAuth2TokenService* token_service, |
const std::string& account_id, |
scoped_refptr<net::URLRequestContextGetter> url_request_context, |
const cryptauth::DeviceClassifier& device_classifier); |
- virtual ~CryptAuthClientFactory(); |
- |
- // Creates and returns a CryptAuthClient instance that is owned by the caller. |
- scoped_ptr<CryptAuthClient> CreateInstance(); |
- |
- private: |
- OAuth2TokenService* token_service_; |
- const std::string account_id_; |
- const scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
- const cryptauth::DeviceClassifier device_classifier_; |
- |
- DISALLOW_COPY_AND_ASSIGN(CryptAuthClientFactory); |
}; |
} // namespace proximity_auth |