Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / sync / internal_api / debug_info_event_listener.h
index b7a187a..ba55650 100644 (file)
@@ -5,11 +5,12 @@
 #ifndef SYNC_INTERNAL_API_DEBUG_INFO_EVENT_LISTENER_H_
 #define SYNC_INTERNAL_API_DEBUG_INFO_EVENT_LISTENER_H_
 
-#include <queue>
+#include <deque>
 #include <string>
 
 #include "base/compiler_specific.h"
 #include "sync/base/sync_export.h"
+#include "sync/internal_api/public/base/model_type.h"
 #include "sync/internal_api/public/data_type_debug_info_listener.h"
 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
 #include "sync/internal_api/public/sync_encryption_handler.h"
@@ -22,8 +23,9 @@
 namespace syncer {
 
 // In order to track datatype association results, we need at least as many
-// entries as datatypes.
-const unsigned int kMaxEntries = 25;
+// entries as datatypes. Reserve additional space for other kinds of events that
+// are likely to happen during first sync or startup.
+const unsigned int kMaxEntries = MODEL_TYPE_COUNT + 10;
 
 // Listens to events and records them in a queue. And passes the events to
 // syncer when requested.
@@ -35,50 +37,48 @@ class SYNC_EXPORT_PRIVATE DebugInfoEventListener
       public DataTypeDebugInfoListener {
  public:
   DebugInfoEventListener();
-  virtual ~DebugInfoEventListener();
+  ~DebugInfoEventListener() override;
 
   // SyncManager::Observer implementation.
-  virtual void OnSyncCycleCompleted(
-    const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
-  virtual void OnInitializationComplete(
+  void OnSyncCycleCompleted(
+      const sessions::SyncSessionSnapshot& snapshot) override;
+  void OnInitializationComplete(
       const WeakHandle<JsBackend>& js_backend,
       const WeakHandle<DataTypeDebugInfoListener>& debug_listener,
-      bool success, ModelTypeSet restored_types) OVERRIDE;
-  virtual void OnConnectionStatusChange(
-      ConnectionStatus connection_status) OVERRIDE;
-  virtual void OnStopSyncingPermanently() OVERRIDE;
-  virtual void OnActionableError(
-      const SyncProtocolError& sync_error) OVERRIDE;
+      bool success,
+      ModelTypeSet restored_types) override;
+  void OnConnectionStatusChange(ConnectionStatus connection_status) override;
+  void OnActionableError(const SyncProtocolError& sync_error) override;
+  void OnMigrationRequested(ModelTypeSet types) override;
+  void OnProtocolEvent(const ProtocolEvent& event) override;
 
   // SyncEncryptionHandler::Observer implementation.
-  virtual void OnPassphraseRequired(
+  void OnPassphraseRequired(
       PassphraseRequiredReason reason,
-      const sync_pb::EncryptedData& pending_keys) OVERRIDE;
-  virtual void OnPassphraseAccepted() OVERRIDE;
-  virtual void OnBootstrapTokenUpdated(
-      const std::string& bootstrap_token,
-      BootstrapTokenType type) OVERRIDE;
-  virtual void OnEncryptedTypesChanged(
-      ModelTypeSet encrypted_types,
-      bool encrypt_everything) OVERRIDE;
-  virtual void OnEncryptionComplete() OVERRIDE;
-  virtual void OnCryptographerStateChanged(
-      Cryptographer* cryptographer) OVERRIDE;
-  virtual void OnPassphraseTypeChanged(
-      PassphraseType type,
-      base::Time explicit_passphrase_time) OVERRIDE;
+      const sync_pb::EncryptedData& pending_keys) override;
+  void OnPassphraseAccepted() override;
+  void OnBootstrapTokenUpdated(const std::string& bootstrap_token,
+                               BootstrapTokenType type) override;
+  void OnEncryptedTypesChanged(ModelTypeSet encrypted_types,
+                               bool encrypt_everything) override;
+  void OnEncryptionComplete() override;
+  void OnCryptographerStateChanged(Cryptographer* cryptographer) override;
+  void OnPassphraseTypeChanged(PassphraseType type,
+                               base::Time explicit_passphrase_time) override;
 
   // Sync manager events.
   void OnNudgeFromDatatype(ModelType datatype);
-  void OnIncomingNotification(const ObjectIdInvalidationMap& invalidations);
 
   // DebugInfoGetter implementation.
-  virtual void GetAndClearDebugInfo(sync_pb::DebugInfo* debug_info) OVERRIDE;
+  void GetDebugInfo(sync_pb::DebugInfo* debug_info) override;
+
+  // DebugInfoGetter implementation.
+  void ClearDebugInfo() override;
 
   // DataTypeDebugInfoListener implementation.
-  virtual void OnDataTypeConfigureComplete(
+  void OnDataTypeConfigureComplete(
       const std::vector<DataTypeConfigurationStats>& configuration_stats)
-      OVERRIDE;
+      override;
 
   // Returns a weak pointer to this object.
   base::WeakPtr<DataTypeDebugInfoListener> GetWeakPtr();
@@ -86,11 +86,14 @@ class SYNC_EXPORT_PRIVATE DebugInfoEventListener
  private:
   FRIEND_TEST_ALL_PREFIXES(DebugInfoEventListenerTest, VerifyEventsAdded);
   FRIEND_TEST_ALL_PREFIXES(DebugInfoEventListenerTest, VerifyQueueSize);
-  FRIEND_TEST_ALL_PREFIXES(DebugInfoEventListenerTest, VerifyGetAndClearEvents);
+  FRIEND_TEST_ALL_PREFIXES(DebugInfoEventListenerTest, VerifyGetEvents);
+  FRIEND_TEST_ALL_PREFIXES(DebugInfoEventListenerTest, VerifyClearEvents);
 
   void AddEventToQueue(const sync_pb::DebugEventInfo& event_info);
-  void CreateAndAddEvent(sync_pb::DebugEventInfo::SingletonEventType type);
-  std::queue<sync_pb::DebugEventInfo> events_;
+  void CreateAndAddEvent(sync_pb::SyncEnums::SingletonDebugEventType type);
+
+  typedef std::deque<sync_pb::DebugEventInfo> DebugEventInfoQueue;
+  DebugEventInfoQueue events_;
 
   // True indicates we had to drop one or more events to keep our limit of
   // |kMaxEntries|.