Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Side by Side Diff: chrome/browser/invalidation/gcm_invalidation_bridge.h

Issue 319223002: Componentize TiclInvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/invalidation/gcm_invalidation_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_INVALIDATION_BRIDGE_H_
6 #define CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
7
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "components/gcm_driver/gcm_app_handler.h"
13 #include "components/gcm_driver/gcm_client.h"
14 #include "components/invalidation/gcm_network_channel_delegate.h"
15 #include "google_apis/gaia/oauth2_token_service.h"
16
17 class IdentityProvider;
18
19 namespace base {
20 class SingleThreadTaskRunner;
21 } // namespace base
22
23 namespace gcm {
24 class GCMDriver;
25 } // namespace gcm
26
27 namespace invalidation {
28
29 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions
30 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while
31 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts
32 // all function calls to GCMInvalidationBridge which does actual work to perform
33 // them.
34 class GCMInvalidationBridge : public gcm::GCMAppHandler,
35 public OAuth2TokenService::Consumer,
36 public base::NonThreadSafe {
37 public:
38 class Core;
39
40 GCMInvalidationBridge(gcm::GCMDriver* gcm_driver,
41 IdentityProvider* identity_provider);
42 virtual ~GCMInvalidationBridge();
43
44 // OAuth2TokenService::Consumer implementation.
45 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
46 const std::string& access_token,
47 const base::Time& expiration_time) OVERRIDE;
48 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
49 const GoogleServiceAuthError& error) OVERRIDE;
50
51 // gcm::GCMEventRouter implementation.
52 virtual void ShutdownHandler() OVERRIDE;
53 virtual void OnMessage(const std::string& app_id,
54 const gcm::GCMClient::IncomingMessage& message)
55 OVERRIDE;
56 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
57 virtual void OnSendError(
58 const std::string& app_id,
59 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
60
61 scoped_ptr<syncer::GCMNetworkChannelDelegate> CreateDelegate();
62
63 void CoreInitializationDone(
64 base::WeakPtr<Core> core,
65 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner);
66
67 // Functions reflecting GCMNetworkChannelDelegate interface. These are called
68 // on UI thread to perform actual work.
69 void RequestToken(
70 syncer::GCMNetworkChannelDelegate::RequestTokenCallback callback);
71 void InvalidateToken(const std::string& token);
72
73 void Register(syncer::GCMNetworkChannelDelegate::RegisterCallback callback);
74
75 void SubscribeForIncomingMessages();
76
77 void RegisterFinished(
78 syncer::GCMNetworkChannelDelegate::RegisterCallback callback,
79 const std::string& registration_id,
80 gcm::GCMClient::Result result);
81
82 private:
83 gcm::GCMDriver* const gcm_driver_;
84 IdentityProvider* const identity_provider_;
85
86 base::WeakPtr<Core> core_;
87 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_;
88
89 // Fields related to RequestToken function.
90 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
91 syncer::GCMNetworkChannelDelegate::RequestTokenCallback
92 request_token_callback_;
93 bool subscribed_for_incoming_messages_;
94
95 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_;
96
97 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge);
98 };
99
100 } // namespace invalidation
101
102 #endif // CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/invalidation/gcm_invalidation_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698