summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-24 18:18:34 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-24 18:18:34 +0000
commitc530c85aa67a10aac9a77d10970951633ff686d9 (patch)
tree5b0943bd7369f48053075a75db9cf6e5a0d1514d /chrome/service
parentb4c95f61571c24ea1fc15fed0eda1269fe75d94b (diff)
downloadchromium_src-c530c85aa67a10aac9a77d10970951633ff686d9.zip
chromium_src-c530c85aa67a10aac9a77d10970951633ff686d9.tar.gz
chromium_src-c530c85aa67a10aac9a77d10970951633ff686d9.tar.bz2
Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old URLFetcher delegate callback while I'm touching all of them.BUG=98716,83592
Review URL: http://codereview.chromium.org/8373021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106949 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/cloud_print/cloud_print_url_fetcher.cc36
-rw-r--r--chrome/service/cloud_print/cloud_print_url_fetcher.h14
-rw-r--r--chrome/service/gaia/service_gaia_authenticator.cc5
-rw-r--r--chrome/service/gaia/service_gaia_authenticator.h7
4 files changed, 30 insertions, 32 deletions
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.cc b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
index 297d56c..2604392 100644
--- a/chrome/service/cloud_print/cloud_print_url_fetcher.cc
+++ b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
@@ -50,38 +50,34 @@ void CloudPrintURLFetcher::StartPostRequest(
additional_headers);
}
- // URLFetcher::Delegate implementation.
-void CloudPrintURLFetcher::OnURLFetchComplete(
- const URLFetcher* source,
- const GURL& url,
- const net::URLRequestStatus& status,
- int response_code,
- const net::ResponseCookies& cookies,
- const std::string& data) {
- VLOG(1) << "CP_PROXY: OnURLFetchComplete, url: " << url
- << ", response code: " << response_code;
+void CloudPrintURLFetcher::OnURLFetchComplete(const URLFetcher* source) {
+ VLOG(1) << "CP_PROXY: OnURLFetchComplete, url: " << source->url()
+ << ", response code: " << source->response_code();
// Make sure we stay alive through the body of this function.
scoped_refptr<CloudPrintURLFetcher> keep_alive(this);
- ResponseAction action = delegate_->HandleRawResponse(source,
- url,
- status,
- response_code,
- cookies,
- data);
+ std::string data;
+ source->GetResponseAsString(&data);
+ ResponseAction action = delegate_->HandleRawResponse(
+ source,
+ source->url(),
+ source->status(),
+ source->response_code(),
+ source->cookies(),
+ data);
if (action == CONTINUE_PROCESSING) {
// If we are not using an OAuth token, and we got an auth error, we are
// done. Else, the token may have been refreshed. Let us try again.
- if ((RC_FORBIDDEN == response_code) &&
+ if ((RC_FORBIDDEN == source->response_code()) &&
(!CloudPrintTokenStore::current() ||
!CloudPrintTokenStore::current()->token_is_oauth())) {
delegate_->OnRequestAuthError();
return;
}
// We need to retry on all network errors.
- if (!status.is_success() || (response_code != 200))
+ if (!source->status().is_success() || (source->response_code() != 200))
action = RETRY_REQUEST;
else
- action = delegate_->HandleRawData(source, url, data);
+ action = delegate_->HandleRawData(source, source->url(), data);
if (action == CONTINUE_PROCESSING) {
// If the delegate is not interested in handling the raw response data,
@@ -93,7 +89,7 @@ void CloudPrintURLFetcher::OnURLFetchComplete(
CloudPrintHelpers::ParseResponseJSON(data, &succeeded, &response_dict);
if (response_dict)
action = delegate_->HandleJSONData(source,
- url,
+ source->url(),
response_dict,
succeeded);
else
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.h b/chrome/service/cloud_print/cloud_print_url_fetcher.h
index ab49923..a872386 100644
--- a/chrome/service/cloud_print/cloud_print_url_fetcher.h
+++ b/chrome/service/cloud_print/cloud_print_url_fetcher.h
@@ -8,8 +8,10 @@
#include <string>
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/common/net/url_fetcher.h"
+#include "content/public/common/url_fetcher_delegate.h"
class GURL;
@@ -18,6 +20,7 @@ class DictionaryValue;
}
namespace net {
+class URLRequestContextGetter;
class URLRequestStatus;
} // namespace net
@@ -28,7 +31,7 @@ class URLRequestStatus;
// must also be retried.
class CloudPrintURLFetcher
: public base::RefCountedThreadSafe<CloudPrintURLFetcher>,
- public URLFetcher::Delegate {
+ public content::URLFetcherDelegate {
public:
enum ResponseAction {
CONTINUE_PROCESSING,
@@ -92,12 +95,9 @@ class CloudPrintURLFetcher
const std::string& post_data,
const std::string& additional_headers);
- // URLFetcher::Delegate implementation.
- virtual void OnURLFetchComplete(const URLFetcher* source, const GURL& url,
- const net::URLRequestStatus& status,
- int response_code,
- const net::ResponseCookies& cookies,
- const std::string& data);
+ // content::URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const URLFetcher* source);
+
protected:
friend class base::RefCountedThreadSafe<CloudPrintURLFetcher>;
virtual ~CloudPrintURLFetcher();
diff --git a/chrome/service/gaia/service_gaia_authenticator.cc b/chrome/service/gaia/service_gaia_authenticator.cc
index 8cfab51..08d1ddd 100644
--- a/chrome/service/gaia/service_gaia_authenticator.cc
+++ b/chrome/service/gaia/service_gaia_authenticator.cc
@@ -7,6 +7,7 @@
#include "base/message_loop_proxy.h"
#include "chrome/service/net/service_url_request_context.h"
#include "chrome/service/service_process.h"
+#include "content/common/net/url_fetcher.h"
#include "googleurl/src/gurl.h"
ServiceGaiaAuthenticator::ServiceGaiaAuthenticator(
@@ -70,11 +71,11 @@ void ServiceGaiaAuthenticator::DoPost(const GURL& post_url,
request->Start();
}
-// URLFetcher::Delegate implementation
+// content::URLFetcherDelegate implementation
void ServiceGaiaAuthenticator::OnURLFetchComplete(const URLFetcher* source) {
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
http_response_code_ = source->response_code();
- response_data_ = source->GetResponseStringRef();
+ source->GetResponseAsString(&response_data_);
delete source;
// Add an extra reference because we want http_post_completed_ to remain
// valid until after Signal() returns.
diff --git a/chrome/service/gaia/service_gaia_authenticator.h b/chrome/service/gaia/service_gaia_authenticator.h
index 6be5a65..8c30cd2 100644
--- a/chrome/service/gaia/service_gaia_authenticator.h
+++ b/chrome/service/gaia/service_gaia_authenticator.h
@@ -8,10 +8,11 @@
#include <string>
+#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/common/net/gaia/gaia_authenticator.h"
-#include "content/common/net/url_fetcher.h"
+#include "content/public/common/url_fetcher_delegate.h"
namespace base {
class MessageLoopProxy;
@@ -21,7 +22,7 @@ class MessageLoopProxy;
// we cannot rely on the existence of a Profile)
class ServiceGaiaAuthenticator
: public base::RefCountedThreadSafe<ServiceGaiaAuthenticator>,
- public URLFetcher::Delegate,
+ public content::URLFetcherDelegate,
public gaia::GaiaAuthenticator {
public:
ServiceGaiaAuthenticator(const std::string& user_agent,
@@ -30,7 +31,7 @@ class ServiceGaiaAuthenticator
base::MessageLoopProxy* io_message_loop_proxy);
virtual ~ServiceGaiaAuthenticator();
- // URLFetcher::Delegate implementation.
+ // content::URLFetcherDelegate implementation.
virtual void OnURLFetchComplete(const URLFetcher *source) OVERRIDE;
protected: