#include "components/sync_bookmarks/bookmark_remote_updates_handler.h"
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/trace_event/trace_event.h"
#include "base/uuid.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/engine/data_type_processor_metrics.h"
#include "components/sync/model/conflict_resolution.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync/protocol/unique_position.pb.h"
#include "components/sync_bookmarks/bookmark_model_view.h"
#include "components/sync_bookmarks/bookmark_specifics_conversions.h"
#include "components/sync_bookmarks/switches.h"
#include "components/sync_bookmarks/synced_bookmark_tracker_entity.h"
namespace sync_bookmarks {
namespace {
enum class RemoteBookmarkUpdateError { … };
void LogProblematicBookmark(RemoteBookmarkUpdateError problem) { … }
void TraverseAndAppendChildren(
const base::Uuid& node_uuid,
const std::unordered_multimap<base::Uuid,
const syncer::UpdateResponseData*,
base::UuidHash>& uuid_to_updates,
const std::unordered_map<base::Uuid,
std::vector<base::Uuid>,
base::UuidHash>& node_to_children,
std::vector<const syncer::UpdateResponseData*>* ordered_updates) { … }
syncer::UniquePosition ComputeUniquePositionForTrackedBookmarkNode(
const SyncedBookmarkTracker* bookmark_tracker,
const bookmarks::BookmarkNode* bookmark_node) { … }
size_t ComputeChildNodeIndex(const bookmarks::BookmarkNode* parent,
const sync_pb::UniquePosition& unique_position,
const SyncedBookmarkTracker* bookmark_tracker) { … }
bool IsPermanentNodeUpdate(const syncer::EntityData& update_entity) { … }
bool IsValidUpdate(const syncer::EntityData& update_entity) { … }
base::Uuid GetParentUuidInUpdate(const syncer::EntityData& update_entity) { … }
void ApplyRemoteUpdate(
const syncer::UpdateResponseData& update,
const SyncedBookmarkTrackerEntity* tracked_entity,
const SyncedBookmarkTrackerEntity* new_parent_tracked_entity,
BookmarkModelView* model,
SyncedBookmarkTracker* tracker,
favicon::FaviconService* favicon_service) { … }
}
BookmarkRemoteUpdatesHandler::BookmarkRemoteUpdatesHandler(
BookmarkModelView* bookmark_model,
favicon::FaviconService* favicon_service,
SyncedBookmarkTracker* bookmark_tracker)
: … { … }
void BookmarkRemoteUpdatesHandler::Process(
const syncer::UpdateResponseDataList& updates,
bool got_new_encryption_requirements) { … }
std::vector<const syncer::UpdateResponseData*>
BookmarkRemoteUpdatesHandler::ReorderValidUpdatesForTest(
const syncer::UpdateResponseDataList* updates) { … }
size_t BookmarkRemoteUpdatesHandler::ComputeChildNodeIndexForTest(
const bookmarks::BookmarkNode* parent,
const sync_pb::UniquePosition& unique_position,
const SyncedBookmarkTracker* bookmark_tracker) { … }
std::vector<const syncer::UpdateResponseData*>
BookmarkRemoteUpdatesHandler::ReorderValidUpdates(
const syncer::UpdateResponseDataList* updates) { … }
const SyncedBookmarkTrackerEntity*
BookmarkRemoteUpdatesHandler::DetermineLocalTrackedEntityToUpdate(
const syncer::EntityData& update_entity,
bool* should_ignore_update) { … }
const SyncedBookmarkTrackerEntity* BookmarkRemoteUpdatesHandler::ProcessCreate(
const syncer::UpdateResponseData& update) { … }
void BookmarkRemoteUpdatesHandler::ProcessUpdate(
const syncer::UpdateResponseData& update,
const SyncedBookmarkTrackerEntity* tracked_entity) { … }
void BookmarkRemoteUpdatesHandler::ProcessDelete(
const syncer::EntityData& update_entity,
const SyncedBookmarkTrackerEntity* tracked_entity) { … }
const SyncedBookmarkTrackerEntity*
BookmarkRemoteUpdatesHandler::ProcessConflict(
const syncer::UpdateResponseData& update,
const SyncedBookmarkTrackerEntity* tracked_entity) { … }
void BookmarkRemoteUpdatesHandler::RemoveEntityAndChildrenFromTracker(
const bookmarks::BookmarkNode* node) { … }
const bookmarks::BookmarkNode* BookmarkRemoteUpdatesHandler::GetParentNode(
const syncer::EntityData& update_entity) const { … }
void BookmarkRemoteUpdatesHandler::ReuploadEntityIfNeeded(
const syncer::EntityData& entity_data,
const SyncedBookmarkTrackerEntity* tracked_entity) { … }
}