| OLD | NEW |
| 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 COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ | 5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ |
| 6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ | 6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 | 12 |
| 13 namespace gcm { | 13 namespace gcm { |
| 14 class GCMDriver; | 14 class GCMDriver; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace audio_modem { |
| 22 class WhispernetClient; |
| 23 } |
| 24 |
| 21 namespace copresence { | 25 namespace copresence { |
| 22 | 26 |
| 23 class Message; | 27 class Message; |
| 24 class WhispernetClient; | |
| 25 | 28 |
| 26 // AUDIO_FAIL indicates that we weren't able to hear the audio token that | 29 // AUDIO_FAIL indicates that we weren't able to hear the audio token that |
| 27 // we were playing. | 30 // we were playing. |
| 28 enum CopresenceStatus { SUCCESS, FAIL, AUDIO_FAIL }; | 31 enum CopresenceStatus { SUCCESS, FAIL, AUDIO_FAIL }; |
| 29 | 32 |
| 30 // Callback type to send a status. | 33 // Callback type to send a status. |
| 31 using StatusCallback = base::Callback<void(CopresenceStatus)>; | 34 using StatusCallback = base::Callback<void(CopresenceStatus)>; |
| 32 | 35 |
| 33 // A delegate interface for users of Copresence. | 36 // A delegate interface for users of Copresence. |
| 34 class CopresenceDelegate { | 37 class CopresenceDelegate { |
| 35 public: | 38 public: |
| 36 // This method will be called when we have subscribed messages | 39 // This method will be called when we have subscribed messages |
| 37 // that need to be sent to their respective apps. | 40 // that need to be sent to their respective apps. |
| 38 virtual void HandleMessages( | 41 virtual void HandleMessages( |
| 39 const std::string& app_id, | 42 const std::string& app_id, |
| 40 const std::string& subscription_id, | 43 const std::string& subscription_id, |
| 41 const std::vector<Message>& messages) = 0; | 44 const std::vector<Message>& messages) = 0; |
| 42 | 45 |
| 43 virtual void HandleStatusUpdate(CopresenceStatus status) = 0; | 46 virtual void HandleStatusUpdate(CopresenceStatus status) = 0; |
| 44 | 47 |
| 45 // Thw URLRequestContextGetter must outlive the CopresenceManager. | 48 // Thw URLRequestContextGetter must outlive the CopresenceManager. |
| 46 virtual net::URLRequestContextGetter* GetRequestContext() const = 0; | 49 virtual net::URLRequestContextGetter* GetRequestContext() const = 0; |
| 47 | 50 |
| 48 virtual const std::string GetPlatformVersionString() const = 0; | 51 virtual const std::string GetPlatformVersionString() const = 0; |
| 49 | 52 |
| 50 virtual const std::string GetAPIKey(const std::string& app_id) const = 0; | 53 virtual const std::string GetAPIKey(const std::string& app_id) const = 0; |
| 51 | 54 |
| 52 // Thw WhispernetClient must outlive the CopresenceManager. | 55 // The WhispernetClient must outlive the CopresenceManager. |
| 53 virtual WhispernetClient* GetWhispernetClient() = 0; | 56 virtual audio_modem::WhispernetClient* GetWhispernetClient() = 0; |
| 54 | 57 |
| 55 // Clients may optionally provide a GCMDriver to receive messages from. | 58 // Clients may optionally provide a GCMDriver to receive messages from. |
| 56 // If no driver is available, this can return null. | 59 // If no driver is available, this can return null. |
| 57 virtual gcm::GCMDriver* GetGCMDriver() = 0; | 60 virtual gcm::GCMDriver* GetGCMDriver() = 0; |
| 58 | 61 |
| 59 // Get the copresence device ID for authenticated or anonymous calls, | 62 // Get the copresence device ID for authenticated or anonymous calls, |
| 60 // as specified. If none exists, return the empty string. | 63 // as specified. If none exists, return the empty string. |
| 61 virtual const std::string GetDeviceId(bool authenticated) = 0; | 64 virtual const std::string GetDeviceId(bool authenticated) = 0; |
| 62 | 65 |
| 63 // Save a copresence device ID for authenticated or anonymous calls. | 66 // Save a copresence device ID for authenticated or anonymous calls. |
| 64 // If the device ID is empty, any stored ID should be deleted. | 67 // If the device ID is empty, any stored ID should be deleted. |
| 65 virtual void SaveDeviceId(bool authenticated, | 68 virtual void SaveDeviceId(bool authenticated, |
| 66 const std::string& device_id) = 0; | 69 const std::string& device_id) = 0; |
| 67 | 70 |
| 68 protected: | 71 protected: |
| 69 virtual ~CopresenceDelegate() {} | 72 virtual ~CopresenceDelegate() {} |
| 70 }; | 73 }; |
| 71 | 74 |
| 72 } // namespace copresence | 75 } // namespace copresence |
| 73 | 76 |
| 74 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ | 77 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_DELEGATE_H_ |
| OLD | NEW |