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

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

Issue 225403021: Extract Profile-independent GCMService from GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore real IO thread in unit tests. Remove sources of flakiness by waiting instead of pumping whe… Created 6 years, 8 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
OLDNEW
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_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
6 #define CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_ 6 #define CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "chrome/browser/services/gcm/gcm_app_handler.h" 12 #include "chrome/browser/services/gcm/gcm_app_handler.h"
13 #include "google_apis/gaia/oauth2_token_service.h" 13 #include "google_apis/gaia/oauth2_token_service.h"
14 #include "google_apis/gcm/gcm_client.h" 14 #include "google_apis/gcm/gcm_client.h"
15 #include "sync/notifier/gcm_network_channel_delegate.h" 15 #include "sync/notifier/gcm_network_channel_delegate.h"
16 16
17 class IdentityProvider; 17 class IdentityProvider;
18 18
19 namespace base { 19 namespace base {
20 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
21 } // namespace base 21 } // namespace base
22 22
23 namespace gcm { 23 namespace gcm {
24 class GCMProfileService; 24 class GCMService;
25 } // namespace gcm 25 } // namespace gcm
26 26
27 namespace invalidation { 27 namespace invalidation {
28 28
29 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions 29 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions
30 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while 30 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while
31 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts 31 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts
32 // all function calls to GCMInvalidationBridge which does actual work to perform 32 // all function calls to GCMInvalidationBridge which does actual work to perform
33 // them. 33 // them.
34 class GCMInvalidationBridge : public gcm::GCMAppHandler, 34 class GCMInvalidationBridge : public gcm::GCMAppHandler,
35 public OAuth2TokenService::Consumer, 35 public OAuth2TokenService::Consumer,
36 public base::NonThreadSafe { 36 public base::NonThreadSafe {
37 public: 37 public:
38 class Core; 38 class Core;
39 39
40 GCMInvalidationBridge(gcm::GCMProfileService* gcm_profile_service, 40 GCMInvalidationBridge(gcm::GCMService* gcm_service,
41 IdentityProvider* identity_provider); 41 IdentityProvider* identity_provider);
42 virtual ~GCMInvalidationBridge(); 42 virtual ~GCMInvalidationBridge();
43 43
44 // OAuth2TokenService::Consumer implementation. 44 // OAuth2TokenService::Consumer implementation.
45 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 45 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
46 const std::string& access_token, 46 const std::string& access_token,
47 const base::Time& expiration_time) OVERRIDE; 47 const base::Time& expiration_time) OVERRIDE;
48 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 48 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
49 const GoogleServiceAuthError& error) OVERRIDE; 49 const GoogleServiceAuthError& error) OVERRIDE;
50 50
(...skipping 22 matching lines...) Expand all
73 void Register(syncer::GCMNetworkChannelDelegate::RegisterCallback callback); 73 void Register(syncer::GCMNetworkChannelDelegate::RegisterCallback callback);
74 74
75 void SubscribeForIncomingMessages(); 75 void SubscribeForIncomingMessages();
76 76
77 void RegisterFinished( 77 void RegisterFinished(
78 syncer::GCMNetworkChannelDelegate::RegisterCallback callback, 78 syncer::GCMNetworkChannelDelegate::RegisterCallback callback,
79 const std::string& registration_id, 79 const std::string& registration_id,
80 gcm::GCMClient::Result result); 80 gcm::GCMClient::Result result);
81 81
82 private: 82 private:
83 gcm::GCMProfileService* const gcm_profile_service_; 83 gcm::GCMService* const gcm_service_;
84 IdentityProvider* const identity_provider_; 84 IdentityProvider* const identity_provider_;
85 85
86 base::WeakPtr<Core> core_; 86 base::WeakPtr<Core> core_;
87 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_; 87 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_;
88 88
89 // Fields related to RequestToken function. 89 // Fields related to RequestToken function.
90 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 90 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
91 syncer::GCMNetworkChannelDelegate::RequestTokenCallback 91 syncer::GCMNetworkChannelDelegate::RequestTokenCallback
92 request_token_callback_; 92 request_token_callback_;
93 bool subscribed_for_incoming_messages_; 93 bool subscribed_for_incoming_messages_;
94 94
95 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_; 95 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge); 97 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge);
98 }; 98 };
99 99
100 } // namespace invalidation 100 } // namespace invalidation
101 101
102 #endif // CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_ 102 #endif // CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698