// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_SYNC_ENGINE_DATA_TYPE_WORKER_H_ #define COMPONENTS_SYNC_ENGINE_DATA_TYPE_WORKER_H_ #include <stddef.h> #include <map> #include <memory> #include <string> #include <vector> #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "base/synchronization/waitable_event.h" #include "components/sync/base/data_type.h" #include "components/sync/base/passphrase_enums.h" #include "components/sync/engine/cancelation_signal.h" #include "components/sync/engine/commit_and_get_updates_types.h" #include "components/sync/engine/commit_contributor.h" #include "components/sync/engine/commit_queue.h" #include "components/sync/engine/nigori/cryptographer.h" #include "components/sync/engine/nudge_handler.h" #include "components/sync/engine/sync_encryption_handler.h" #include "components/sync/engine/update_handler.h" #include "components/sync/protocol/data_type_state.pb.h" namespace sync_pb { class DataTypeContext; class DataTypeProgressMarker; class DataTypeState; class GarbageCollectionDirective; class GetUpdateTriggers; class SyncEntity; } // namespace sync_pb namespace syncer { class CancelationSignal; class DataTypeProcessor; // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. // LINT.IfChange(SyncPasswordNotesStateInUpdate) enum class PasswordNotesStateForUMA { … }; // LINT.ThenChange(/tools/metrics/histograms/metadata/sync/enums.xml:SyncPasswordNotesStateInUpdate) // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. // LINT.IfChange(PendingInvalidationStatus) enum class PendingInvalidationStatus { … }; // LINT.ThenChange(/tools/metrics/histograms/metadata/sync/enums.xml:PendingInvalidationStatus) // A smart cache for sync types to communicate with the sync sequence. // // When the sync data type wants to talk to the sync server, it will // send a message from its sequence to this object on the sync sequence. This // object ensures the appropriate sync server communication gets scheduled and // executed. The response, if any, will be returned to the data types's sequence // eventually. // // This object also has a role to play in communications in the opposite // direction. Sometimes the sync sequence will receive changes from the sync // server and deliver them here. This object will post this information back to // the appropriate component on the data type's sequence. // // This object does more than just pass along messages. It understands the sync // protocol, and it can make decisions when it sees conflicting messages. For // example, if the sync server sends down an update for a sync entity that is // currently pending for commit, this object will detect this condition and // cancel the pending commit. // // Lives on the sync sequence. class DataTypeWorker : public UpdateHandler, public CommitContributor, public CommitQueue { … }; // GetLocalChangesRequest is a container for GetLocalChanges call response. It // allows sync sequence to block waiting for model sequence to call SetResponse. // This class supports canceling blocking call through CancelationSignal during // sync engine shutdown. // // It should be used in the following manner: // scoped_refptr<GetLocalChangesRequest> request = // base::MakeRefCounted<GetLocalChangesRequest>(cancelation_signal_); // data_type_processor_->GetLocalChanges( // max_entries, // base::BindOnce(&GetLocalChangesRequest::SetResponse, request)); // request->WaitForResponseOrCancelation(); // CommitRequestDataList response; // if (!request->WasCancelled()) // response = request->ExtractResponse(); class GetLocalChangesRequest : public base::RefCountedThreadSafe<GetLocalChangesRequest>, public CancelationSignal::Observer { … }; } // namespace syncer #endif // COMPONENTS_SYNC_ENGINE_DATA_TYPE_WORKER_H_