Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / sync / internal_api / sync_manager_impl.h
index 5cb3908..9402737 100644 (file)
 #include "sync/engine/all_status.h"
 #include "sync/engine/net/server_connection_manager.h"
 #include "sync/engine/sync_engine_event_listener.h"
-#include "sync/engine/traffic_recorder.h"
 #include "sync/internal_api/change_reorder_buffer.h"
 #include "sync/internal_api/debug_info_event_listener.h"
 #include "sync/internal_api/js_mutation_event_observer.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/sync_core_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"
@@ -33,6 +34,8 @@ namespace syncer {
 
 class ModelTypeRegistry;
 class SyncAPIServerConnectionManager;
+class SyncCore;
+class TypeDebugInfoObserver;
 class WriteNode;
 class WriteTransaction;
 
@@ -110,11 +113,22 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   virtual void SaveChanges() OVERRIDE;
   virtual void ShutdownOnSyncThread() OVERRIDE;
   virtual UserShare* GetUserShare() OVERRIDE;
-  virtual syncer::SyncCore* GetSyncCore() OVERRIDE;
+  virtual syncer::SyncCoreProxy* GetSyncCoreProxy() OVERRIDE;
   virtual const std::string cache_guid() OVERRIDE;
   virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
   virtual bool HasUnsyncedItems() OVERRIDE;
   virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
+  virtual ScopedVector<syncer::ProtocolEvent>
+      GetBufferedProtocolEvents() OVERRIDE;
+  virtual scoped_ptr<base::ListValue> GetAllNodesForType(
+      syncer::ModelType type) OVERRIDE;
+  virtual void RegisterDirectoryTypeDebugInfoObserver(
+      syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+  virtual void UnregisterDirectoryTypeDebugInfoObserver(
+      syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+  virtual bool HasDirectoryTypeDebugInfoObserver(
+      syncer::TypeDebugInfoObserver* observer) OVERRIDE;
+  virtual void RequestEmitDebugInfo() OVERRIDE;
 
   // SyncEncryptionHandler::Observer implementation.
   virtual void OnPassphraseRequired(
@@ -152,9 +166,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   // JsBackend implementation.
   virtual void SetJsEventHandler(
       const WeakHandle<JsEventHandler>& event_handler) OVERRIDE;
-  virtual void ProcessJsMessage(
-      const std::string& name, const JsArgList& args,
-      const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE;
 
   // DirectoryChangeDelegate implementation.
   // This listener is called upon completion of a syncable transaction, and
@@ -215,10 +226,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   base::TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type);
 
   typedef std::map<ModelType, NotificationInfo> NotificationInfoMap;
-  typedef JsArgList (SyncManagerImpl::*UnboundJsMessageHandler)(
-      const JsArgList&);
-  typedef base::Callback<JsArgList(const JsArgList&)> JsMessageHandler;
-  typedef std::map<std::string, JsMessageHandler> JsMessageHandlerMap;
 
   // Determine if the parents or predecessors differ between the old and new
   // versions of an entry.  Note that a node's index may change without its
@@ -264,17 +271,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   // Checks for server reachabilty and requests a nudge.
   void OnNetworkConnectivityChangedImpl();
 
-  // Helper function used only by the constructor.
-  void BindJsMessageHandler(
-    const std::string& name, UnboundJsMessageHandler unbound_message_handler);
-
-  // JS message handlers.
-  JsArgList GetAllNodes(const JsArgList& args);
-  JsArgList GetNodeSummariesById(const JsArgList& args);
-  JsArgList GetNodeDetailsById(const JsArgList& args);
-  JsArgList GetChildNodeIds(const JsArgList& args);
-  JsArgList GetClientServerTraffic(const JsArgList& args);
-
   syncable::Directory* directory();
 
   base::FilePath database_path_;
@@ -312,8 +308,9 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   // This state changes when entering or exiting a configuration cycle.
   scoped_ptr<ModelTypeRegistry> model_type_registry_;
 
-  // The main interface for non-blocking sync types.
+  // The main interface for non-blocking sync types and a thread-safe wrapper.
   scoped_ptr<SyncCore> sync_core_;
+  scoped_ptr<SyncCoreProxy> sync_core_proxy_;
 
   // A container of various bits of information used by the SyncScheduler to
   // create SyncSessions.  Must outlive the SyncScheduler.
@@ -350,7 +347,6 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   NotificationInfoMap notification_info_map_;
 
   // These are for interacting with chrome://sync-internals.
-  JsMessageHandlerMap js_message_handlers_;
   JsSyncManagerObserver js_sync_manager_observer_;
   JsMutationEventObserver js_mutation_event_observer_;
   JsSyncEncryptionHandlerObserver js_sync_encryption_handler_observer_;
@@ -358,9 +354,8 @@ class SYNC_EXPORT_PRIVATE SyncManagerImpl :
   // This is for keeping track of client events to send to the server.
   DebugInfoEventListener debug_info_event_listener_;
 
-  TrafficRecorder traffic_recorder_;
+  ProtocolEventBuffer protocol_event_buffer_;
 
-  Encryptor* encryptor_;
   scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler_;
   ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;