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> |
| 8 |
7 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
8 #include "net/http/http_status_code.h" | 10 #include "net/http/http_status_code.h" |
9 #include "sync/internal_api/public/http_post_provider_factory.h" | 11 #include "sync/internal_api/public/http_post_provider_factory.h" |
10 #include "sync/internal_api/public/http_post_provider_interface.h" | 12 #include "sync/internal_api/public/http_post_provider_interface.h" |
11 | 13 |
12 namespace syncer { | 14 namespace syncer { |
13 | 15 |
14 SyncAPIBridgedConnection::SyncAPIBridgedConnection( | 16 SyncAPIBridgedConnection::SyncAPIBridgedConnection( |
15 ServerConnectionManager* scm, | 17 ServerConnectionManager* scm, |
16 HttpPostProviderFactory* factory) | 18 HttpPostProviderFactory* factory) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 if (!http->MakeSynchronousPost(&error_code, &response_code)) { | 55 if (!http->MakeSynchronousPost(&error_code, &response_code)) { |
54 DVLOG(1) << "Http POST failed, error returns: " << error_code; | 56 DVLOG(1) << "Http POST failed, error returns: " << error_code; |
55 response->server_status = HttpResponse::ServerConnectionCodeFromNetError( | 57 response->server_status = HttpResponse::ServerConnectionCodeFromNetError( |
56 error_code); | 58 error_code); |
57 return false; | 59 return false; |
58 } | 60 } |
59 | 61 |
60 // We got a server response, copy over response codes and content. | 62 // We got a server response, copy over response codes and content. |
61 response->response_code = response_code; | 63 response->response_code = response_code; |
62 response->content_length = | 64 response->content_length = |
63 static_cast<int64>(http->GetResponseContentLength()); | 65 static_cast<int64_t>(http->GetResponseContentLength()); |
64 response->payload_length = | 66 response->payload_length = |
65 static_cast<int64>(http->GetResponseContentLength()); | 67 static_cast<int64_t>(http->GetResponseContentLength()); |
66 if (response->response_code < 400) | 68 if (response->response_code < 400) |
67 response->server_status = HttpResponse::SERVER_CONNECTION_OK; | 69 response->server_status = HttpResponse::SERVER_CONNECTION_OK; |
68 else if (response->response_code == net::HTTP_UNAUTHORIZED) | 70 else if (response->response_code == net::HTTP_UNAUTHORIZED) |
69 response->server_status = HttpResponse::SYNC_AUTH_ERROR; | 71 response->server_status = HttpResponse::SYNC_AUTH_ERROR; |
70 else | 72 else |
71 response->server_status = HttpResponse::SYNC_SERVER_ERROR; | 73 response->server_status = HttpResponse::SYNC_SERVER_ERROR; |
72 | 74 |
73 // Write the content into our buffer. | 75 // Write the content into our buffer. |
74 buffer_.assign(http->GetResponseContent(), http->GetResponseContentLength()); | 76 buffer_.assign(http->GetResponseContent(), http->GetResponseContentLength()); |
75 return true; | 77 return true; |
(...skipping 19 matching lines...) Expand all Loading... |
95 } | 97 } |
96 | 98 |
97 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} | 99 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} |
98 | 100 |
99 ServerConnectionManager::Connection* | 101 ServerConnectionManager::Connection* |
100 SyncAPIServerConnectionManager::MakeConnection() { | 102 SyncAPIServerConnectionManager::MakeConnection() { |
101 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); | 103 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); |
102 } | 104 } |
103 | 105 |
104 } // namespace syncer | 106 } // namespace syncer |
OLD | NEW |