Commit d638a00b authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Sync::USS] Rename DecodeSyncMetadata to ModelReadyToSync

This is more aligned with what other data types have and also better
describes what this method is actually doing.

Bug: 516866
Change-Id: I8eb93d645f49427f4e8bf071aaaaa527d63d6772
Reviewed-on: https://chromium-review.googlesource.com/1124855
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572524}
parent 76cb23f9
...@@ -166,7 +166,7 @@ std::string BookmarkModelTypeProcessor::EncodeSyncMetadata() const { ...@@ -166,7 +166,7 @@ std::string BookmarkModelTypeProcessor::EncodeSyncMetadata() const {
return metadata_str; return metadata_str;
} }
void BookmarkModelTypeProcessor::DecodeSyncMetadata( void BookmarkModelTypeProcessor::ModelReadyToSync(
const std::string& metadata_str, const std::string& metadata_str,
const base::RepeatingClosure& schedule_save_closure, const base::RepeatingClosure& schedule_save_closure,
bookmarks::BookmarkModel* model) { bookmarks::BookmarkModel* model) {
......
...@@ -56,7 +56,7 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor, ...@@ -56,7 +56,7 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor,
void RecordMemoryUsageHistogram() override; void RecordMemoryUsageHistogram() override;
// Encodes all sync metadata into a string, representing a state that can be // Encodes all sync metadata into a string, representing a state that can be
// restored via DecodeSyncMetadata() below. // restored via ModelReadyToSync() below.
std::string EncodeSyncMetadata() const; std::string EncodeSyncMetadata() const;
// It mainly decodes a BookmarkModelMetadata proto seralized in // It mainly decodes a BookmarkModelMetadata proto seralized in
...@@ -66,9 +66,9 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor, ...@@ -66,9 +66,9 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor,
// used for further model operations. |schedule_save_closure| is a repeating // used for further model operations. |schedule_save_closure| is a repeating
// closure used to schedule a save of the bookmark model together with the // closure used to schedule a save of the bookmark model together with the
// metadata. // metadata.
void DecodeSyncMetadata(const std::string& metadata_str, void ModelReadyToSync(const std::string& metadata_str,
const base::RepeatingClosure& schedule_save_closure, const base::RepeatingClosure& schedule_save_closure,
bookmarks::BookmarkModel* model); bookmarks::BookmarkModel* model);
const SyncedBookmarkTracker* GetTrackerForTest() const; const SyncedBookmarkTracker* GetTrackerForTest() const;
...@@ -92,11 +92,11 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor, ...@@ -92,11 +92,11 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor,
std::unique_ptr<sync_pb::ModelTypeState> model_type_state); std::unique_ptr<sync_pb::ModelTypeState> model_type_state);
// Stores the start callback in between OnSyncStarting() and // Stores the start callback in between OnSyncStarting() and
// DecodeSyncMetadata(). // ModelReadyToSync().
StartCallback start_callback_; StartCallback start_callback_;
// The bookmark model we are processing local changes from and forwarding // The bookmark model we are processing local changes from and forwarding
// remote changes to. It is set during DecodeSyncMetadata(), which is called // remote changes to. It is set during ModelReadyToSync(), which is called
// during startup, as part of the bookmark-loading process. // during startup, as part of the bookmark-loading process.
bookmarks::BookmarkModel* bookmark_model_ = nullptr; bookmarks::BookmarkModel* bookmark_model_ = nullptr;
...@@ -118,8 +118,10 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor, ...@@ -118,8 +118,10 @@ class BookmarkModelTypeProcessor : public syncer::ModelTypeProcessor,
std::unique_ptr<syncer::CommitQueue> worker_; std::unique_ptr<syncer::CommitQueue> worker_;
// Keeps the mapping between server ids and bookmarks nodes together with sync // Keeps the mapping between server ids and bookmarks nodes together with sync
// metadata. It is constructed and set during DecodeSyncMetadata(), which is // metadata. It is constructed and set during ModelReadyToSync(), if the
// called during startup, as part of the bookmark-loading process. // loaded bookmarks JSON contained previous sync metadata, or upon completion
// of initial sync, which is called during startup, as part of the
// bookmark-loading process.
std::unique_ptr<SyncedBookmarkTracker> bookmark_tracker_; std::unique_ptr<SyncedBookmarkTracker> bookmark_tracker_;
// GUID string that identifies the sync client and is received from the sync // GUID string that identifies the sync client and is received from the sync
......
...@@ -138,8 +138,9 @@ class BookmarkModelTypeProcessorTest : public testing::Test { ...@@ -138,8 +138,9 @@ class BookmarkModelTypeProcessorTest : public testing::Test {
// TODO(crbug.com/516866): This class assumes model is loaded and sync has // TODO(crbug.com/516866): This class assumes model is loaded and sync has
// started before running tests. We should test other variations (i.e. model // started before running tests. We should test other variations (i.e. model
// isn't loaded yet and/or sync didn't start yet). // isn't loaded yet and/or sync didn't start yet).
processor_.DecodeSyncMetadata(std::string(), schedule_save_closure_.Get(), processor_.ModelReadyToSync(/*metadata_str=*/std::string(),
bookmark_model_.get()); schedule_save_closure_.Get(),
bookmark_model_.get());
syncer::DataTypeActivationRequest request; syncer::DataTypeActivationRequest request;
request.cache_guid = kCacheGuid; request.cache_guid = kCacheGuid;
processor_.OnSyncStarting(request, base::DoNothing()); processor_.OnSyncStarting(request, base::DoNothing());
...@@ -422,8 +423,8 @@ TEST_F(BookmarkModelTypeProcessorTest, ShouldDecodeSyncMetadata) { ...@@ -422,8 +423,8 @@ TEST_F(BookmarkModelTypeProcessorTest, ShouldDecodeSyncMetadata) {
sync_client()->GetBookmarkUndoServiceIfExists()); sync_client()->GetBookmarkUndoServiceIfExists());
std::string metadata_str; std::string metadata_str;
model_metadata.SerializeToString(&metadata_str); model_metadata.SerializeToString(&metadata_str);
new_processor.DecodeSyncMetadata(metadata_str, base::DoNothing(), new_processor.ModelReadyToSync(metadata_str, base::DoNothing(),
bookmark_model()); bookmark_model());
AssertState(&new_processor, bookmarks); AssertState(&new_processor, bookmarks);
} }
...@@ -455,8 +456,8 @@ TEST_F(BookmarkModelTypeProcessorTest, ShouldDecodeEncodedSyncMetadata) { ...@@ -455,8 +456,8 @@ TEST_F(BookmarkModelTypeProcessorTest, ShouldDecodeEncodedSyncMetadata) {
BookmarkModelTypeProcessor new_processor( BookmarkModelTypeProcessor new_processor(
sync_client()->GetBookmarkUndoServiceIfExists()); sync_client()->GetBookmarkUndoServiceIfExists());
model_metadata.SerializeToString(&metadata_str); model_metadata.SerializeToString(&metadata_str);
new_processor.DecodeSyncMetadata(metadata_str, base::DoNothing(), new_processor.ModelReadyToSync(metadata_str, base::DoNothing(),
bookmark_model()); bookmark_model());
AssertState(&new_processor, bookmarks); AssertState(&new_processor, bookmarks);
} }
......
...@@ -38,7 +38,7 @@ void BookmarkSyncService::DecodeBookmarkSyncMetadata( ...@@ -38,7 +38,7 @@ void BookmarkSyncService::DecodeBookmarkSyncMetadata(
const base::RepeatingClosure& schedule_save_closure, const base::RepeatingClosure& schedule_save_closure,
bookmarks::BookmarkModel* model) { bookmarks::BookmarkModel* model) {
if (bookmark_model_type_processor_) { if (bookmark_model_type_processor_) {
bookmark_model_type_processor_->DecodeSyncMetadata( bookmark_model_type_processor_->ModelReadyToSync(
metadata_str, schedule_save_closure, model); metadata_str, schedule_save_closure, model);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment