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