Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: components/sync/engine_impl/syncer_proto_util.h

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync/engine_impl/syncer.cc ('k') | components/sync/engine_impl/syncer_proto_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_ 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_
6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_ 6 #define COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "components/sync/base/model_type.h" 13 #include "components/sync/base/model_type.h"
14 #include "components/sync/base/syncer_error.h" 14 #include "components/sync/base/syncer_error.h"
15 #include "components/sync/sessions_impl/sync_session.h" 15 #include "components/sync/engine_impl/cycle/sync_cycle.h"
16 16
17 namespace sync_pb { 17 namespace sync_pb {
18 class ClientToServerMessage; 18 class ClientToServerMessage;
19 class ClientToServerResponse; 19 class ClientToServerResponse;
20 class ClientToServerResponse_Error; 20 class ClientToServerResponse_Error;
21 class CommitResponse_EntryResponse; 21 class CommitResponse_EntryResponse;
22 class EntitySpecifics; 22 class EntitySpecifics;
23 class SyncEntity; 23 class SyncEntity;
24 } 24 }
25 25
26 namespace syncer { 26 namespace syncer {
27 27
28 class ServerConnectionManager; 28 class ServerConnectionManager;
29 29 class SyncCycleContext;
30 namespace sessions { 30 struct SyncProtocolError;
31 class SyncProtocolError;
32 class SyncSessionContext;
33 }
34 31
35 namespace syncable { 32 namespace syncable {
36 class Directory; 33 class Directory;
37 class Entry; 34 class Entry;
38 } 35 }
39 36
40 // Returns the types to migrate from the data in |response|. 37 // Returns the types to migrate from the data in |response|.
41 ModelTypeSet GetTypesToMigrate(const sync_pb::ClientToServerResponse& response); 38 ModelTypeSet GetTypesToMigrate(const sync_pb::ClientToServerResponse& response);
42 39
43 // Builds a SyncProtocolError from the data in |error|. 40 // Builds a SyncProtocolError from the data in |error|.
44 SyncProtocolError ConvertErrorPBToSyncProtocolError( 41 SyncProtocolError ConvertErrorPBToSyncProtocolError(
45 const sync_pb::ClientToServerResponse_Error& error); 42 const sync_pb::ClientToServerResponse_Error& error);
46 43
47 class SyncerProtoUtil { 44 class SyncerProtoUtil {
48 public: 45 public:
49 // Posts the given message and fills the buffer with the returned value. 46 // Posts the given message and fills the buffer with the returned value.
50 // Returns true on success. Also handles store birthday verification: will 47 // Returns true on success. Also handles store birthday verification: will
51 // produce a SyncError if the birthday is incorrect. 48 // produce a SyncError if the birthday is incorrect.
52 // NOTE: This will add all fields that must be sent on every request, which 49 // NOTE: This will add all fields that must be sent on every request, which
53 // includes store birthday, protocol version, client chips, api keys, etc. 50 // includes store birthday, protocol version, client chips, api keys, etc.
54 static SyncerError PostClientToServerMessage( 51 static SyncerError PostClientToServerMessage(
55 sync_pb::ClientToServerMessage* msg, 52 sync_pb::ClientToServerMessage* msg,
56 sync_pb::ClientToServerResponse* response, 53 sync_pb::ClientToServerResponse* response,
57 sessions::SyncSession* session, 54 SyncCycle* cycle,
58 ModelTypeSet* partial_failure_data_types); 55 ModelTypeSet* partial_failure_data_types);
59 56
60 // Specifies where entity's position should be updated from the data in 57 // Specifies where entity's position should be updated from the data in
61 // GetUpdates message. 58 // GetUpdates message.
62 static bool ShouldMaintainPosition(const sync_pb::SyncEntity& sync_entity); 59 static bool ShouldMaintainPosition(const sync_pb::SyncEntity& sync_entity);
63 60
64 // Specifies where entity's parent ID should be updated from the data in 61 // Specifies where entity's parent ID should be updated from the data in
65 // GetUpdates message. 62 // GetUpdates message.
66 static bool ShouldMaintainHierarchy(const sync_pb::SyncEntity& sync_entity); 63 static bool ShouldMaintainHierarchy(const sync_pb::SyncEntity& sync_entity);
67 64
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 const sync_pb::ClientToServerResponse& response, 120 const sync_pb::ClientToServerResponse& response,
124 syncable::Directory* dir); 121 syncable::Directory* dir);
125 122
126 // Returns true if sync is disabled by admin for a dasher account. 123 // Returns true if sync is disabled by admin for a dasher account.
127 static bool IsSyncDisabledByAdmin( 124 static bool IsSyncDisabledByAdmin(
128 const sync_pb::ClientToServerResponse& response); 125 const sync_pb::ClientToServerResponse& response);
129 126
130 // Post the message using the scm, and do some processing on the returned 127 // Post the message using the scm, and do some processing on the returned
131 // headers. Decode the server response. 128 // headers. Decode the server response.
132 static bool PostAndProcessHeaders(ServerConnectionManager* scm, 129 static bool PostAndProcessHeaders(ServerConnectionManager* scm,
133 sessions::SyncSession* session, 130 SyncCycle* cycle,
134 const sync_pb::ClientToServerMessage& msg, 131 const sync_pb::ClientToServerMessage& msg,
135 sync_pb::ClientToServerResponse* response); 132 sync_pb::ClientToServerResponse* response);
136 133
137 static base::TimeDelta GetThrottleDelay( 134 static base::TimeDelta GetThrottleDelay(
138 const sync_pb::ClientToServerResponse& response); 135 const sync_pb::ClientToServerResponse& response);
139 136
140 friend class SyncerProtoUtilTest; 137 friend class SyncerProtoUtilTest;
141 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); 138 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday);
142 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); 139 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders);
143 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); 140 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes);
144 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); 141 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes);
145 142
146 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); 143 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil);
147 }; 144 };
148 145
149 } // namespace syncer 146 } // namespace syncer
150 147
151 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_ 148 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_
OLDNEW
« no previous file with comments | « components/sync/engine_impl/syncer.cc ('k') | components/sync/engine_impl/syncer_proto_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698