| OLD | NEW |
| 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" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 static const std::string& NameFromSyncEntity( | 70 static const std::string& NameFromSyncEntity( |
| 71 const sync_pb::SyncEntity& entry); | 71 const sync_pb::SyncEntity& entry); |
| 72 | 72 |
| 73 // Extract the name field from a commit entry response. | 73 // Extract the name field from a commit entry response. |
| 74 static const std::string& NameFromCommitEntryResponse( | 74 static const std::string& NameFromCommitEntryResponse( |
| 75 const sync_pb::CommitResponse_EntryResponse& entry); | 75 const sync_pb::CommitResponse_EntryResponse& entry); |
| 76 | 76 |
| 77 // EntitySpecifics is used as a filter for the GetUpdates message to tell | 77 // EntitySpecifics is used as a filter for the GetUpdates message to tell |
| 78 // the server which datatypes to send back. This adds a datatype so that | 78 // the server which datatypes to send back. This adds a datatype so that |
| 79 // it's included in the filter. | 79 // it's included in the filter. |
| 80 static void AddToEntitySpecificDatatypesFilter(syncer::ModelType datatype, | 80 static void AddToEntitySpecificDatatypesFilter(ModelType datatype, |
| 81 sync_pb::EntitySpecifics* filter); | 81 sync_pb::EntitySpecifics* filter); |
| 82 | 82 |
| 83 // Get a debug string representation of the client to server response. | 83 // Get a debug string representation of the client to server response. |
| 84 static std::string ClientToServerResponseDebugString( | 84 static std::string ClientToServerResponseDebugString( |
| 85 const sync_pb::ClientToServerResponse& response); | 85 const sync_pb::ClientToServerResponse& response); |
| 86 | 86 |
| 87 // Get update contents as a string. Intended for logging, and intended | 87 // Get update contents as a string. Intended for logging, and intended |
| 88 // to have a smaller footprint than the protobuf's built-in pretty printer. | 88 // to have a smaller footprint than the protobuf's built-in pretty printer. |
| 89 static std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); | 89 static std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); |
| 90 | 90 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 const sync_pb::ClientToServerResponse* response); | 106 const sync_pb::ClientToServerResponse* response); |
| 107 | 107 |
| 108 // Builds and sends a SyncEngineEvent to begin migration for types (specified | 108 // Builds and sends a SyncEngineEvent to begin migration for types (specified |
| 109 // in notification). | 109 // in notification). |
| 110 static void HandleMigrationDoneResponse( | 110 static void HandleMigrationDoneResponse( |
| 111 const sync_pb::ClientToServerResponse* response, | 111 const sync_pb::ClientToServerResponse* response, |
| 112 sessions::SyncSession* session); | 112 sessions::SyncSession* session); |
| 113 | 113 |
| 114 // Post the message using the scm, and do some processing on the returned | 114 // Post the message using the scm, and do some processing on the returned |
| 115 // headers. Decode the server response. | 115 // headers. Decode the server response. |
| 116 static bool PostAndProcessHeaders(syncer::ServerConnectionManager* scm, | 116 static bool PostAndProcessHeaders(ServerConnectionManager* scm, |
| 117 sessions::SyncSession* session, | 117 sessions::SyncSession* session, |
| 118 const sync_pb::ClientToServerMessage& msg, | 118 const sync_pb::ClientToServerMessage& msg, |
| 119 sync_pb::ClientToServerResponse* response); | 119 sync_pb::ClientToServerResponse* response); |
| 120 | 120 |
| 121 static base::TimeDelta GetThrottleDelay( | 121 static base::TimeDelta GetThrottleDelay( |
| 122 const sync_pb::ClientToServerResponse& response); | 122 const sync_pb::ClientToServerResponse& response); |
| 123 | 123 |
| 124 static void HandleThrottleError( | 124 static void HandleThrottleError( |
| 125 const SyncProtocolError& error, | 125 const SyncProtocolError& error, |
| 126 const base::TimeTicks& throttled_until, | 126 const base::TimeTicks& throttled_until, |
| 127 syncer::ThrottledDataTypeTracker* tracker, | 127 ThrottledDataTypeTracker* tracker, |
| 128 sessions::SyncSession::Delegate* delegate); | 128 sessions::SyncSession::Delegate* delegate); |
| 129 | 129 |
| 130 friend class SyncerProtoUtilTest; | 130 friend class SyncerProtoUtilTest; |
| 131 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); | 131 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); |
| 132 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); | 132 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); |
| 133 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday); | 133 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday); |
| 134 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); | 134 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); |
| 135 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); | 135 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); | 137 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace syncer | 140 } // namespace syncer |
| 141 | 141 |
| 142 #endif // SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 142 #endif // SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ |
| OLD | NEW |