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

Unified Diff: sync/notifier/non_blocking_invalidator.h

Issue 308413002: Revert of Move some sync/notifier to components/invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « sync/notifier/invalidator_test_template.cc ('k') | sync/notifier/non_blocking_invalidator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/non_blocking_invalidator.h
diff --git a/sync/notifier/non_blocking_invalidator.h b/sync/notifier/non_blocking_invalidator.h
new file mode 100644
index 0000000000000000000000000000000000000000..efdf89d5d09b4f395859812e187ab055c8c80e8b
--- /dev/null
+++ b/sync/notifier/non_blocking_invalidator.h
@@ -0,0 +1,114 @@
+// Copyright 2012 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.
+//
+// An implementation of SyncNotifier that wraps InvalidationNotifier
+// on its own thread.
+
+#ifndef SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
+#define SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "jingle/notifier/base/notifier_options.h"
+#include "sync/base/sync_export.h"
+#include "sync/notifier/invalidation_state_tracker.h"
+#include "sync/notifier/invalidator.h"
+#include "sync/notifier/invalidator_registrar.h"
+#include "sync/notifier/invalidator_state.h"
+#include "sync/notifier/unacked_invalidation_set.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace syncer {
+class SyncNetworkChannel;
+class GCMNetworkChannelDelegate;
+
+// Callback type for function that creates SyncNetworkChannel. This function
+// gets passed into NonBlockingInvalidator constructor.
+typedef base::Callback<scoped_ptr<SyncNetworkChannel>(void)>
+ NetworkChannelCreator;
+
+class SYNC_EXPORT_PRIVATE NonBlockingInvalidator
+ : public Invalidator,
+ public InvalidationStateTracker {
+ public:
+ // |invalidation_state_tracker| must be initialized and must outlive |this|.
+ NonBlockingInvalidator(
+ NetworkChannelCreator network_channel_creator,
+ const std::string& invalidator_client_id,
+ const UnackedInvalidationsMap& saved_invalidations,
+ const std::string& invalidation_bootstrap_data,
+ InvalidationStateTracker* invalidation_state_tracker,
+ const std::string& client_info,
+ const scoped_refptr<net::URLRequestContextGetter>&
+ request_context_getter);
+
+ virtual ~NonBlockingInvalidator();
+
+ // Invalidator implementation.
+ virtual void RegisterHandler(InvalidationHandler* handler) OVERRIDE;
+ virtual void UpdateRegisteredIds(InvalidationHandler* handler,
+ const ObjectIdSet& ids) OVERRIDE;
+ virtual void UnregisterHandler(InvalidationHandler* handler) OVERRIDE;
+ virtual InvalidatorState GetInvalidatorState() const OVERRIDE;
+ virtual void UpdateCredentials(
+ const std::string& email, const std::string& token) OVERRIDE;
+ virtual void RequestDetailedStatus(
+ base::Callback<void(const base::DictionaryValue&)> callback) const
+ OVERRIDE;
+
+ // Static functions to construct callback that creates network channel for
+ // SyncSystemResources. The goal is to pass network channel to invalidator at
+ // the same time not exposing channel specific parameters to invalidator and
+ // channel implementation to client of invalidator.
+ static NetworkChannelCreator MakePushClientChannelCreator(
+ const notifier::NotifierOptions& notifier_options);
+ static NetworkChannelCreator MakeGCMNetworkChannelCreator(
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ scoped_ptr<GCMNetworkChannelDelegate> delegate);
+
+ // These methods are forwarded to the invalidation_state_tracker_.
+ virtual void ClearAndSetNewClientId(const std::string& data) OVERRIDE;
+ virtual std::string GetInvalidatorClientId() const OVERRIDE;
+ virtual void SetBootstrapData(const std::string& data) OVERRIDE;
+ virtual std::string GetBootstrapData() const OVERRIDE;
+ virtual void SetSavedInvalidations(
+ const UnackedInvalidationsMap& states) OVERRIDE;
+ virtual UnackedInvalidationsMap GetSavedInvalidations() const OVERRIDE;
+ virtual void Clear() OVERRIDE;
+
+ private:
+ void OnInvalidatorStateChange(InvalidatorState state);
+ void OnIncomingInvalidation(const ObjectIdInvalidationMap& invalidation_map);
+ std::string GetOwnerName() const;
+
+ friend class NonBlockingInvalidatorTestDelegate;
+
+ struct InitializeOptions;
+ class Core;
+
+ InvalidatorRegistrar registrar_;
+ InvalidationStateTracker* invalidation_state_tracker_;
+
+ // The real guts of NonBlockingInvalidator, which allows this class to live
+ // completely on the parent thread.
+ scoped_refptr<Core> core_;
+ scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
+
+ base::WeakPtrFactory<NonBlockingInvalidator> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidator);
+};
+
+} // namespace syncer
+
+#endif // SYNC_NOTIFIER_NON_BLOCKING_INVALIDATOR_H_
« no previous file with comments | « sync/notifier/invalidator_test_template.cc ('k') | sync/notifier/non_blocking_invalidator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698