- add sources.
[platform/framework/web/crosswalk.git] / src / jingle / notifier / listener / push_client.h
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.
4
5 #ifndef JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_
6 #define JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "jingle/notifier/listener/notification_defines.h"
12
13 namespace notifier {
14
15 struct NotifierOptions;
16 class PushClientObserver;
17
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();
24
25   // Creates a default non-blocking PushClient implementation from the
26   // given options.
27   static scoped_ptr<PushClient> CreateDefault(
28       const NotifierOptions& notifier_options);
29
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);
35
36   // Manage the list of observers for incoming notifications.
37   virtual void AddObserver(PushClientObserver* observer) = 0;
38   virtual void RemoveObserver(PushClientObserver* observer) = 0;
39
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;
44
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;
50
51   // Sends a notification (with no reliability guarantees).
52   virtual void SendNotification(const Notification& notification) = 0;
53
54   // Sends a ping (with no reliability guarantees).
55   virtual void SendPing() = 0;
56 };
57
58 }  // namespace notifier
59
60 #endif  // JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_