OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_IMPL_H_ | |
6 #define CHROME_BROWSER_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_IMPL_H_ | |
7 | |
8 #include "google_apis/gaia/oauth2_token_service.h" | |
9 #include "sync/notifier/gcm_network_channel_delegate.h" | |
10 | |
11 class Profile; | |
12 | |
13 namespace base { | |
14 class SingleThreadTaskRunner; | |
15 } // namespace base | |
16 | |
17 namespace invalidation { | |
18 | |
19 // Implementation of GCMNetworkChannelDelegate. | |
20 // GCMNetworkChannel lives in sync/notifier and therefore doesn't have access to | |
21 // ProfileOAuth2TokenService and GCMPRofileService that it needs. | |
22 // GCMNetworkChannelDelegate declares abstract interface for these functions | |
23 // which GCMNetworkChannelDelegateImpl implements in chrome/browser/invalidation | |
24 // where it has access to BrowserContext keyed services. | |
25 class GCMNetworkChannelDelegateImpl : public syncer::GCMNetworkChannelDelegate, | |
26 public OAuth2TokenService::Consumer { | |
27 public: | |
28 explicit GCMNetworkChannelDelegateImpl(Profile* profile); | |
29 virtual ~GCMNetworkChannelDelegateImpl(); | |
30 | |
31 // GCMNetworkChannelDelegate implementation. | |
32 virtual void Register(RegisterCallback callback) OVERRIDE; | |
33 virtual void RequestToken(RequestTokenCallback callback) OVERRIDE; | |
34 virtual void InvalidateToken(const std::string& token) OVERRIDE; | |
35 | |
36 // OAuth2TokenService::Consumer implementation. | |
37 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
38 const std::string& access_token, | |
39 const base::Time& expiration_time) OVERRIDE; | |
40 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
41 const GoogleServiceAuthError& error) OVERRIDE; | |
42 | |
43 private: | |
44 static void InvalidateTokenOnUIThread(Profile* profile, | |
45 const std::string& token); | |
46 | |
47 Profile* profile_; | |
48 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; | |
49 | |
50 // Fields related to RequestToken function. | |
51 std::string account_id_; | |
52 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | |
53 RequestTokenCallback request_token_callback_; | |
54 }; | |
55 | |
56 } // namespace invalidation | |
57 | |
58 #endif // CHROME_BROWSER_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_IMPL_H_ | |
OLD | NEW |