| 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 "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 8 #include "net/http/http_status_code.h" | 8 #include "net/http/http_status_code.h" |
| 9 #include "sync/internal_api/public/http_post_provider_factory.h" | 9 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 10 #include "sync/internal_api/public/http_post_provider_interface.h" | 10 #include "sync/internal_api/public/http_post_provider_interface.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const std::string& auth_token, | 30 const std::string& auth_token, |
| 31 const std::string& payload, | 31 const std::string& payload, |
| 32 HttpResponse* response) { | 32 HttpResponse* response) { |
| 33 std::string sync_server; | 33 std::string sync_server; |
| 34 int sync_server_port = 0; | 34 int sync_server_port = 0; |
| 35 bool use_ssl = false; | 35 bool use_ssl = false; |
| 36 GetServerParams(&sync_server, &sync_server_port, &use_ssl); | 36 GetServerParams(&sync_server, &sync_server_port, &use_ssl); |
| 37 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); | 37 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); |
| 38 | 38 |
| 39 HttpPostProviderInterface* http = post_provider_; | 39 HttpPostProviderInterface* http = post_provider_; |
| 40 http->SetUserAgent(scm_->user_agent().c_str()); | |
| 41 http->SetURL(connection_url.c_str(), sync_server_port); | 40 http->SetURL(connection_url.c_str(), sync_server_port); |
| 42 | 41 |
| 43 if (!auth_token.empty()) { | 42 if (!auth_token.empty()) { |
| 44 const std::string& headers = | 43 const std::string& headers = |
| 45 "Authorization: GoogleLogin auth=" + auth_token; | 44 "Authorization: GoogleLogin auth=" + auth_token; |
| 46 http->SetExtraRequestHeaders(headers.c_str()); | 45 http->SetExtraRequestHeaders(headers.c_str()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 // 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. |
| 50 http->SetPostPayload("application/octet-stream", payload.length(), | 49 http->SetPostPayload("application/octet-stream", payload.length(), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 82 |
| 84 void SyncAPIBridgedConnection::Abort() { | 83 void SyncAPIBridgedConnection::Abort() { |
| 85 DCHECK(post_provider_); | 84 DCHECK(post_provider_); |
| 86 post_provider_->Abort(); | 85 post_provider_->Abort(); |
| 87 } | 86 } |
| 88 | 87 |
| 89 SyncAPIServerConnectionManager::SyncAPIServerConnectionManager( | 88 SyncAPIServerConnectionManager::SyncAPIServerConnectionManager( |
| 90 const std::string& server, | 89 const std::string& server, |
| 91 int port, | 90 int port, |
| 92 bool use_ssl, | 91 bool use_ssl, |
| 93 const std::string& client_version, | |
| 94 HttpPostProviderFactory* factory) | 92 HttpPostProviderFactory* factory) |
| 95 : ServerConnectionManager(server, port, use_ssl, client_version), | 93 : ServerConnectionManager(server, port, use_ssl), |
| 96 post_provider_factory_(factory) { | 94 post_provider_factory_(factory) { |
| 97 DCHECK(post_provider_factory_.get()); | 95 DCHECK(post_provider_factory_.get()); |
| 98 } | 96 } |
| 99 | 97 |
| 100 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} | 98 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} |
| 101 | 99 |
| 102 csync::ServerConnectionManager::Connection* | 100 csync::ServerConnectionManager::Connection* |
| 103 SyncAPIServerConnectionManager::MakeConnection() { | 101 SyncAPIServerConnectionManager::MakeConnection() { |
| 104 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); | 102 return new SyncAPIBridgedConnection(this, post_provider_factory_.get()); |
| 105 } | 103 } |
| 106 | 104 |
| 107 } // namespace csync | 105 } // namespace csync |
| OLD | NEW |