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

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

Issue 8586014: [Sync] Replace uses of ObserverListThreadSafe with WeakHandles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/non_blocking_invalidation_notifier.h
diff --git a/chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h b/chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h
index 351d67f37ad93d4bff827285301656d98c55881a..45da2f6e99a004e70d353949a06744df62eb3655 100644
--- a/chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h
+++ b/chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h
@@ -14,8 +14,11 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "chrome/browser/sync/notifier/invalidation_version_tracker.h"
#include "chrome/browser/sync/notifier/sync_notifier.h"
+#include "chrome/browser/sync/notifier/sync_notifier_observer.h"
#include "chrome/browser/sync/util/weak_handle.h"
#include "jingle/notifier/base/notifier_options.h"
@@ -25,7 +28,9 @@ class MessageLoopProxy;
namespace sync_notifier {
-class NonBlockingInvalidationNotifier : public SyncNotifier {
+class NonBlockingInvalidationNotifier
+ : public SyncNotifier,
+ public SyncNotifierObserver {
public:
// |invalidation_version_tracker| must be initialized.
NonBlockingInvalidationNotifier(
@@ -49,13 +54,26 @@ class NonBlockingInvalidationNotifier : public SyncNotifier {
virtual void SendNotification(
const syncable::ModelTypeSet& changed_types) OVERRIDE;
+ // SyncNotifierObserver implementation.
+ virtual void OnIncomingNotification(
+ const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE;
+ virtual void OnNotificationStateChange(bool notifications_enabled) OVERRIDE;
+ virtual void StoreState(const std::string& state) OVERRIDE;
+
private:
- // The real guts of NonBlockingInvalidationNotifier, which allows this class
- // to not be refcounted.
class Core;
+
+ base::WeakPtrFactory<NonBlockingInvalidationNotifier> weak_ptr_factory_;
+
+ // Our observers (which must live on the parent thread).
+ ObserverList<SyncNotifierObserver> observers_;
+
+ // The real guts of NonBlockingInvalidationNotifier, which allows
+ // this class to live completely on the parent thread.
scoped_refptr<Core> core_;
scoped_refptr<base::MessageLoopProxy> parent_message_loop_proxy_;
scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
+
DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidationNotifier);
};

Powered by Google App Engine
This is Rietveld 408576698