| 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 #include "sync/engine/net/server_connection_manager.h" | 5 #include "sync/engine/net/server_connection_manager.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <stdint.h> |
| 8 | 9 |
| 9 #include <ostream> | 10 #include <ostream> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 #include "net/http/http_status_code.h" | 17 #include "net/http/http_status_code.h" |
| 17 #include "sync/engine/net/url_translator.h" | 18 #include "sync/engine/net/url_translator.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 HttpResponse* response, | 84 HttpResponse* response, |
| 84 bool require_response) { | 85 bool require_response) { |
| 85 if (net::HTTP_OK != response->response_code) { | 86 if (net::HTTP_OK != response->response_code) { |
| 86 response->server_status = HttpResponse::SYNC_SERVER_ERROR; | 87 response->server_status = HttpResponse::SYNC_SERVER_ERROR; |
| 87 return false; | 88 return false; |
| 88 } | 89 } |
| 89 | 90 |
| 90 if (require_response && (1 > response->content_length)) | 91 if (require_response && (1 > response->content_length)) |
| 91 return false; | 92 return false; |
| 92 | 93 |
| 93 const int64 bytes_read = ReadResponse(buffer_out, | 94 const int64_t bytes_read = |
| 94 static_cast<int>(response->content_length)); | 95 ReadResponse(buffer_out, static_cast<int>(response->content_length)); |
| 95 if (bytes_read != response->content_length) { | 96 if (bytes_read != response->content_length) { |
| 96 response->server_status = HttpResponse::IO_ERROR; | 97 response->server_status = HttpResponse::IO_ERROR; |
| 97 return false; | 98 return false; |
| 98 } | 99 } |
| 99 return true; | 100 return true; |
| 100 } | 101 } |
| 101 | 102 |
| 102 bool ServerConnectionManager::Connection::ReadDownloadResponse( | 103 bool ServerConnectionManager::Connection::ReadDownloadResponse( |
| 103 HttpResponse* response, | 104 HttpResponse* response, |
| 104 string* buffer_out) { | 105 string* buffer_out) { |
| 105 const int64 bytes_read = ReadResponse(buffer_out, | 106 const int64_t bytes_read = |
| 106 static_cast<int>(response->content_length)); | 107 ReadResponse(buffer_out, static_cast<int>(response->content_length)); |
| 107 | 108 |
| 108 if (bytes_read != response->content_length) { | 109 if (bytes_read != response->content_length) { |
| 109 LOG(ERROR) << "Mismatched content lengths, server claimed " << | 110 LOG(ERROR) << "Mismatched content lengths, server claimed " << |
| 110 response->content_length << ", but sent " << bytes_read; | 111 response->content_length << ", but sent " << bytes_read; |
| 111 response->server_status = HttpResponse::IO_ERROR; | 112 response->server_status = HttpResponse::IO_ERROR; |
| 112 return false; | 113 return false; |
| 113 } | 114 } |
| 114 return true; | 115 return true; |
| 115 } | 116 } |
| 116 | 117 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 372 |
| 372 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { | 373 std::ostream& operator << (std::ostream& s, const struct HttpResponse& hr) { |
| 373 s << " Response Code (bogus on error): " << hr.response_code; | 374 s << " Response Code (bogus on error): " << hr.response_code; |
| 374 s << " Content-Length (bogus on error): " << hr.content_length; | 375 s << " Content-Length (bogus on error): " << hr.content_length; |
| 375 s << " Server Status: " | 376 s << " Server Status: " |
| 376 << HttpResponse::GetServerConnectionCodeString(hr.server_status); | 377 << HttpResponse::GetServerConnectionCodeString(hr.server_status); |
| 377 return s; | 378 return s; |
| 378 } | 379 } |
| 379 | 380 |
| 380 } // namespace syncer | 381 } // namespace syncer |
| OLD | NEW |