| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "chrome/service/net/service_url_request_context.h" | 8 #include "chrome/service/net/service_url_request_context.h" |
| 9 #include "chrome/service/service_process.h" | 9 #include "chrome/service/service_process.h" |
| 10 #include "content/common/net/url_fetcher.h" | 10 #include "content/common/net/url_fetcher.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 if (ret > kMaxBackoffDelaySeconds) { | 58 if (ret > kMaxBackoffDelaySeconds) { |
| 59 ret = kMaxBackoffDelaySeconds; | 59 ret = kMaxBackoffDelaySeconds; |
| 60 } | 60 } |
| 61 return ret; | 61 return ret; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, | 64 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, |
| 65 const std::string& post_body) { | 65 const std::string& post_body) { |
| 66 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 66 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 67 URLFetcher* request = new URLFetcher(post_url, URLFetcher::POST, this); | 67 URLFetcher* request = new URLFetcher(post_url, URLFetcher::POST, this); |
| 68 request->set_request_context( | 68 request->SetRequestContext( |
| 69 g_service_process->GetServiceURLRequestContextGetter()); | 69 g_service_process->GetServiceURLRequestContextGetter()); |
| 70 request->set_upload_data("application/x-www-form-urlencoded", post_body); | 70 request->SetUploadData("application/x-www-form-urlencoded", post_body); |
| 71 request->Start(); | 71 request->Start(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // content::URLFetcherDelegate implementation | 74 // content::URLFetcherDelegate implementation |
| 75 void ServiceGaiaAuthenticator::OnURLFetchComplete(const URLFetcher* source) { | 75 void ServiceGaiaAuthenticator::OnURLFetchComplete( |
| 76 const content::URLFetcher* source) { |
| 76 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 77 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 77 http_response_code_ = source->response_code(); | 78 http_response_code_ = source->GetResponseCode(); |
| 78 source->GetResponseAsString(&response_data_); | 79 source->GetResponseAsString(&response_data_); |
| 79 delete source; | 80 delete source; |
| 80 // Add an extra reference because we want http_post_completed_ to remain | 81 // Add an extra reference because we want http_post_completed_ to remain |
| 81 // valid until after Signal() returns. | 82 // valid until after Signal() returns. |
| 82 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this); | 83 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this); |
| 83 // Wake the blocked thread in Post. | 84 // Wake the blocked thread in Post. |
| 84 http_post_completed_.Signal(); | 85 http_post_completed_.Signal(); |
| 85 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! | 86 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! |
| 86 } | 87 } |
| OLD | NEW |