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

Unified Diff: chrome/browser/sync/notifier/sync_notifier_impl.h

Issue 6621062: Refactor sync notifier out of sync api. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Minox fixes. Created 9 years, 9 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
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..2a9fc6d1611e4cef26c533cf6f676cfeec601cd2
--- /dev/null
+++ b/chrome/browser/sync/notifier/sync_notifier_impl.h
@@ -0,0 +1,76 @@
+// 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.
+//
+// Talk Mediator based implementation of the sync notifier interface.
+// Initializes the talk mediator and registers itself as the delegate.
+//
+// Example usage:
+// SyncNotifierImpl sync_notifier(...);
+// sync_notifier.Login(...);
+// ...
+// sync_notifier.Logout();
+
+#ifndef CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
+#define CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
+
+#include "base/observer_list.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:
+ explicit SyncNotifierImpl(const notifier::NotifierOptions& notifier_options);
+
+ virtual ~SyncNotifierImpl();
+
+ // TalkMediator::Delegate implementation.
+ virtual void OnNotificationStateChange(bool notifications_enabled);
+
+ virtual void OnIncomingNotification(
+ const IncomingNotificationData& notification_data);
+
+ virtual void OnOutgoingNotification() {}
+
+ // sync_notifier::StateWriter implementation.
+ virtual void WriteState(const std::string& state);
+
+ // SyncNotifier implementation
+ virtual void UpdateCredentials(
+ const std::string& email, const std::string& token);
+
+ virtual void SetState(const std::string& state);
+
+ virtual void AddObserver(SyncNotifierObserver* observer);
+ virtual void RemoveObserver(SyncNotifierObserver* observer);
+
+ virtual void UpdateEnabledTypes(const syncable::ModelTypeSet& types);
+ virtual void SendNotification();
+ private:
+ // Login to the talk mediator with the given credentials.
+ void TalkMediatorLogin(
+ const std::string& email, const std::string& token);
+
+ // Notification (xmpp) handler.
+ scoped_ptr<notifier::TalkMediator> talk_mediator_;
+ syncable::ModelTypeSet enabled_types_;
+ std::string state_;
+
+ notifier::NotifierOptions notifier_options_;
+ ServerNotifierThread* server_notifier_thread_;
+ ObserverList<SyncNotifierObserver> observer_list_;
+};
+
+
+}
+#endif // CHROME_BROWSER_SYNC_NOTIFIER_SYNC_NOTIFIER_IMPL_H_
« no previous file with comments | « chrome/browser/sync/notifier/sync_notifier_factory.cc ('k') | chrome/browser/sync/notifier/sync_notifier_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698