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

Unified Diff: chrome/browser/invalidation/gcm_invalidation_bridge.h

Issue 186623006: Refactor GCMNetworkChannelDelegateImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another rebase to resolve conflict with recent change. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/invalidation/gcm_invalidation_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/invalidation/gcm_invalidation_bridge.h
diff --git a/chrome/browser/invalidation/gcm_invalidation_bridge.h b/chrome/browser/invalidation/gcm_invalidation_bridge.h
new file mode 100644
index 0000000000000000000000000000000000000000..e8f920c7f2e80a9210c0838fffd77034e618e7b2
--- /dev/null
+++ b/chrome/browser/invalidation/gcm_invalidation_bridge.h
@@ -0,0 +1,83 @@
+// 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_INVALIDATION_BRIDGE_H_
+#define CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/non_thread_safe.h"
+#include "google_apis/gaia/oauth2_token_service.h"
+#include "google_apis/gcm/gcm_client.h"
+#include "sync/notifier/gcm_network_channel_delegate.h"
+
+class Profile;
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace invalidation {
+
+// GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions
+// needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while
+// Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts
+// all function calls to GCMInvalidationBridge which does actual work to perform
+// them.
+class GCMInvalidationBridge : public OAuth2TokenService::Consumer,
+ public base::NonThreadSafe {
+ public:
+ class Core;
+
+ explicit GCMInvalidationBridge(Profile* profile);
+ virtual ~GCMInvalidationBridge();
+
+ // 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;
+
+ scoped_ptr<syncer::GCMNetworkChannelDelegate> CreateDelegate();
+
+ void CoreInitializationDone(
+ base::WeakPtr<Core> core,
+ scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner);
+
+ // Functions reflecting GCMNetworkChannelDelegate interface. These are called
+ // on UI thread to perform actual work.
+ void RequestToken(
+ syncer::GCMNetworkChannelDelegate::RequestTokenCallback callback);
+ void InvalidateToken(const std::string& token);
+
+ void Register(syncer::GCMNetworkChannelDelegate::RegisterCallback callback);
+
+ void RegisterFinished(
+ syncer::GCMNetworkChannelDelegate::RegisterCallback callback,
+ const std::string& registration_id,
+ gcm::GCMClient::Result result);
+
+ private:
+ // GCMInvalidationBridge is owned by TiclInvalidationService therefore it is
+ // expected that profile_ pointer is valid throughout lifetime of this object.
+ Profile* profile_;
+
+ base::WeakPtr<Core> core_;
+ scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_;
+
+ // Fields related to RequestToken function.
+ scoped_ptr<OAuth2TokenService::Request> access_token_request_;
+ syncer::GCMNetworkChannelDelegate::RequestTokenCallback
+ request_token_callback_;
+
+ base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge);
+};
+
+} // namespace invalidation
+
+#endif // CHROME_BROWSER_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
« 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