Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / jingle / notifier / listener / push_client.h
blobfd673373e201ee15c906dd8fd10b9dd3d57ef237
1 // Copyright (c) 2012 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 JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_
6 #define JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "jingle/notifier/listener/notification_defines.h"
13 namespace notifier {
15 struct NotifierOptions;
16 class PushClientObserver;
18 // A PushClient is an interface for classes that implement a push
19 // mechanism, where a client can push notifications to and receive
20 // notifications from other clients.
21 class PushClient {
22 public:
23 virtual ~PushClient();
25 // Creates a default non-blocking PushClient implementation from the
26 // given options.
27 static scoped_ptr<PushClient> CreateDefault(
28 const NotifierOptions& notifier_options);
30 // Creates a default blocking PushClient implementation from the
31 // given options. Must be called from the IO thread (according to
32 // |notifier_options|).
33 static scoped_ptr<PushClient> CreateDefaultOnIOThread(
34 const NotifierOptions& notifier_options);
36 // Manage the list of observers for incoming notifications.
37 virtual void AddObserver(PushClientObserver* observer) = 0;
38 virtual void RemoveObserver(PushClientObserver* observer) = 0;
40 // Implementors are required to have this take effect only on the
41 // next (re-)connection. Therefore, clients should call this before
42 // UpdateCredentials().
43 virtual void UpdateSubscriptions(const SubscriptionList& subscriptions) = 0;
45 // If not connected, connects with the given credentials. If
46 // already connected, the next connection attempt will use the given
47 // credentials.
48 virtual void UpdateCredentials(
49 const std::string& email, const std::string& token) = 0;
51 // Sends a notification (with no reliability guarantees).
52 virtual void SendNotification(const Notification& notification) = 0;
54 // Sends a ping (with no reliability guarantees).
55 virtual void SendPing() = 0;
58 } // namespace notifier
60 #endif // JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_