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