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

Unified Diff: sync/notifier/gcm_network_channel.h

Issue 140513002: Client-to-server messages in GCMNetworkChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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
Index: sync/notifier/gcm_network_channel.h
diff --git a/sync/notifier/gcm_network_channel.h b/sync/notifier/gcm_network_channel.h
index b7d97fb41d76bcd176b01c2d60585e8e51ff16a6..c89a136988f3d2d63e8421875c676b31ad8dbd8a 100644
--- a/sync/notifier/gcm_network_channel.h
+++ b/sync/notifier/gcm_network_channel.h
@@ -10,17 +10,25 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "net/url_request/url_fetcher_delegate.h"
#include "sync/base/sync_export.h"
+#include "sync/notifier/gcm_network_channel_delegate.h"
#include "sync/notifier/sync_system_resources.h"
+#include "url/gurl.h"
+
+class GoogleServiceAuthError;
namespace syncer {
// GCMNetworkChannel is an implementation of SyncNetworkChannel that routes
// messages through GCMProfileService.
class SYNC_EXPORT_PRIVATE GCMNetworkChannel
rlarocque 2014/01/16 18:52:48 The threading code is starting to get complicated.
pavely 2014/01/17 00:44:39 Actually everything that happens to this class is
- : public SyncNetworkChannel {
+ : public SyncNetworkChannel,
+ public net::URLFetcherDelegate {
public:
- explicit GCMNetworkChannel();
+ explicit GCMNetworkChannel(
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ scoped_ptr<GCMNetworkChannelDelegate> delegate);
virtual ~GCMNetworkChannel();
@@ -29,7 +37,36 @@ class SYNC_EXPORT_PRIVATE GCMNetworkChannel
virtual void UpdateCredentials(const std::string& email,
const std::string& token) OVERRIDE;
+ // URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
private:
+ void OnRegisterComplete(const std::string& registration_id,
+ gcm::GCMClient::Result result);
+ void RequestAccessToken();
+ void OnGetTokenComplete(const GoogleServiceAuthError& error,
+ const std::string& token);
+ GURL BuildUrl();
+
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
+ scoped_ptr<GCMNetworkChannelDelegate> delegate_;
+
+ // Message is saved until all conditions are met: there is valid
+ // registration_id and access_token.
+ std::string encoded_message_;
+
+ // Access token is saved because in case of auth failure from server we need
+ // to invalidate it.
+ std::string access_token_;
+
+ // GCM registration_id is requested one at startup and never refreshed until
+ // next restart.
+ std::string registration_id_;
+
+ scoped_ptr<net::URLFetcher> fetcher_;
+
+ base::WeakPtrFactory<GCMNetworkChannel> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(GCMNetworkChannel);
};

Powered by Google App Engine
This is Rietveld 408576698