| 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/cloud_print/cloud_print_url_fetcher.h" | 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 CloudPrintURLFetcherFactory* factory) { | 99 CloudPrintURLFetcherFactory* factory) { |
| 100 g_test_factory = factory; | 100 g_test_factory = factory; |
| 101 } | 101 } |
| 102 | 102 |
| 103 CloudPrintURLFetcher::ResponseAction | 103 CloudPrintURLFetcher::ResponseAction |
| 104 CloudPrintURLFetcher::Delegate::HandleRawResponse( | 104 CloudPrintURLFetcher::Delegate::HandleRawResponse( |
| 105 const net::URLFetcher* source, | 105 const net::URLFetcher* source, |
| 106 const GURL& url, | 106 const GURL& url, |
| 107 const net::URLRequestStatus& status, | 107 const net::URLRequestStatus& status, |
| 108 int response_code, | 108 int response_code, |
| 109 const net::ResponseCookies& cookies, | |
| 110 const std::string& data) { | 109 const std::string& data) { |
| 111 return CONTINUE_PROCESSING; | 110 return CONTINUE_PROCESSING; |
| 112 } | 111 } |
| 113 | 112 |
| 114 CloudPrintURLFetcher::ResponseAction | 113 CloudPrintURLFetcher::ResponseAction |
| 115 CloudPrintURLFetcher::Delegate::HandleRawData( | 114 CloudPrintURLFetcher::Delegate::HandleRawData( |
| 116 const net::URLFetcher* source, | 115 const net::URLFetcher* source, |
| 117 const GURL& url, | 116 const GURL& url, |
| 118 const std::string& data) { | 117 const std::string& data) { |
| 119 return CONTINUE_PROCESSING; | 118 return CONTINUE_PROCESSING; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_refptr<CloudPrintURLFetcher> keep_alive(this); | 167 scoped_refptr<CloudPrintURLFetcher> keep_alive(this); |
| 169 std::string data; | 168 std::string data; |
| 170 source->GetResponseAsString(&data); | 169 source->GetResponseAsString(&data); |
| 171 ReportRequestTime(type_, base::Time::Now() - start_time_); | 170 ReportRequestTime(type_, base::Time::Now() - start_time_); |
| 172 ReportDownloadSize(type_, data.size()); | 171 ReportDownloadSize(type_, data.size()); |
| 173 ResponseAction action = delegate_->HandleRawResponse( | 172 ResponseAction action = delegate_->HandleRawResponse( |
| 174 source, | 173 source, |
| 175 source->GetURL(), | 174 source->GetURL(), |
| 176 source->GetStatus(), | 175 source->GetStatus(), |
| 177 source->GetResponseCode(), | 176 source->GetResponseCode(), |
| 178 source->GetCookies(), | |
| 179 data); | 177 data); |
| 180 | 178 |
| 181 // If we get auth error, notify delegate and check if it wants to proceed. | 179 // If we get auth error, notify delegate and check if it wants to proceed. |
| 182 if (action == CONTINUE_PROCESSING && | 180 if (action == CONTINUE_PROCESSING && |
| 183 source->GetResponseCode() == net::HTTP_FORBIDDEN) { | 181 source->GetResponseCode() == net::HTTP_FORBIDDEN) { |
| 184 action = delegate_->OnRequestAuthError(); | 182 action = delegate_->OnRequestAuthError(); |
| 185 } | 183 } |
| 186 | 184 |
| 187 if (action == CONTINUE_PROCESSING) { | 185 if (action == CONTINUE_PROCESSING) { |
| 188 // We need to retry on all network errors. | 186 // We need to retry on all network errors. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 ServiceURLRequestContextGetter* getter = | 293 ServiceURLRequestContextGetter* getter = |
| 296 g_service_process->GetServiceURLRequestContextGetter(); | 294 g_service_process->GetServiceURLRequestContextGetter(); |
| 297 // Now set up the user agent for cloudprint. | 295 // Now set up the user agent for cloudprint. |
| 298 std::string user_agent = getter->user_agent(); | 296 std::string user_agent = getter->user_agent(); |
| 299 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); | 297 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); |
| 300 getter->set_user_agent(user_agent); | 298 getter->set_user_agent(user_agent); |
| 301 return getter; | 299 return getter; |
| 302 } | 300 } |
| 303 | 301 |
| 304 } // namespace cloud_print | 302 } // namespace cloud_print |
| OLD | NEW |