OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ |
6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/time.h" |
| 13 #include "chrome/browser/sync/sessions/sync_session.h" |
12 #include "chrome/browser/sync/syncable/blob.h" | 14 #include "chrome/browser/sync/syncable/blob.h" |
13 #include "chrome/browser/sync/syncable/model_type.h" | 15 #include "chrome/browser/sync/syncable/model_type.h" |
14 | 16 |
15 namespace syncable { | 17 namespace syncable { |
16 class Directory; | 18 class Directory; |
17 class Entry; | 19 class Entry; |
18 } // namespace syncable | 20 } // namespace syncable |
19 | 21 |
20 namespace sync_pb { | 22 namespace sync_pb { |
21 class ClientToServerResponse; | 23 class ClientToServerResponse; |
22 class EntitySpecifics; | 24 class EntitySpecifics; |
23 } // namespace sync_pb | 25 } // namespace sync_pb |
24 | 26 |
25 namespace browser_sync { | 27 namespace browser_sync { |
26 | 28 |
27 namespace sessions { | 29 namespace sessions { |
28 class SyncSession; | 30 class SyncProtocolError; |
| 31 class SyncSessionContext; |
29 } | 32 } |
30 | 33 |
31 class ClientToServerMessage; | 34 class ClientToServerMessage; |
32 class ServerConnectionManager; | 35 class ServerConnectionManager; |
33 class SyncEntity; | 36 class SyncEntity; |
34 class CommitResponse_EntryResponse; | 37 class CommitResponse_EntryResponse; |
35 | 38 |
36 class SyncerProtoUtil { | 39 class SyncerProtoUtil { |
37 public: | 40 public: |
38 // Posts the given message and fills the buffer with the returned value. | 41 // Posts the given message and fills the buffer with the returned value. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Post the message using the scm, and do some processing on the returned | 111 // Post the message using the scm, and do some processing on the returned |
109 // headers. Decode the server response. | 112 // headers. Decode the server response. |
110 static bool PostAndProcessHeaders(browser_sync::ServerConnectionManager* scm, | 113 static bool PostAndProcessHeaders(browser_sync::ServerConnectionManager* scm, |
111 sessions::SyncSession* session, | 114 sessions::SyncSession* session, |
112 const ClientToServerMessage& msg, | 115 const ClientToServerMessage& msg, |
113 sync_pb::ClientToServerResponse* response); | 116 sync_pb::ClientToServerResponse* response); |
114 | 117 |
115 static base::TimeDelta GetThrottleDelay( | 118 static base::TimeDelta GetThrottleDelay( |
116 const sync_pb::ClientToServerResponse& response); | 119 const sync_pb::ClientToServerResponse& response); |
117 | 120 |
| 121 static void HandleThrottleError(const SyncProtocolError& error, |
| 122 const base::TimeTicks& throttled_until, |
| 123 sessions::SyncSessionContext* context, |
| 124 sessions::SyncSession::Delegate* delegate); |
| 125 |
118 friend class SyncerProtoUtilTest; | 126 friend class SyncerProtoUtilTest; |
119 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); | 127 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, AddRequestBirthday); |
120 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); | 128 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, PostAndProcessHeaders); |
121 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday); | 129 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, VerifyResponseBirthday); |
| 130 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingNoDatatypes); |
| 131 FRIEND_TEST_ALL_PREFIXES(SyncerProtoUtilTest, HandleThrottlingWithDatatypes); |
122 | 132 |
123 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); | 133 DISALLOW_COPY_AND_ASSIGN(SyncerProtoUtil); |
124 }; | 134 }; |
125 | 135 |
126 } // namespace browser_sync | 136 } // namespace browser_sync |
127 | 137 |
128 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ | 138 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_PROTO_UTIL_H_ |
OLD | NEW |