| 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/message_loop_proxy.h" | 8 #include "base/message_loop/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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Wake the blocked thread in Post. | 34 // Wake the blocked thread in Post. |
| 35 http_post_completed_.Signal(); | 35 http_post_completed_.Signal(); |
| 36 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 36 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool ServiceGaiaAuthenticator::Post(const GURL& url, | 39 bool ServiceGaiaAuthenticator::Post(const GURL& url, |
| 40 const std::string& post_body, | 40 const std::string& post_body, |
| 41 unsigned long* response_code, | 41 unsigned long* response_code, |
| 42 std::string* response_body) { | 42 std::string* response_body) { |
| 43 DCHECK(url.SchemeIsSecure()); | 43 DCHECK(url.SchemeIsSecure()); |
| 44 DCHECK(io_message_loop_proxy_); | 44 DCHECK(io_message_loop_proxy_.get()); |
| 45 io_message_loop_proxy_->PostTask( | 45 io_message_loop_proxy_->PostTask( |
| 46 FROM_HERE, | 46 FROM_HERE, |
| 47 base::Bind(&ServiceGaiaAuthenticator::DoPost, this, url, post_body)); | 47 base::Bind(&ServiceGaiaAuthenticator::DoPost, this, url, post_body)); |
| 48 // TODO(sanjeevr): Waiting here until the network request completes is not | 48 // TODO(sanjeevr): Waiting here until the network request completes is not |
| 49 // desirable. We need to change Post to be asynchronous. | 49 // desirable. We need to change Post to be asynchronous. |
| 50 // Block until network request completes. See OnURLFetchComplete. | 50 // Block until network request completes. See OnURLFetchComplete. |
| 51 http_post_completed_.Wait(); | 51 http_post_completed_.Wait(); |
| 52 | 52 |
| 53 *response_code = static_cast<int>(http_response_code_); | 53 *response_code = static_cast<int>(http_response_code_); |
| 54 *response_body = response_data_; | 54 *response_body = response_data_; |
| (...skipping 23 matching lines...) Expand all 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 net::URLFetcher* request = net::URLFetcher::Create( | 81 net::URLFetcher* request = net::URLFetcher::Create( |
| 82 post_url, net::URLFetcher::POST, this); | 82 post_url, net::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 |