summaryrefslogtreecommitdiffstats
path: root/sync/notifier/p2p_notifier.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 02:11:48 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 02:11:48 +0000
commitfc43868654630100e0f5dd7beef20464ea434679 (patch)
treec3cb020b3b42959736480e33ef7c0c6ee050ccee /sync/notifier/p2p_notifier.h
parent4593aa2be388ee1e028399d43e4e3f4d4491b5a2 (diff)
downloadchromium_src-fc43868654630100e0f5dd7beef20464ea434679.zip
chromium_src-fc43868654630100e0f5dd7beef20464ea434679.tar.gz
chromium_src-fc43868654630100e0f5dd7beef20464ea434679.tar.bz2
[Sync] Replace TalkMediator*/MediatorThread* with PushClient
Streamline methods of PushClient and its Observer subclass. Remove sync/protocol/service_constants.h and consolidate use of each constant in one place. Remove duplicate constant in cloud print code. BUG=76764 TEST= TBR=estade@chromium.org Review URL: https://chromiumcodereview.appspot.com/10398051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/notifier/p2p_notifier.h')
-rw-r--r--sync/notifier/p2p_notifier.h35
1 files changed, 22 insertions, 13 deletions
diff --git a/sync/notifier/p2p_notifier.h b/sync/notifier/p2p_notifier.h
index 093d023..24b0ab3 100644
--- a/sync/notifier/p2p_notifier.h
+++ b/sync/notifier/p2p_notifier.h
@@ -13,8 +13,10 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
-#include "jingle/notifier/listener/talk_mediator.h"
+#include "jingle/notifier/base/notifier_options.h"
+#include "jingle/notifier/listener/push_client.h"
#include "sync/notifier/sync_notifier.h"
#include "sync/syncable/model_type.h"
@@ -22,6 +24,9 @@ namespace base {
class MessageLoopProxy;
}
+namespace buzz {
+class XmppTaskParentInterface;
+} // namespace buzz
namespace sync_notifier {
@@ -81,17 +86,14 @@ class P2PNotificationData {
class P2PNotifier
: public SyncNotifier,
- public notifier::TalkMediator::Delegate {
+ public notifier::PushClient::Observer {
public:
- // Takes ownership of |talk_mediator|, but it is guaranteed that
- // |talk_mediator| is destroyed only when this object is destroyed.
- //
// The |send_notification_target| parameter was added to allow us to send
// self-notifications in some cases, but not others. The value should be
// either NOTIFY_ALL to send notifications to all clients, or NOTIFY_OTHERS
- // to send notificaitons to all clients except for the one that triggered the
+ // to send notifications to all clients except for the one that triggered the
// notification. See crbug.com/97780.
- P2PNotifier(notifier::TalkMediator* talk_mediator,
+ P2PNotifier(const notifier::NotifierOptions& notifier_options,
P2PNotificationTarget send_notification_target);
virtual ~P2PNotifier();
@@ -108,13 +110,20 @@ class P2PNotifier
virtual void SendNotification(
syncable::ModelTypeSet changed_types) OVERRIDE;
- // TalkMediator::Delegate implementation.
+ // PushClient::Delegate implementation.
virtual void OnNotificationStateChange(bool notifications_enabled) OVERRIDE;
virtual void OnIncomingNotification(
const notifier::Notification& notification) OVERRIDE;
- virtual void OnOutgoingNotification() OVERRIDE;
// For testing.
+
+ void SimulateConnectForTest(
+ base::WeakPtr<buzz::XmppTaskParentInterface> base_task);
+
+ // Any notifications sent after this is called will be reflected,
+ // i.e. will be treated as an incoming notification also.
+ void ReflectSentNotificationsForTest();
+
void SendNotificationDataForTest(
const P2PNotificationData& notification_data);
@@ -123,13 +132,13 @@ class P2PNotifier
ObserverList<SyncNotifierObserver> observer_list_;
- // The actual notification listener.
- scoped_ptr<notifier::TalkMediator> talk_mediator_;
+ // The XMPP push client.
+ notifier::PushClient push_client_;
// Our unique ID.
std::string unique_id_;
- // Whether we called Login() on |talk_mediator_| yet.
+ // Whether we have called UpdateCredentials() yet.
bool logged_in_;
- // Whether |talk_mediator_| has notified us that notifications are
+ // Whether |push_client_| has notified us that notifications are
// enabled.
bool notifications_enabled_;
// Which set of clients should be sent notifications.