| Index: chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc
|
| diff --git a/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc b/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc
|
| index fa0c15fe134cd9ddc43adedebf8fcb5cfd8d36fc..cf852c7a1f39f6084862561abc6e018fa8f26122 100644
|
| --- a/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc
|
| +++ b/chrome/browser/sync/internal_api/syncapi_server_connection_manager.cc
|
| @@ -8,30 +8,36 @@
|
| #include "chrome/browser/sync/internal_api/http_post_provider_interface.h"
|
| #include "chrome/browser/sync/util/oauth.h"
|
| #include "chrome/common/net/http_return.h"
|
| +#include "net/base/net_errors.h"
|
|
|
| using browser_sync::HttpResponse;
|
|
|
| namespace sync_api {
|
|
|
| -SyncAPIBridgedPost::SyncAPIBridgedPost(
|
| +SyncAPIBridgedConnection::SyncAPIBridgedConnection(
|
| browser_sync::ServerConnectionManager* scm,
|
| HttpPostProviderFactory* factory)
|
| - : Post(scm), factory_(factory) {
|
| + : Connection(scm), factory_(factory) {
|
| + post_provider_ = factory_->Create();
|
| }
|
|
|
| -SyncAPIBridgedPost::~SyncAPIBridgedPost() {}
|
| +SyncAPIBridgedConnection::~SyncAPIBridgedConnection() {
|
| + DCHECK(post_provider_);
|
| + factory_->Destroy(post_provider_);
|
| + post_provider_ = NULL;
|
| +}
|
|
|
| -bool SyncAPIBridgedPost::Init(const char* path,
|
| - const std::string& auth_token,
|
| - const std::string& payload,
|
| - HttpResponse* response) {
|
| +bool SyncAPIBridgedConnection::Init(const char* path,
|
| + const std::string& auth_token,
|
| + const std::string& payload,
|
| + HttpResponse* response) {
|
| std::string sync_server;
|
| int sync_server_port = 0;
|
| bool use_ssl = false;
|
| GetServerParams(&sync_server, &sync_server_port, &use_ssl);
|
| std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl);
|
|
|
| - HttpPostProviderInterface* http = factory_->Create();
|
| + HttpPostProviderInterface* http = post_provider_;
|
| http->SetUserAgent(scm_->user_agent().c_str());
|
| http->SetURL(connection_url.c_str(), sync_server_port);
|
|
|
| @@ -54,8 +60,8 @@ bool SyncAPIBridgedPost::Init(const char* path,
|
| int response_code = 0;
|
| if (!http->MakeSynchronousPost(&os_error_code, &response_code)) {
|
| VLOG(1) << "Http POST failed, error returns: " << os_error_code;
|
| - response->server_status = HttpResponse::IO_ERROR;
|
| - factory_->Destroy(http);
|
| + response->server_status = os_error_code == net::ERR_ABORTED ?
|
| + HttpResponse::CONNECTION_UNAVAILABLE : HttpResponse::IO_ERROR;
|
| return false;
|
| }
|
|
|
| @@ -77,12 +83,14 @@ bool SyncAPIBridgedPost::Init(const char* path,
|
|
|
| // Write the content into our buffer.
|
| buffer_.assign(http->GetResponseContent(), http->GetResponseContentLength());
|
| -
|
| - // We're done with the HttpPostProvider.
|
| - factory_->Destroy(http);
|
| return true;
|
| }
|
|
|
| +void SyncAPIBridgedConnection::Abort() {
|
| + DCHECK(post_provider_);
|
| + post_provider_->Abort();
|
| +}
|
| +
|
| SyncAPIServerConnectionManager::SyncAPIServerConnectionManager(
|
| const std::string& server,
|
| int port,
|
| @@ -96,9 +104,9 @@ SyncAPIServerConnectionManager::SyncAPIServerConnectionManager(
|
|
|
| SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {}
|
|
|
| -browser_sync::ServerConnectionManager::Post*
|
| -SyncAPIServerConnectionManager::MakePost() {
|
| - return new SyncAPIBridgedPost(this, post_provider_factory_.get());
|
| +browser_sync::ServerConnectionManager::Connection*
|
| +SyncAPIServerConnectionManager::MakeConnection() {
|
| + return new SyncAPIBridgedConnection(this, post_provider_factory_.get());
|
| }
|
|
|
| } // namespace sync_api
|
|
|