| OLD | NEW |
| (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 COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_ | |
| 6 #define COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "google_apis/gcm/gcm_client.h" | |
| 12 | |
| 13 class GoogleServiceAuthError; | |
| 14 | |
| 15 namespace syncer { | |
| 16 | |
| 17 // Delegate for GCMNetworkChannel. | |
| 18 // GCMNetworkChannel needs Register to register with GCM client and obtain gcm | |
| 19 // registration id. This id is used for building URL to cache invalidation | |
| 20 // endpoint. | |
| 21 // It needs RequestToken and InvalidateToken to get access token to include it | |
| 22 // in HTTP message to server. | |
| 23 // GCMNetworkChannel lives on IO thread therefore calls will be made on IO | |
| 24 // thread and callbacks should be invoked there as well. | |
| 25 class GCMNetworkChannelDelegate { | |
| 26 public: | |
| 27 typedef base::Callback<void(const GoogleServiceAuthError& error, | |
| 28 const std::string& token)> RequestTokenCallback; | |
| 29 typedef base::Callback<void(const std::string& registration_id, | |
| 30 gcm::GCMClient::Result result)> RegisterCallback; | |
| 31 typedef base::Callback<void(const std::string& message, | |
| 32 const std::string& echo_token)> MessageCallback; | |
| 33 | |
| 34 virtual ~GCMNetworkChannelDelegate() {} | |
| 35 | |
| 36 virtual void Initialize() = 0; | |
| 37 // Request access token. Callback should be called either with access token or | |
| 38 // error code. | |
| 39 virtual void RequestToken(RequestTokenCallback callback) = 0; | |
| 40 // Invalidate access token that was rejected by server. | |
| 41 virtual void InvalidateToken(const std::string& token) = 0; | |
| 42 | |
| 43 // Request registration_id from GCMService. Callback should be called with | |
| 44 // either registration id or error code. | |
| 45 virtual void Register(RegisterCallback callback) = 0; | |
| 46 // Provide callback for incoming messages from GCM. | |
| 47 virtual void SetMessageReceiver(MessageCallback callback) = 0; | |
| 48 }; | |
| 49 } // namespace syncer | |
| 50 | |
| 51 #endif // COMPONENTS_INVALIDATION_GCM_NETWORK_CHANNEL_DELEGATE_H_ | |
| OLD | NEW |