1 // Copyright 2015 The Chromium 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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_CLIENT_FACTORY_H
6 #define COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_CLIENT_FACTORY_H
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "components/proximity_auth/cryptauth/cryptauth_client.h"
11 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h"
12 #include "google_apis/gaia/oauth2_token_service.h"
13 #include "net/url_request/url_request_context_getter.h"
15 namespace proximity_auth
{
17 class CryptAuthClient
;
19 // Factory for creating CryptAuthClient instances. Because each CryptAuthClient
20 // instance can only be used for one API call, this class helps making multiple
21 // requests in sequence or parallel easier.
22 class CryptAuthClientFactory
{
24 // Creates the factory.
25 // |token_service|: Gets the user's access token.
26 // Needs to outlive this object.
27 // |account_id|: The account id of the user.
28 // |url_request_context|: The request context to make the HTTP requests.
29 // |device_classifier|: Contains basic device information of the client.
30 CryptAuthClientFactory(
31 OAuth2TokenService
* token_service
,
32 const std::string
& account_id
,
33 scoped_refptr
<net::URLRequestContextGetter
> url_request_context
,
34 const cryptauth::DeviceClassifier
& device_classifier
);
35 virtual ~CryptAuthClientFactory();
37 // Creates and returns a CryptAuthClient instance that is owned by the caller.
38 scoped_ptr
<CryptAuthClient
> CreateInstance();
41 OAuth2TokenService
* token_service_
;
42 const std::string account_id_
;
43 const scoped_refptr
<net::URLRequestContextGetter
> url_request_context_
;
44 const cryptauth::DeviceClassifier device_classifier_
;
46 DISALLOW_COPY_AND_ASSIGN(CryptAuthClientFactory
);
49 } // namespace proximity_auth
51 #endif // COMPONENTS_PROXIMITY_AUTH_CRYPT_AUTH_CLIENT_FACTORY_H