Chromium Code Reviews| 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/net/server_connection_manager.h" | 5 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 const PostBufferParams* params, ScopedServerStatusWatcher* watcher) { | 185 const PostBufferParams* params, ScopedServerStatusWatcher* watcher) { |
| 186 string path = | 186 string path = |
| 187 MakeSyncServerPath(proto_sync_path(), MakeSyncQueryString(client_id_)); | 187 MakeSyncServerPath(proto_sync_path(), MakeSyncQueryString(client_id_)); |
| 188 return PostBufferToPath(params, path, auth_token(), watcher); | 188 return PostBufferToPath(params, path, auth_token(), watcher); |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool ServerConnectionManager::PostBufferToPath(const PostBufferParams* params, | 191 bool ServerConnectionManager::PostBufferToPath(const PostBufferParams* params, |
| 192 const string& path, const string& auth_token, | 192 const string& path, const string& auth_token, |
| 193 ScopedServerStatusWatcher* watcher) { | 193 ScopedServerStatusWatcher* watcher) { |
| 194 DCHECK(watcher != NULL); | 194 DCHECK(watcher != NULL); |
| 195 | |
| 196 if (auth_token.empty()) { | |
|
tim (not reviewing)
2011/08/04 00:24:40
could we put all this in syncapi_server_connection
lipalani1
2011/08/04 01:14:33
CheckTime uses that code and we probably dont want
| |
| 197 params->response->server_status = HttpResponse::SYNC_AUTH_ERROR; | |
| 198 return false; | |
| 199 } | |
| 200 | |
| 195 scoped_ptr<Post> post(MakePost()); | 201 scoped_ptr<Post> post(MakePost()); |
| 196 post->set_timing_info(params->timing_info); | 202 post->set_timing_info(params->timing_info); |
| 197 bool ok = post->Init(path.c_str(), auth_token, params->buffer_in, | 203 bool ok = post->Init(path.c_str(), auth_token, params->buffer_in, |
| 198 params->response); | 204 params->response); |
| 199 | 205 |
| 206 if (params->response->server_status == HttpResponse::SYNC_AUTH_ERROR) { | |
| 207 reset_auth_token(); | |
| 208 } | |
| 209 | |
| 200 if (!ok || RC_REQUEST_OK != params->response->response_code) { | 210 if (!ok || RC_REQUEST_OK != params->response->response_code) { |
| 201 IncrementErrorCount(); | 211 IncrementErrorCount(); |
| 202 return false; | 212 return false; |
| 203 } | 213 } |
| 204 | 214 |
| 205 if (post->ReadBufferResponse(params->buffer_out, params->response, true)) { | 215 if (post->ReadBufferResponse(params->buffer_out, params->response, true)) { |
| 206 params->response->server_status = HttpResponse::SERVER_CONNECTION_OK; | 216 params->response->server_status = HttpResponse::SERVER_CONNECTION_OK; |
| 207 server_reachable_ = true; | 217 server_reachable_ = true; |
| 208 return true; | 218 return true; |
| 209 } | 219 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 } | 389 } |
| 380 | 390 |
| 381 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { | 391 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { |
| 382 s << " Response Code (bogus on error): " << hr.response_code; | 392 s << " Response Code (bogus on error): " << hr.response_code; |
| 383 s << " Content-Length (bogus on error): " << hr.content_length; | 393 s << " Content-Length (bogus on error): " << hr.content_length; |
| 384 s << " Server Status: " << hr.server_status; | 394 s << " Server Status: " << hr.server_status; |
| 385 return s; | 395 return s; |
| 386 } | 396 } |
| 387 | 397 |
| 388 } // namespace browser_sync | 398 } // namespace browser_sync |
| OLD | NEW |