| OLD | NEW |
| 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 SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_ |
| 6 #define SYNC_ENGINE_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 "sync/base/sync_export.h" | 13 #include "components/sync/base/model_type.h" |
| 14 #include "sync/internal_api/public/base/model_type.h" | 14 #include "components/sync/base/sync_export.h" |
| 15 #include "sync/internal_api/public/util/syncer_error.h" | 15 #include "components/sync/base/syncer_error.h" |
| 16 #include "sync/sessions/sync_session.h" | 16 #include "components/sync/sessions_impl/sync_session.h" |
| 17 | 17 |
| 18 namespace sync_pb { | 18 namespace sync_pb { |
| 19 class ClientToServerMessage; | 19 class ClientToServerMessage; |
| 20 class ClientToServerResponse; | 20 class ClientToServerResponse; |
| 21 class ClientToServerResponse_Error; | 21 class ClientToServerResponse_Error; |
| 22 class CommitResponse_EntryResponse; | 22 class CommitResponse_EntryResponse; |
| 23 class EntitySpecifics; | 23 class EntitySpecifics; |
| 24 class SyncEntity; | 24 class SyncEntity; |
| 25 } | 25 } |
| 26 | 26 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const sync_pb::CommitResponse_EntryResponse& entry); | 76 const sync_pb::CommitResponse_EntryResponse& entry); |
| 77 | 77 |
| 78 // Persist the bag of chips if it is present in the response. | 78 // Persist the bag of chips if it is present in the response. |
| 79 static void PersistBagOfChips( | 79 static void PersistBagOfChips( |
| 80 syncable::Directory* dir, | 80 syncable::Directory* dir, |
| 81 const sync_pb::ClientToServerResponse& response); | 81 const sync_pb::ClientToServerResponse& response); |
| 82 | 82 |
| 83 // EntitySpecifics is used as a filter for the GetUpdates message to tell | 83 // EntitySpecifics is used as a filter for the GetUpdates message to tell |
| 84 // the server which datatypes to send back. This adds a datatype so that | 84 // the server which datatypes to send back. This adds a datatype so that |
| 85 // it's included in the filter. | 85 // it's included in the filter. |
| 86 static void AddToEntitySpecificDatatypesFilter(ModelType datatype, | 86 static void AddToEntitySpecificDatatypesFilter( |
| 87 ModelType datatype, |
| 87 sync_pb::EntitySpecifics* filter); | 88 sync_pb::EntitySpecifics* filter); |
| 88 | 89 |
| 89 // Get a debug string representation of the client to server response. | 90 // Get a debug string representation of the client to server response. |
| 90 static std::string ClientToServerResponseDebugString( | 91 static std::string ClientToServerResponseDebugString( |
| 91 const sync_pb::ClientToServerResponse& response); | 92 const sync_pb::ClientToServerResponse& response); |
| 92 | 93 |
| 93 // Get update contents as a string. Intended for logging, and intended | 94 // Get update contents as a string. Intended for logging, and intended |
| 94 // to have a smaller footprint than the protobuf's built-in pretty printer. | 95 // to have a smaller footprint than the protobuf's built-in pretty printer. |
| 95 static std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); | 96 static std::string SyncEntityDebugString(const sync_pb::SyncEntity& entry); |
| 96 | 97 |
| 97 // Pull the birthday from the dir and put it into the msg. | 98 // Pull the birthday from the dir and put it into the msg. |
| 98 static void AddRequestBirthday(syncable::Directory* dir, | 99 static void AddRequestBirthday(syncable::Directory* dir, |
| 99 sync_pb::ClientToServerMessage* msg); | 100 sync_pb::ClientToServerMessage* msg); |
| 100 | 101 |
| 101 // Pull the bag of chips from the dir and put it into the msg. | 102 // Pull the bag of chips from the dir and put it into the msg. |
| 102 static void AddBagOfChips(syncable::Directory* dir, | 103 static void AddBagOfChips(syncable::Directory* dir, |
| 103 sync_pb::ClientToServerMessage* msg); | 104 sync_pb::ClientToServerMessage* msg); |
| 104 | 105 |
| 105 | |
| 106 // Set the protocol version field in the outgoing message. | 106 // Set the protocol version field in the outgoing message. |
| 107 static void SetProtocolVersion(sync_pb::ClientToServerMessage* msg); | 107 static void SetProtocolVersion(sync_pb::ClientToServerMessage* msg); |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 SyncerProtoUtil() {} | 110 SyncerProtoUtil() {} |
| 111 | 111 |
| 112 // Helper functions for PostClientToServerMessage. | 112 // Helper functions for PostClientToServerMessage. |
| 113 | 113 |
| 114 // Analyzes error fields and store birthday in response message, compares | 114 // Analyzes error fields and store birthday in response message, compares |
| 115 // store birthday with value in directory and returns corresponding | 115 // store birthday with value in directory and returns corresponding |
| (...skipping 27 matching lines...) Expand all Loading... |
| 143 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); | 143 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); |
| 144 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); | 144 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); |
| 145 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); | 145 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); |
| 146 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); | 146 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); |
| 147 | 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); | 148 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 } // namespace syncer | 151 } // namespace syncer |
| 152 | 152 |
| 153 #endif // SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 153 #endif // COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_PROTO_UTIL_H_ |
| OLD | NEW |