| 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/internal_api/syncapi_server_connection_manager.h" | 5 #include "sync/internal_api/syncapi_server_connection_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Must be octet-stream, or the payload may be parsed for a cookie. | 48 // Must be octet-stream, or the payload may be parsed for a cookie. |
| 49 http->SetPostPayload("application/octet-stream", payload.length(), | 49 http->SetPostPayload("application/octet-stream", payload.length(), |
| 50 payload.data()); | 50 payload.data()); |
| 51 | 51 |
| 52 // Issue the POST, blocking until it finishes. | 52 // Issue the POST, blocking until it finishes. |
| 53 int error_code = 0; | 53 int error_code = 0; |
| 54 int response_code = 0; | 54 int response_code = 0; |
| 55 if (!http->MakeSynchronousPost(&error_code, &response_code)) { | 55 if (!http->MakeSynchronousPost(&error_code, &response_code)) { |
| 56 DCHECK_NE(error_code, net::OK); |
| 56 DVLOG(1) << "Http POST failed, error returns: " << error_code; | 57 DVLOG(1) << "Http POST failed, error returns: " << error_code; |
| 57 response->server_status = HttpResponse::ServerConnectionCodeFromNetError( | 58 response->server_status = HttpResponse::CONNECTION_UNAVAILABLE; |
| 58 error_code); | |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // We got a server response, copy over response codes and content. | 62 // We got a server response, copy over response codes and content. |
| 63 response->response_code = response_code; | 63 response->response_code = response_code; |
| 64 response->content_length = | 64 response->content_length = |
| 65 static_cast<int64_t>(http->GetResponseContentLength()); | 65 static_cast<int64_t>(http->GetResponseContentLength()); |
| 66 response->payload_length = | 66 response->payload_length = |
| 67 static_cast<int64_t>(http->GetResponseContentLength()); | 67 static_cast<int64_t>(http->GetResponseContentLength()); |
| 68 if (response->response_code < 400) | 68 if (response->response_code < 400) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} | 99 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} |
| 100 | 100 |
| 101 ServerConnectionManager::Connection* | 101 ServerConnectionManager::Connection* |
| 102 SyncAPIServerConnectionManager::MakeConnection() { | 102 SyncAPIServerConnectionManager::MakeConnection() { |
| 103 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); | 103 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace syncer | 106 } // namespace syncer |
| OLD | NEW |