Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(841)

Unified Diff: jingle/notifier/listener/push_client.h

Issue 10413014: [Sync] Turn notifier::PushClient into an interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jingle/notifier/listener/notification_defines.cc ('k') | jingle/notifier/listener/push_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/notifier/listener/push_client.h
diff --git a/jingle/notifier/listener/push_client.h b/jingle/notifier/listener/push_client.h
index fdac8ba35fc09533a9feb14a14c187254c309817..ea975a84992b8cda018118c454fbe81125624bdf 100644
--- a/jingle/notifier/listener/push_client.h
+++ b/jingle/notifier/listener/push_client.h
@@ -6,91 +6,44 @@
#define JINGLE_NOTIFIER_LISTENER_PUSH_CLIENT_H_
#include <string>
-#include <vector>
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "jingle/notifier/base/notifier_options.h"
+#include "base/memory/scoped_ptr.h"
#include "jingle/notifier/listener/notification_defines.h"
-namespace base {
-class MessageLoopProxy;
-} // namespace base
-
-namespace buzz {
-class XmppTaskParentInterface;
-} // namespace buzz
-
namespace notifier {
-// This class implements a client for the XMPP google:push protocol.
-//
-// This class must be used on a single thread.
+struct NotifierOptions;
+class PushClientObserver;
+
+// A PushClient is an interface for classes that implement a push
+// mechanism, where a client can push notifications to and receive
+// notifications from other clients.
class PushClient {
public:
- // An Observer is sent messages whenever a notification is received
- // or when the state of the push client changes.
- class Observer {
- public:
- // Called when the state of the push client changes. If
- // |notifications_enabled| is true, that means notifications can
- // be sent and received freely. If it is false, that means no
- // notifications can be sent or received.
- virtual void OnNotificationStateChange(bool notifications_enabled) = 0;
-
- // Called when a notification is received. The details of the
- // notification are in |notification|.
- virtual void OnIncomingNotification(const Notification& notification) = 0;
+ virtual ~PushClient();
- protected:
- virtual ~Observer();
- };
+ // Creates a default non-blocking PushClient implementation from the
+ // given options.
+ static scoped_ptr<PushClient> CreateDefault(
+ const NotifierOptions& notifier_options);
- explicit PushClient(const NotifierOptions& notifier_options);
- ~PushClient();
+ // Manage the list of observers for incoming notifications.
+ virtual void AddObserver(PushClientObserver* observer) = 0;
+ virtual void RemoveObserver(PushClientObserver* observer) = 0;
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
- // Takes effect only on the next (re-)connection. Therefore, you
- // probably want to call this before UpdateCredentials().
- void UpdateSubscriptions(const SubscriptionList& subscriptions);
+ // Implementors are required to have this take effect only on the
+ // next (re-)connection. Therefore, clients should call this before
+ // UpdateCredentials().
+ virtual void UpdateSubscriptions(const SubscriptionList& subscriptions) = 0;
// If not connected, connects with the given credentials. If
// already connected, the next connection attempt will use the given
// credentials.
- void UpdateCredentials(const std::string& email, const std::string& token);
-
- // Sends a notification. Can be called when notifications are
- // disabled; the notification will be sent when notifications become
- // enabled.
- void SendNotification(const Notification& notification);
-
- void SimulateOnNotificationReceivedForTest(
- const Notification& notification);
-
- void SimulateConnectAndSubscribeForTest(
- base::WeakPtr<buzz::XmppTaskParentInterface> base_task);
-
- void SimulateDisconnectForTest();
-
- void SimulateSubscriptionErrorForTest();
-
- // Any notifications sent after this is called will be reflected,
- // i.e. will be treated as an incoming notification also.
- void ReflectSentNotificationsForTest();
-
- private:
- class Core;
-
- // The real guts of PushClient, which allows this class to not be
- // refcounted.
- const scoped_refptr<Core> core_;
- const scoped_refptr<base::MessageLoopProxy> parent_message_loop_proxy_;
- const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
+ virtual void UpdateCredentials(
+ const std::string& email, const std::string& token) = 0;
- DISALLOW_COPY_AND_ASSIGN(PushClient);
+ // Sends a notification (with no reliability guarantees).
+ virtual void SendNotification(const Notification& notification) = 0;
};
} // namespace notifier
« no previous file with comments | « jingle/notifier/listener/notification_defines.cc ('k') | jingle/notifier/listener/push_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698