Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/service/gaia/service_gaia_authenticator.cc

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
11 12
12 ServiceGaiaAuthenticator::ServiceGaiaAuthenticator( 13 ServiceGaiaAuthenticator::ServiceGaiaAuthenticator(
13 const std::string& user_agent, const std::string& service_id, 14 const std::string& user_agent, const std::string& service_id,
14 const std::string& gaia_url, 15 const std::string& gaia_url,
15 base::MessageLoopProxy* io_message_loop_proxy) 16 base::MessageLoopProxy* io_message_loop_proxy)
16 : gaia::GaiaAuthenticator(user_agent, service_id, gaia_url), 17 : gaia::GaiaAuthenticator(user_agent, service_id, gaia_url),
17 http_post_completed_(false, false), 18 http_post_completed_(false, false),
18 io_message_loop_proxy_(io_message_loop_proxy), 19 io_message_loop_proxy_(io_message_loop_proxy),
19 http_response_code_(0) { 20 http_response_code_(0) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url, 64 void ServiceGaiaAuthenticator::DoPost(const GURL& post_url,
64 const std::string& post_body) { 65 const std::string& post_body) {
65 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 66 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
66 URLFetcher* request = new URLFetcher(post_url, URLFetcher::POST, this); 67 URLFetcher* request = new URLFetcher(post_url, URLFetcher::POST, this);
67 request->set_request_context( 68 request->set_request_context(
68 g_service_process->GetServiceURLRequestContextGetter()); 69 g_service_process->GetServiceURLRequestContextGetter());
69 request->set_upload_data("application/x-www-form-urlencoded", post_body); 70 request->set_upload_data("application/x-www-form-urlencoded", post_body);
70 request->Start(); 71 request->Start();
71 } 72 }
72 73
73 // URLFetcher::Delegate implementation 74 // content::URLFetcherDelegate implementation
74 void ServiceGaiaAuthenticator::OnURLFetchComplete(const URLFetcher* source) { 75 void ServiceGaiaAuthenticator::OnURLFetchComplete(const URLFetcher* source) {
75 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 76 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
76 http_response_code_ = source->response_code(); 77 http_response_code_ = source->response_code();
77 response_data_ = source->GetResponseStringRef(); 78 source->GetResponseAsString(&response_data_);
78 delete source; 79 delete source;
79 // Add an extra reference because we want http_post_completed_ to remain 80 // Add an extra reference because we want http_post_completed_ to remain
80 // valid until after Signal() returns. 81 // valid until after Signal() returns.
81 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this); 82 scoped_refptr<ServiceGaiaAuthenticator> keep_alive(this);
82 // Wake the blocked thread in Post. 83 // Wake the blocked thread in Post.
83 http_post_completed_.Signal(); 84 http_post_completed_.Signal();
84 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted! 85 // WARNING: DONT DO ANYTHING AFTER THIS CALL! |this| may be deleted!
85 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698