summaryrefslogtreecommitdiffstats
path: root/components/invalidation/gcm_network_channel_delegate.h
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 22:17:50 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-02 22:17:50 +0000
commit24c9ee594694a646eec1e5028cdd088cf4d73f9d (patch)
treece7cbdceee342e9af83a5002814d3481f800561a /components/invalidation/gcm_network_channel_delegate.h
parent4d488032475256413d3aa347407b77f21ca11633 (diff)
downloadchromium_src-24c9ee594694a646eec1e5028cdd088cf4d73f9d.zip
chromium_src-24c9ee594694a646eec1e5028cdd088cf4d73f9d.tar.gz
chromium_src-24c9ee594694a646eec1e5028cdd088cf4d73f9d.tar.bz2
Move some sync/notifier to components/invalidation
Moves many of the files in sync/notifier to components/invalidation. This change does not introduce any new dependencies. The relevant dependency rules both before and after this change should be: - chrome/browser/invalidation and chrome in general depend on components/invalidation. - components/invalidation depends on sync/notifier and sync in general. - sync/notifier, components/invalidation, and various parts of chrome all depend on sync/internal_api/public. The eventual goal is to move all of sync/notifier into components/invalidation. The invalidation-related parts of sync/internal_api/public should be moved to components/invalidation, too. This will allow us to remove the deopendencies from components/invalidation to sync, and remove sync's dependencies on cacheinvalidation and libjingle. This change is a regression in terms of shared library componentization. the files in the sync/notifier folder could be built as a shared library. The files in compononents/invalidation do not support this yet. The SYNC_EXPORT declarations in the moved files have been changed to INVALIDATION_EXPORT so as to not lose this information, but the macros are currently #defined to no-ops. This change does not attempt to rename any classes or namespaces. Many of the files ported from sync/notifier still use the syncer namespace. Some, like SyncSystemResources, still have names tied to their sync heritage. This will be addressed in future CLs. Some non-trivial or non-obvious changes include: - invalidator_state.h was moved to sync/internal_api/public/base so it could be shared by both sync/ and components/invalidation. This should be fixed in a future CL. - FromNotifierReason was split out of invalidator_state.h and moved to the newly-created components/invalidator_reason_util.h TBR=zea,rtenneti,mallinath,dcheng BUG=259559 Review URL: https://codereview.chromium.org/294123004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/invalidation/gcm_network_channel_delegate.h')
-rw-r--r--components/invalidation/gcm_network_channel_delegate.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/components/invalidation/gcm_network_channel_delegate.h b/components/invalidation/gcm_network_channel_delegate.h
new file mode 100644
index 0000000..5229dec
--- /dev/null
+++ b/components/invalidation/gcm_network_channel_delegate.h
@@ -0,0 +1,51 @@
+// 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 COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_
+#define COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "google_apis/gcm/gcm_client.h"
+
+class GoogleServiceAuthError;
+
+namespace syncer {
+
+// Delegate for GCMNetworkChannel.
+// GCMNetworkChannel needs Register to register with GCM client and obtain gcm
+// registration id. This id is used for building URL to cache invalidation
+// endpoint.
+// It needs RequestToken and InvalidateToken to get access token to include it
+// in HTTP message to server.
+// GCMNetworkChannel lives on IO thread therefore calls will be made on IO
+// thread and callbacks should be invoked there as well.
+class GCMNetworkChannelDelegate {
+ public:
+ typedef base::Callback<void(const GoogleServiceAuthError& error,
+ const std::string& token)> RequestTokenCallback;
+ typedef base::Callback<void(const std::string& registration_id,
+ gcm::GCMClient::Result result)> RegisterCallback;
+ typedef base::Callback<void(const std::string& message,
+ const std::string& echo_token)> MessageCallback;
+
+ virtual ~GCMNetworkChannelDelegate() {}
+
+ virtual void Initialize() = 0;
+ // Request access token. Callback should be called either with access token or
+ // error code.
+ virtual void RequestToken(RequestTokenCallback callback) = 0;
+ // Invalidate access token that was rejected by server.
+ virtual void InvalidateToken(const std::string& token) = 0;
+
+ // Request registration_id from GCMService. Callback should be called with
+ // either registration id or error code.
+ virtual void Register(RegisterCallback callback) = 0;
+ // Provide callback for incoming messages from GCM.
+ virtual void SetMessageReceiver(MessageCallback callback) = 0;
+};
+} // namespace syncer
+
+#endif // COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_