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 #include "chrome/browser/sync/engine/syncer_proto_util.h" | 5 #include "chrome/browser/sync/engine/syncer_proto_util.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 9 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
10 #include "chrome/browser/sync/engine/syncer.h" | 10 #include "chrome/browser/sync/engine/syncer.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 using std::stringstream; | 24 using std::stringstream; |
25 using syncable::BASE_VERSION; | 25 using syncable::BASE_VERSION; |
26 using syncable::CTIME; | 26 using syncable::CTIME; |
27 using syncable::ID; | 27 using syncable::ID; |
28 using syncable::IS_DEL; | 28 using syncable::IS_DEL; |
29 using syncable::IS_DIR; | 29 using syncable::IS_DIR; |
30 using syncable::IS_UNSYNCED; | 30 using syncable::IS_UNSYNCED; |
31 using syncable::MTIME; | 31 using syncable::MTIME; |
32 using syncable::PARENT_ID; | 32 using syncable::PARENT_ID; |
33 using syncable::ScopedDirLookup; | 33 using syncable::ScopedDirLookup; |
34 using syncable::SyncName; | |
35 | 34 |
36 namespace browser_sync { | 35 namespace browser_sync { |
37 using sessions::SyncSession; | 36 using sessions::SyncSession; |
38 | 37 |
39 namespace { | 38 namespace { |
40 | 39 |
41 // Time to backoff syncing after receiving a throttled response. | 40 // Time to backoff syncing after receiving a throttled response. |
42 static const int kSyncDelayAfterThrottled = 2 * 60 * 60; // 2 hours | 41 static const int kSyncDelayAfterThrottled = 2 * 60 * 60; // 2 hours |
43 void LogResponseProfilingData(const ClientToServerResponse& response) { | 42 void LogResponseProfilingData(const ClientToServerResponse& response) { |
44 if (response.has_profiling_data()) { | 43 if (response.has_profiling_data()) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 ClientToServerMessage* msg) { | 132 ClientToServerMessage* msg) { |
134 if (!dir->store_birthday().empty()) | 133 if (!dir->store_birthday().empty()) |
135 msg->set_store_birthday(dir->store_birthday()); | 134 msg->set_store_birthday(dir->store_birthday()); |
136 } | 135 } |
137 | 136 |
138 // static | 137 // static |
139 bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm, | 138 bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm, |
140 sessions::SyncSession* session, | 139 sessions::SyncSession* session, |
141 const ClientToServerMessage& msg, | 140 const ClientToServerMessage& msg, |
142 ClientToServerResponse* response) { | 141 ClientToServerResponse* response) { |
143 | |
144 ServerConnectionManager::PostBufferParams params; | 142 ServerConnectionManager::PostBufferParams params; |
145 msg.SerializeToString(¶ms.buffer_in); | 143 msg.SerializeToString(¶ms.buffer_in); |
146 | 144 |
147 ScopedServerStatusWatcher server_status_watcher(scm, ¶ms.response); | 145 ScopedServerStatusWatcher server_status_watcher(scm, ¶ms.response); |
148 // Fills in params.buffer_out and params.response. | 146 // Fills in params.buffer_out and params.response. |
149 if (!scm->PostBufferWithCachedAuth(¶ms, &server_status_watcher)) { | 147 if (!scm->PostBufferWithCachedAuth(¶ms, &server_status_watcher)) { |
150 LOG(WARNING) << "Error posting from syncer:" << params.response; | 148 LOG(WARNING) << "Error posting from syncer:" << params.response; |
151 return false; | 149 return false; |
152 } | 150 } |
153 | 151 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 471 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
474 const sync_pb::ClientToServerResponse& response) { | 472 const sync_pb::ClientToServerResponse& response) { |
475 // Add more handlers as needed. | 473 // Add more handlers as needed. |
476 std::string output; | 474 std::string output; |
477 if (response.has_get_updates()) | 475 if (response.has_get_updates()) |
478 output.append(GetUpdatesResponseString(response.get_updates())); | 476 output.append(GetUpdatesResponseString(response.get_updates())); |
479 return output; | 477 return output; |
480 } | 478 } |
481 | 479 |
482 } // namespace browser_sync | 480 } // namespace browser_sync |
OLD | NEW |