1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SYNC_INTERNAL_API_PUBLIC_NON_BLOCKING_SYNC_COMMON_H_
6 #define SYNC_INTERNAL_API_PUBLIC_NON_BLOCKING_SYNC_COMMON_H_
11 #include "base/time/time.h"
12 #include "sync/base/sync_export.h"
13 #include "sync/protocol/sync.pb.h"
17 static const int64 kUncommittedVersion
= -1;
19 // Data-type global state that must be accessed and updated on the sync thread,
20 // but persisted on or through the model thread.
21 struct SYNC_EXPORT_PRIVATE DataTypeState
{
25 // The latest progress markers received from the server.
26 sync_pb::DataTypeProgressMarker progress_marker
;
28 // A data type context. Sent to the server in every commit or update
29 // request. May be updated by either by responses from the server or
30 // requests made on the model thread. The interpretation of this value may
31 // be data-type specific. Many data types ignore it.
32 sync_pb::DataTypeContext type_context
;
34 // The ID of the folder node that sits at the top of this type's folder
35 // hierarchy. We keep this around for legacy reasons. The protocol expects
36 // that all nodes of a certain type are children of the same type root
37 // entity. This entity is delivered by the server, and may not be available
38 // until the first download cycle has completed.
39 std::string type_root_id
;
41 // A strictly increasing counter used to generate unique values for the
42 // client-assigned IDs. The incrementing and ID assignment happens on the
43 // sync thread, but we store the value here so we can pass it back to the
44 // model thread for persistence. This is probably unnecessary for the
45 // client-tagged data types supported by non-blocking sync, but we will
46 // continue to emulate the directory sync's behavior for now.
49 // This flag is set to true when the first download cycle is complete. The
50 // ModelTypeSyncProxy should not attempt to commit any items until this
52 bool initial_sync_done
;
55 struct SYNC_EXPORT_PRIVATE CommitRequestData
{
60 std::string client_tag_hash
;
62 // Strictly incrementing number for in-progress commits. More information
63 // about its meaning can be found in comments in the files that make use of
65 int64 sequence_number
;
70 std::string non_unique_name
;
72 sync_pb::EntitySpecifics specifics
;
75 struct SYNC_EXPORT_PRIVATE CommitResponseData
{
77 ~CommitResponseData();
80 std::string client_tag_hash
;
81 int64 sequence_number
;
82 int64 response_version
;
85 struct SYNC_EXPORT_PRIVATE UpdateResponseData
{
87 ~UpdateResponseData();
90 std::string client_tag_hash
;
91 int64 response_version
;
94 std::string non_unique_name
;
96 sync_pb::EntitySpecifics specifics
;
99 typedef std::vector
<CommitRequestData
> CommitRequestDataList
;
100 typedef std::vector
<CommitResponseData
> CommitResponseDataList
;
101 typedef std::vector
<UpdateResponseData
> UpdateResponseDataList
;
103 } // namespace syncer
105 #endif // SYNC_INTERNAL_API_PUBLIC_NON_BLOCKING_SYNC_COMMON_H_