| 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/internal_api/syncapi_server_connection_manager.h" | 5 #include "chrome/browser/sync/internal_api/syncapi_server_connection_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" | 7 #include "chrome/browser/sync/internal_api/http_post_provider_factory.h" |
| 8 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" | 8 #include "chrome/browser/sync/internal_api/http_post_provider_interface.h" |
| 9 #include "chrome/browser/sync/util/oauth.h" | 9 #include "chrome/browser/sync/util/oauth.h" |
| 10 #include "chrome/common/net/http_return.h" | 10 #include "chrome/common/net/http_return.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 headers = "Authorization: GoogleLogin auth=" + auth_token; | 49 headers = "Authorization: GoogleLogin auth=" + auth_token; |
| 50 } | 50 } |
| 51 http->SetExtraRequestHeaders(headers.c_str()); | 51 http->SetExtraRequestHeaders(headers.c_str()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Must be octet-stream, or the payload may be parsed for a cookie. | 54 // Must be octet-stream, or the payload may be parsed for a cookie. |
| 55 http->SetPostPayload("application/octet-stream", payload.length(), | 55 http->SetPostPayload("application/octet-stream", payload.length(), |
| 56 payload.data()); | 56 payload.data()); |
| 57 | 57 |
| 58 // Issue the POST, blocking until it finishes. | 58 // Issue the POST, blocking until it finishes. |
| 59 int os_error_code = 0; | 59 int error_code = 0; |
| 60 int response_code = 0; | 60 int response_code = 0; |
| 61 if (!http->MakeSynchronousPost(&os_error_code, &response_code)) { | 61 if (!http->MakeSynchronousPost(&error_code, &response_code)) { |
| 62 VLOG(1) << "Http POST failed, error returns: " << os_error_code; | 62 VLOG(1) << "Http POST failed, error returns: " << error_code; |
| 63 response->server_status = os_error_code == net::ERR_ABORTED ? | 63 response->server_status = error_code == net::ERR_ABORTED ? |
| 64 HttpResponse::CONNECTION_UNAVAILABLE : HttpResponse::IO_ERROR; | 64 HttpResponse::CONNECTION_UNAVAILABLE : HttpResponse::IO_ERROR; |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // We got a server response, copy over response codes and content. | 68 // We got a server response, copy over response codes and content. |
| 69 response->response_code = response_code; | 69 response->response_code = response_code; |
| 70 response->content_length = | 70 response->content_length = |
| 71 static_cast<int64>(http->GetResponseContentLength()); | 71 static_cast<int64>(http->GetResponseContentLength()); |
| 72 response->payload_length = | 72 response->payload_length = |
| 73 static_cast<int64>(http->GetResponseContentLength()); | 73 static_cast<int64>(http->GetResponseContentLength()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} | 105 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} |
| 106 | 106 |
| 107 browser_sync::ServerConnectionManager::Connection* | 107 browser_sync::ServerConnectionManager::Connection* |
| 108 SyncAPIServerConnectionManager::MakeConnection() { | 108 SyncAPIServerConnectionManager::MakeConnection() { |
| 109 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); | 109 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace sync_api | 112 } // namespace sync_api |
| OLD | NEW |