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

Side by Side Diff: sync/engine/syncer_proto_util.h

Issue 11485019: [Sync] Add tests for invalid specifics field number handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ 5 #ifndef SYNC_ENGINE_SYNCER_PROTO_UTIL_H_
6 #define SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ 6 #define SYNC_ENGINE_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/time.h" 11 #include "base/time.h"
12 #include "sync/base/sync_export.h"
12 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
13 #include "sync/internal_api/public/util/syncer_error.h" 14 #include "sync/internal_api/public/util/syncer_error.h"
14 #include "sync/sessions/sync_session.h" 15 #include "sync/sessions/sync_session.h"
15 #include "sync/syncable/blob.h" 16 #include "sync/syncable/blob.h"
16 17
17 namespace sync_pb { 18 namespace sync_pb {
18 class ClientToServerMessage; 19 class ClientToServerMessage;
19 class ClientToServerResponse; 20 class ClientToServerResponse;
21 class ClientToServerResponse_Error;
20 class CommitResponse_EntryResponse; 22 class CommitResponse_EntryResponse;
21 class EntitySpecifics; 23 class EntitySpecifics;
22 class SyncEntity; 24 class SyncEntity;
23 } 25 }
24 26
25 namespace syncer { 27 namespace syncer {
26 28
27 class ThrottledDataTypeTracker; 29 class ThrottledDataTypeTracker;
28 class ServerConnectionManager; 30 class ServerConnectionManager;
29 31
30 namespace sessions { 32 namespace sessions {
31 class SyncProtocolError; 33 class SyncProtocolError;
32 class SyncSessionContext; 34 class SyncSessionContext;
33 } 35 }
34 36
35 namespace syncable { 37 namespace syncable {
36 class Directory; 38 class Directory;
37 class Entry; 39 class Entry;
38 } 40 }
39 41
42 // Returns the types to migrate from the data in |response|.
43 SYNC_EXPORT_PRIVATE ModelTypeSet GetTypesToMigrate(
44 const sync_pb::ClientToServerResponse& response);
45
46 // Builds a SyncProtocolError from the data in |error|.
47 SYNC_EXPORT_PRIVATE SyncProtocolError ConvertErrorPBToLocalType(
48 const sync_pb::ClientToServerResponse_Error& error);
49
40 class SyncerProtoUtil { 50 class SyncerProtoUtil {
41 public: 51 public:
42 // Posts the given message and fills the buffer with the returned value. 52 // Posts the given message and fills the buffer with the returned value.
43 // Returns true on success. Also handles store birthday verification: will 53 // Returns true on success. Also handles store birthday verification: will
44 // produce a SyncError if the birthday is incorrect. 54 // produce a SyncError if the birthday is incorrect.
45 // NOTE: This will add all fields that must be sent on every request, which 55 // NOTE: This will add all fields that must be sent on every request, which
46 // includes store birthday, protocol version, client chips, api keys, etc. 56 // includes store birthday, protocol version, client chips, api keys, etc.
47 static SyncerError PostClientToServerMessage( 57 static SyncerError PostClientToServerMessage(
48 sync_pb::ClientToServerMessage* msg, 58 sync_pb::ClientToServerMessage* msg,
49 sync_pb::ClientToServerResponse* response, 59 sync_pb::ClientToServerResponse* response,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Set the protocol version field in the outgoing message. 117 // Set the protocol version field in the outgoing message.
108 static void SetProtocolVersion(sync_pb::ClientToServerMessage* msg); 118 static void SetProtocolVersion(sync_pb::ClientToServerMessage* msg);
109 119
110 private: 120 private:
111 SyncerProtoUtil() {} 121 SyncerProtoUtil() {}
112 122
113 // Helper functions for PostClientToServerMessage. 123 // Helper functions for PostClientToServerMessage.
114 124
115 // Verifies the store birthday, alerting/resetting as appropriate if there's a 125 // Verifies the store birthday, alerting/resetting as appropriate if there's a
116 // mismatch. Return false if the syncer should be stuck. 126 // mismatch. Return false if the syncer should be stuck.
117 static bool VerifyResponseBirthday(syncable::Directory* dir, 127 static bool VerifyResponseBirthday(
118 const sync_pb::ClientToServerResponse* response); 128 const sync_pb::ClientToServerResponse& response,
119 129 syncable::Directory* dir);
120 // Builds and sends a SyncEngineEvent to begin migration for types (specified
121 // in notification).
122 static void HandleMigrationDoneResponse(
123 const sync_pb::ClientToServerResponse* response,
124 sessions::SyncSession* session);
125 130
126 // Post the message using the scm, and do some processing on the returned 131 // Post the message using the scm, and do some processing on the returned
127 // headers. Decode the server response. 132 // headers. Decode the server response.
128 static bool PostAndProcessHeaders(ServerConnectionManager* scm, 133 static bool PostAndProcessHeaders(ServerConnectionManager* scm,
129 sessions::SyncSession* session, 134 sessions::SyncSession* session,
130 const sync_pb::ClientToServerMessage& msg, 135 const sync_pb::ClientToServerMessage& msg,
131 sync_pb::ClientToServerResponse* response); 136 sync_pb::ClientToServerResponse* response);
132 137
133 static base::TimeDelta GetThrottleDelay( 138 static base::TimeDelta GetThrottleDelay(
134 const sync_pb::ClientToServerResponse& response); 139 const sync_pb::ClientToServerResponse& response);
(...skipping 10 matching lines...) Expand all
145 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday); 150 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday);
146 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); 151 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes);
147 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); 152 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes);
148 153
149 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); 154 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil);
150 }; 155 };
151 156
152 } // namespace syncer 157 } // namespace syncer
153 158
154 #endif // SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ 159 #endif // SYNC_ENGINE_SYNCER_PROTO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698