| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ | 5 #ifndef COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ |
| 6 #define COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ | 6 #define COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "components/sync/base/model_type.h" | 12 #include "components/sync/base/model_type.h" |
| 14 #include "components/sync/model/model_type_sync_bridge.h" | 13 #include "components/sync/model/model_type_sync_bridge.h" |
| 15 #include "components/sync/model_impl/shared_model_type_processor.h" | 14 #include "components/sync/model_impl/shared_model_type_processor.h" |
| 16 | 15 |
| 17 namespace syncer { | 16 namespace syncer { |
| 18 | 17 |
| 19 // This class holds static functions used for extracting debug information for a | 18 // This class holds static functions used for extracting debug information for a |
| 20 // model type. They should be run on the model thread. These functions are | 19 // model type. They should be run on the model thread. These functions are |
| 21 // static so they can be posted to from the UI thread, and they live inside a | 20 // static so they can be posted to from the UI thread, and they live inside a |
| 22 // class because it is a friend class to SharedModelTypeProcessor. | 21 // class because it is a friend class to SharedModelTypeProcessor. |
| 23 class ModelTypeDebugInfo { | 22 class ModelTypeDebugInfo { |
| 24 public: | 23 public: |
| 25 // Returns a ListValue representing all nodes for the type to |callback|. | 24 // Returns a ListValue representing all nodes for the type to |callback|. |
| 26 // Used for populating nodes in Sync Node Browser of chrome://sync-internals. | 25 // Used for populating nodes in Sync Node Browser of chrome://sync-internals. |
| 27 static void GetAllNodes( | 26 static void GetAllNodes( |
| 28 const base::WeakPtr<ModelTypeSyncBridge>& bridge, | |
| 29 const base::Callback<void(const ModelType, | 27 const base::Callback<void(const ModelType, |
| 30 std::unique_ptr<base::ListValue>)>& callback); | 28 std::unique_ptr<base::ListValue>)>& callback, |
| 29 ModelTypeSyncBridge* bridge); |
| 31 | 30 |
| 32 // Returns StatusCounters for the type to |callback|. | 31 // Returns StatusCounters for the type to |callback|. |
| 33 // Used for updating data type counters in chrome://sync-internals. | 32 // Used for updating data type counters in chrome://sync-internals. |
| 34 static void GetStatusCounters( | 33 static void GetStatusCounters( |
| 35 const base::WeakPtr<ModelTypeSyncBridge>& bridge, | |
| 36 const base::Callback<void(const ModelType, const StatusCounters&)>& | 34 const base::Callback<void(const ModelType, const StatusCounters&)>& |
| 37 callback); | 35 callback, |
| 36 ModelTypeSyncBridge* bridge); |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 ModelTypeDebugInfo(); | 39 ModelTypeDebugInfo(); |
| 41 | 40 |
| 42 // This is callback function for ModelTypeSyncBridge::GetAllData. This | 41 // This is callback function for ModelTypeSyncBridge::GetAllData. This |
| 43 // function will merge real data from |batch| with metadata extracted from | 42 // function will merge real data from |batch| with metadata extracted from |
| 44 // the |processor|, then pass it all to |callback|. | 43 // the |processor|, then pass it all to |callback|. |
| 45 static void MergeDataWithMetadata( | 44 static void MergeDataWithMetadata( |
| 46 SharedModelTypeProcessor* processor, | 45 SharedModelTypeProcessor* processor, |
| 47 const base::Callback<void(const ModelType, | 46 const base::Callback<void(const ModelType, |
| 48 std::unique_ptr<base::ListValue>)>& callback, | 47 std::unique_ptr<base::ListValue>)>& callback, |
| 49 std::unique_ptr<DataBatch> batch); | 48 std::unique_ptr<DataBatch> batch); |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 } // namespace syncer | 51 } // namespace syncer |
| 53 | 52 |
| 54 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ | 53 #endif // COMPONENTS_SYNC_MODEL_MODEL_TYPE_DEBUG_INFO_H_ |
| OLD | NEW |