| 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 "chrome/service/gaia/service_gaia_authenticator.h" | 5 #include "chrome/service/gaia/service_gaia_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "chrome/service/net/service_url_request_context.h" | 9 #include "chrome/service/net/service_url_request_context.h" |
| 10 #include "chrome/service/service_process.h" | 10 #include "chrome/service/service_process.h" |
| 11 #include "content/public/common/url_fetcher.h" | 11 #include "content/public/common/url_fetcher.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 ServiceGaiaAuthenticator::ServiceGaiaAuthenticator( | 14 ServiceGaiaAuthenticator::ServiceGaiaAuthenticator( |
| 15 const std::string& user_agent, const std::string& service_id, | 15 const std::string& user_agent, const std::string& service_id, |
| 16 const std::string& gaia_url, | 16 const std::string& gaia_url, |
| 17 base::MessageLoopProxy* io_message_loop_proxy) | 17 base::MessageLoopProxy* io_message_loop_proxy) |
| 18 : gaia::GaiaAuthenticator(user_agent, service_id, gaia_url), | 18 : gaia::GaiaAuthenticator(user_agent, service_id, gaia_url), |
| 19 http_post_completed_(false, false), | 19 http_post_completed_(false, false), |
| 20 io_message_loop_proxy_(io_message_loop_proxy), | 20 io_message_loop_proxy_(io_message_loop_proxy), |
| 21 http_response_code_(0) { | 21 http_response_code_(0) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 // content::URLFetcherDelegate implementation | 24 // net::URLFetcherDelegate implementation |
| 25 void ServiceGaiaAuthenticator::OnURLFetchComplete( | 25 void ServiceGaiaAuthenticator::OnURLFetchComplete( |
| 26 const net::URLFetcher* source) { | 26 const net::URLFetcher* source) { |
| 27 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 27 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 28 http_response_code_ = source->GetResponseCode(); | 28 http_response_code_ = source->GetResponseCode(); |
| 29 source->GetResponseAsString(&response_data_); | 29 source->GetResponseAsString(&response_data_); |
| 30 delete source; | 30 delete source; |
| 31 // Add an extra reference because we want http_post_completed_ to remain | 31 // Add an extra reference because we want http_post_completed_ to remain |
| 32 // valid until after Signal() returns. | 32 // valid until after Signal() returns. |
| 33 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this); | 33 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this); |
| 34 // Wake the blocked thread in Post. | 34 // Wake the blocked thread in Post. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, | 78 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, |
| 79 const std::string& post_body) { | 79 const std::string& post_body) { |
| 80 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 80 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 81 content::URLFetcher* request = content::URLFetcher::Create( | 81 content::URLFetcher* request = content::URLFetcher::Create( |
| 82 post_url, content::URLFetcher::POST, this); | 82 post_url, content::URLFetcher::POST, this); |
| 83 request->SetRequestContext( | 83 request->SetRequestContext( |
| 84 g_service_process->GetServiceURLRequestContextGetter()); | 84 g_service_process->GetServiceURLRequestContextGetter()); |
| 85 request->SetUploadData("application/x-www-form-urlencoded", post_body); | 85 request->SetUploadData("application/x-www-form-urlencoded", post_body); |
| 86 request->Start(); | 86 request->Start(); |
| 87 } | 87 } |
| OLD | NEW |