| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/engine/net/syncapi_server_connection_manager.h" | 5 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sync/engine/syncapi.h" | 7 #include "chrome/browser/sync/engine/syncapi.h" |
| 8 #include "chrome/common/net/http_return.h" | 8 #include "chrome/common/net/http_return.h" |
| 9 | 9 |
| 10 using browser_sync::HttpResponse; | 10 using browser_sync::HttpResponse; |
| 11 using std::string; | 11 using std::string; |
| 12 | 12 |
| 13 namespace sync_api { | 13 namespace sync_api { |
| 14 | 14 |
| 15 SyncAPIBridgedPost::SyncAPIBridgedPost( |
| 16 browser_sync::ServerConnectionManager* scm, |
| 17 HttpPostProviderFactory* factory) |
| 18 : Post(scm), factory_(factory) { |
| 19 } |
| 20 |
| 21 SyncAPIBridgedPost::~SyncAPIBridgedPost() {} |
| 22 |
| 23 |
| 15 bool SyncAPIBridgedPost::Init(const char* path, const string& auth_token, | 24 bool SyncAPIBridgedPost::Init(const char* path, const string& auth_token, |
| 16 const string& payload, HttpResponse* response) { | 25 const string& payload, HttpResponse* response) { |
| 17 string sync_server; | 26 string sync_server; |
| 18 int sync_server_port = 0; | 27 int sync_server_port = 0; |
| 19 bool use_ssl = false; | 28 bool use_ssl = false; |
| 20 GetServerParams(&sync_server, &sync_server_port, &use_ssl); | 29 GetServerParams(&sync_server, &sync_server_port, &use_ssl); |
| 21 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); | 30 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); |
| 22 | 31 |
| 23 HttpPostProviderInterface* http = factory_->Create(); | 32 HttpPostProviderInterface* http = factory_->Create(); |
| 24 http->SetUserAgent(scm_->user_agent().c_str()); | 33 http->SetUserAgent(scm_->user_agent().c_str()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 http->GetResponseHeaderValue("Update-Client-Auth"); | 69 http->GetResponseHeaderValue("Update-Client-Auth"); |
| 61 | 70 |
| 62 // Write the content into our buffer. | 71 // Write the content into our buffer. |
| 63 buffer_.assign(http->GetResponseContent(), http->GetResponseContentLength()); | 72 buffer_.assign(http->GetResponseContent(), http->GetResponseContentLength()); |
| 64 | 73 |
| 65 // We're done with the HttpPostProvider. | 74 // We're done with the HttpPostProvider. |
| 66 factory_->Destroy(http); | 75 factory_->Destroy(http); |
| 67 return true; | 76 return true; |
| 68 } | 77 } |
| 69 | 78 |
| 79 SyncAPIServerConnectionManager::SyncAPIServerConnectionManager( |
| 80 const std::string& server, |
| 81 int port, |
| 82 bool use_ssl, |
| 83 const std::string& client_version, |
| 84 HttpPostProviderFactory* factory) |
| 85 : ServerConnectionManager(server, port, use_ssl, client_version), |
| 86 post_provider_factory_(factory) { |
| 87 DCHECK(post_provider_factory_.get()); |
| 88 } |
| 89 |
| 70 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} | 90 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} |
| 71 | 91 |
| 92 browser_sync::ServerConnectionManager::Post* |
| 93 SyncAPIServerConnectionManager::MakePost() { |
| 94 return new SyncAPIBridgedPost(this, post_provider_factory_.get()); |
| 95 } |
| 96 |
| 97 |
| 72 } // namespace sync_api | 98 } // namespace sync_api |
| OLD | NEW |