Index: chrome/browser/sync/notifier/sync_notifier_impl.h |
diff --git a/chrome/browser/sync/notifier/sync_notifier_impl.h b/chrome/browser/sync/notifier/sync_notifier_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ddaeb713decc1e3fd28634a945b1b41774acf7d5 |
--- /dev/null |
+++ b/chrome/browser/sync/notifier/sync_notifier_impl.h |
@@ -0,0 +1,86 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+ |
+#ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
+#define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |
+ |
+#include "chrome/browser/sync/notifier/state_writer.h" |
+#include "chrome/browser/sync/notifier/sync_notifier.h" |
+#include "chrome/browser/sync/syncable/model_type.h" |
+#include "jingle/notifier/base/notifier_options.h" |
+#include "jingle/notifier/listener/talk_mediator.h" |
+#include "jingle/notifier/listener/talk_mediator_impl.h" |
+ |
+namespace sync_notifier { |
+class ServerNotifierThread; |
+ |
+class SyncNotifierImpl |
+ : public SyncNotifier, |
+ public sync_notifier::StateWriter, |
+ public notifier::TalkMediator::Delegate { |
+ public: |
+ // Takes owner ship of notifier_options. |
+ explicit SyncNotifierImpl(notifier::NotifierOptions* notifier_options); |
+ |
+ virtual ~SyncNotifierImpl(); |
+ |
+ // TalkMediator::Delegate implementation. |
+ virtual void OnNotificationStateChange(bool notifications_enabled) { |
+ sync_notifier_callback_->OnNotificationStateChange(notifications_enabled); |
+ } |
+ |
+ virtual void OnIncomingNotification( |
+ const IncomingNotificationData& notification_data) { |
+ sync_notifier_callback_->OnIncomingNotification(notification_data); |
+ } |
+ |
+ virtual void OnOutgoingNotification() { |
+ sync_notifier_callback_->OnOutgoingNotification(); |
+ } |
+ |
+ // sync_notifier::StateWriter implementation. |
+ virtual void WriteState(const std::string& state) { |
+ sync_notifier_callback_->StoreCookie(state); |
+ } |
+ |
+ // SyncNotifier implementation |
+ virtual void Login( |
+ const std::string& email, const std::string& token, |
+ const std::string& state, |
+ SyncNotifierCallback* sync_notifier_callback); |
+ |
+ virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types); |
+ virtual void Logout(); |
+ |
+#if defined(UNIT_TEST) |
+ // P2P notification, still used by tests. |
+ void SendNotification(); |
akalin
2011/03/08 02:48:30
I think this should be part of the SyncNotifier in
Agrawal
2011/03/08 23:07:28
Added SendNotification to the interface.
|
+#endif |
+ private: |
+ // Login to the talk mediator with the given credentials. |
+ void TalkMediatorLogin( |
+ const std::string& email, const std::string& token); |
+ |
+ notifier::TalkMediator* talk_mediator() { return talk_mediator_.get(); } |
+ |
+ // Helper to handle the details of initializing the TalkMediator. |
+ // Must be called only after OpenDirectory() is called. |
+ void InitializeTalkMediator(const std::string& state, |
+ const notifier::NotifierOptions& notifier_options); |
+ |
+ // Notification (xmpp) handler. |
+ scoped_ptr<notifier::TalkMediator> talk_mediator_; |
+ syncable::ModelTypeSet enabled_types_; |
+ |
+ // Sync Notifier Callback. We do not take ownership of the object. |
+ SyncNotifierCallback* sync_notifier_callback_; |
+ |
+ ServerNotifierThread* server_notifier_thread_; |
+ notifier::NotifierOptions* notifier_options_; |
+}; |
+ |
+ |
+} |
+#endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_ |