Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / sync / internal_api / sync_manager_impl.h
index dd6e191..535ccef 100644 (file)
@@ -12,6 +12,7 @@
 #include "sync/base/sync_export.h"
 #include "sync/engine/all_status.h"
 #include "sync/engine/net/server_connection_manager.h"
+#include "sync/engine/nudge_handler.h"
 #include "sync/engine/sync_engine_event_listener.h"
 #include "sync/internal_api/change_reorder_buffer.h"
 #include "sync/internal_api/debug_info_event_listener.h"
 #include "sync/internal_api/js_sync_encryption_handler_observer.h"
 #include "sync/internal_api/js_sync_manager_observer.h"
 #include "sync/internal_api/protocol_event_buffer.h"
-#include "sync/internal_api/public/base/invalidator_state.h"
-#include "sync/internal_api/public/sync_core_proxy.h"
+#include "sync/internal_api/public/sync_context_proxy.h"
 #include "sync/internal_api/public/sync_manager.h"
 #include "sync/internal_api/public/user_share.h"
 #include "sync/internal_api/sync_encryption_handler_impl.h"
 #include "sync/js/js_backend.h"
-#include "sync/notifier/invalidation_handler.h"
 #include "sync/syncable/directory_change_delegate.h"
 #include "sync/util/cryptographer.h"
 #include "sync/util/time.h"
 
+class GURL;
+
 namespace syncer {
 
 class ModelTypeRegistry;
 class SyncAPIServerConnectionManager;
-class SyncCore;
+class SyncContext;
 class TypeDebugInfoObserver;
 class WriteNode;
 class WriteTransaction;
@@ -51,41 +52,23 @@ class SyncSessionContext;
 //
 // Unless stated otherwise, all methods of SyncManager should be called on the
 // same thread.
-class SYNC_EXPORT_PRIVATE SyncManagerImpl :
-    public SyncManager,
-    public net::NetworkChangeNotifier::IPAddressObserver,
-    public net::NetworkChangeNotifier::ConnectionTypeObserver,
-    public JsBackend,
-    public SyncEngineEventListener,
-    public ServerConnectionEventListener,
-    public syncable::DirectoryChangeDelegate,
-    public SyncEncryptionHandler::Observer {
+class SYNC_EXPORT_PRIVATE SyncManagerImpl
+    : public SyncManager,
+      public net::NetworkChangeNotifier::IPAddressObserver,
+      public net::NetworkChangeNotifier::ConnectionTypeObserver,
+      public JsBackend,
+      public SyncEngineEventListener,
+      public ServerConnectionEventListener,
+      public syncable::DirectoryChangeDelegate,
+      public SyncEncryptionHandler::Observer,
+      public NudgeHandler {
  public:
   // Create an uninitialized SyncManager.  Callers must Init() before using.
   explicit SyncManagerImpl(const std::string& name);
   virtual ~SyncManagerImpl();
 
   // SyncManager implementation.
-  virtual void Init(
-      const base::FilePath& database_location,
-      const WeakHandle<JsEventHandler>& event_handler,
-      const std::string& sync_server_and_path,
-      int sync_server_port,
-      bool use_ssl,
-      scoped_ptr<HttpPostProviderFactory> post_factory,
-      const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
-      ExtensionsActivity* extensions_activity,
-      SyncManager::ChangeDelegate* change_delegate,
-      const SyncCredentials& credentials,
-      const std::string& invalidator_client_id,
-      const std::string& restored_key_for_bootstrapping,
-      const std::string& restored_keystore_key_for_bootstrapping,
-      InternalComponentsFactory* internal_components_factory,
-      Encryptor* encryptor,
-      scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
-      ReportUnrecoverableErrorFunction
-          report_unrecoverable_error_function,
-      CancelationSignal* cancelation_signal) OVERRIDE;
+  virtual void Init(InitArgs* args) OVERRIDE;
   virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
   virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
       ModelTypeSet types) OVERRIDE;
@@ -102,17 +85,17 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
       const ModelSafeRoutingInfo& new_routing_info,
       const base::Closure& ready_task,
       const base::Closure& retry_task) OVERRIDE;
-  virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
+  virtual void SetInvalidatorEnabled(bool invalidator_enabled) OVERRIDE;
   virtual void OnIncomingInvalidation(
-      const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
-  virtual std::string GetOwnerName() const OVERRIDE;
+      syncer::ModelType type,
+      scoped_ptr<InvalidationInterface> invalidation) OVERRIDE;
   virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE;
   virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE;
   virtual SyncStatus GetDetailedStatus() const OVERRIDE;
   virtual void SaveChanges() OVERRIDE;
-  virtual void ShutdownOnSyncThread() OVERRIDE;
+  virtual void ShutdownOnSyncThread(ShutdownReason reason) OVERRIDE;
   virtual UserShare* GetUserShare() OVERRIDE;
-  virtual syncer::SyncCoreProxy* GetSyncCoreProxy() OVERRIDE;
+  virtual syncer::SyncContextProxy* GetSyncContextProxy() OVERRIDE;
   virtual const std::string cache_guid() OVERRIDE;
   virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
   virtual bool HasUnsyncedItems() OVERRIDE;
@@ -194,6 +177,11 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   virtual void OnConnectionTypeChanged(
       net::NetworkChangeNotifier::ConnectionType) OVERRIDE;
 
+  // NudgeHandler implementation.
+  virtual void NudgeForInitialDownload(syncer::ModelType type) OVERRIDE;
+  virtual void NudgeForCommit(syncer::ModelType type) OVERRIDE;
+  virtual void NudgeForRefresh(syncer::ModelType type) OVERRIDE;
+
   const SyncScheduler* scheduler() const;
 
   bool GetHasInvalidAuthTokenForTest() const;
@@ -206,8 +194,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
  private:
   friend class SyncManagerTest;
   FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest);
-  FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnNotificationStateChange);
-  FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnIncomingNotification);
   FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, PurgeDisabledTypes);
   FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, PurgeUnappliedTypes);
 
@@ -308,8 +294,8 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   scoped_ptr<ModelTypeRegistry> model_type_registry_;
 
   // The main interface for non-blocking sync types and a thread-safe wrapper.
-  scoped_ptr<SyncCore> sync_core_;
-  scoped_ptr<SyncCoreProxy> sync_core_proxy_;
+  scoped_ptr<SyncContext> sync_context_;
+  scoped_ptr<SyncContextProxy> sync_context_proxy_;
 
   // A container of various bits of information used by the SyncScheduler to
   // create SyncSessions.  Must outlive the SyncScheduler.
@@ -339,8 +325,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
 
   bool observing_network_connectivity_changes_;
 
-  InvalidatorState invalidator_state_;
-
   // Map used to store the notification info to be displayed in
   // about:sync page.
   NotificationInfoMap notification_info_map_;