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 CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "google_apis/gaia/oauth2_token_service.h" | 10 #include "google_apis/gaia/oauth2_token_service.h" |
11 #include "sync/internal_api/public/sync_auth_provider.h" | 11 #include "sync/internal_api/public/sync_auth_provider.h" |
12 | 12 |
13 class ProfileOAuth2TokenService; | 13 class ProfileOAuth2TokenService; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
17 } // namespace base | 17 } // namespace base |
18 | 18 |
19 // ProfileSyncAuthProvider implements function for SyncAuthProvider. It doesn't | 19 // ProfileSyncAuthProvider implements function for SyncAuthProvider. It doesn't |
20 // inherit from SyncAuthProvider because it lives on UI thread while requests | 20 // inherit from SyncAuthProvider because it lives on UI thread while requests |
21 // originate from sync thread. SyncThreadProxy implements SyncAuthProvider and | 21 // originate from sync thread. SyncThreadProxy implements SyncAuthProvider and |
22 // forwards all requests. | 22 // forwards all requests. |
23 class ProfileSyncAuthProvider : public OAuth2TokenService::Consumer, | 23 class ProfileSyncAuthProvider : public OAuth2TokenService::Consumer, |
24 public base::NonThreadSafe { | 24 public base::NonThreadSafe { |
25 public: | 25 public: |
26 ProfileSyncAuthProvider(ProfileOAuth2TokenService* token_service, | 26 ProfileSyncAuthProvider(ProfileOAuth2TokenService* token_service, |
27 const std::string& account_id, | 27 const std::string& account_id, |
28 const std::string& scope); | 28 const std::string& scope); |
29 virtual ~ProfileSyncAuthProvider(); | 29 ~ProfileSyncAuthProvider() override; |
30 | 30 |
31 // OAuth2TokenService::Consumer implementation. | 31 // OAuth2TokenService::Consumer implementation. |
32 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 32 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
33 const std::string& access_token, | 33 const std::string& access_token, |
34 const base::Time& expiration_time) override; | 34 const base::Time& expiration_time) override; |
35 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 35 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
36 const GoogleServiceAuthError& error) override; | 36 const GoogleServiceAuthError& error) override; |
37 | 37 |
38 // Request access token from OAuth2TokenService. Once access token is received | 38 // Request access token from OAuth2TokenService. Once access token is received |
39 // result should be posted to callback on task_runner thread. | 39 // result should be posted to callback on task_runner thread. |
40 void RequestAccessToken( | 40 void RequestAccessToken( |
41 const syncer::SyncAuthProvider::RequestTokenCallback& callback, | 41 const syncer::SyncAuthProvider::RequestTokenCallback& callback, |
42 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 42 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
43 | 43 |
44 void InvalidateAccessToken(const std::string& token); | 44 void InvalidateAccessToken(const std::string& token); |
45 | 45 |
46 scoped_ptr<syncer::SyncAuthProvider> CreateProviderForSyncThread(); | 46 scoped_ptr<syncer::SyncAuthProvider> CreateProviderForSyncThread(); |
(...skipping 13 matching lines...) Expand all Loading... |
60 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 60 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
61 syncer::SyncAuthProvider::RequestTokenCallback request_token_callback_; | 61 syncer::SyncAuthProvider::RequestTokenCallback request_token_callback_; |
62 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; | 62 scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner_; |
63 | 63 |
64 base::WeakPtrFactory<ProfileSyncAuthProvider> weak_factory_; | 64 base::WeakPtrFactory<ProfileSyncAuthProvider> weak_factory_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(ProfileSyncAuthProvider); | 66 DISALLOW_COPY_AND_ASSIGN(ProfileSyncAuthProvider); |
67 }; | 67 }; |
68 | 68 |
69 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ | 69 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_AUTH_PROVIDER_H_ |
OLD | NEW |