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/browser/chromeos/gdata/gdata_operations.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_operations.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 13 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 14 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
15 #include "chrome/common/net/gaia/gaia_urls.h" | 15 #include "chrome/common/net/gaia/gaia_urls.h" |
16 #include "chrome/common/net/gaia/google_service_auth_error.h" | 16 #include "chrome/common/net/gaia/google_service_auth_error.h" |
17 #include "chrome/common/net/url_util.h" | 17 #include "chrome/common/net/url_util.h" |
| 18 #include "content/public/common/url_fetcher.h" |
18 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
19 #include "net/http/http_util.h" | 20 #include "net/http/http_util.h" |
20 #include "third_party/libxml/chromium/libxml_utils.h" | 21 #include "third_party/libxml/chromium/libxml_utils.h" |
21 | 22 |
22 using content::BrowserThread; | 23 using content::BrowserThread; |
23 using content::URLFetcher; | 24 using net::URLFetcher; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // Used for success ratio histograms. 0 for failure, 1 for success, | 28 // Used for success ratio histograms. 0 for failure, 1 for success, |
28 // 2 for no connection (likely offline). | 29 // 2 for no connection (likely offline). |
29 const int kSuccessRatioHistogramFailure = 0; | 30 const int kSuccessRatioHistogramFailure = 0; |
30 const int kSuccessRatioHistogramSuccess = 1; | 31 const int kSuccessRatioHistogramSuccess = 1; |
31 const int kSuccessRatioHistogramNoConnection = 2; | 32 const int kSuccessRatioHistogramNoConnection = 2; |
32 const int kSuccessRatioHistogramMaxValue = 3; // The max value is exclusive. | 33 const int kSuccessRatioHistogramMaxValue = 3; // The max value is exclusive. |
33 | 34 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 253 |
253 UrlFetchOperationBase::~UrlFetchOperationBase() {} | 254 UrlFetchOperationBase::~UrlFetchOperationBase() {} |
254 | 255 |
255 void UrlFetchOperationBase::Start(const std::string& auth_token) { | 256 void UrlFetchOperationBase::Start(const std::string& auth_token) { |
256 DCHECK(!auth_token.empty()); | 257 DCHECK(!auth_token.empty()); |
257 | 258 |
258 GURL url = GetURL(); | 259 GURL url = GetURL(); |
259 DCHECK(!url.is_empty()); | 260 DCHECK(!url.is_empty()); |
260 DVLOG(1) << "URL: " << url.spec(); | 261 DVLOG(1) << "URL: " << url.spec(); |
261 | 262 |
262 url_fetcher_.reset(URLFetcher::Create(url, GetRequestType(), this)); | 263 url_fetcher_.reset( |
| 264 content::URLFetcher::Create(url, GetRequestType(), this)); |
263 url_fetcher_->SetRequestContext(g_browser_process->system_request_context()); | 265 url_fetcher_->SetRequestContext(g_browser_process->system_request_context()); |
264 // Always set flags to neither send nor save cookies. | 266 // Always set flags to neither send nor save cookies. |
265 url_fetcher_->SetLoadFlags( | 267 url_fetcher_->SetLoadFlags( |
266 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES | | 268 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES | |
267 net::LOAD_DISABLE_CACHE); | 269 net::LOAD_DISABLE_CACHE); |
268 if (save_temp_file_) { | 270 if (save_temp_file_) { |
269 url_fetcher_->SaveResponseToTemporaryFile( | 271 url_fetcher_->SaveResponseToTemporaryFile( |
270 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | 272 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |
271 } else if (!output_file_path_.empty()) { | 273 } else if (!output_file_path_.empty()) { |
272 url_fetcher_->SaveResponseToFileAtPath(output_file_path_, | 274 url_fetcher_->SaveResponseToFileAtPath(output_file_path_, |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 return true; | 1072 return true; |
1071 } | 1073 } |
1072 | 1074 |
1073 void ResumeUploadOperation::OnURLFetchUploadProgress( | 1075 void ResumeUploadOperation::OnURLFetchUploadProgress( |
1074 const net::URLFetcher* source, int64 current, int64 total) { | 1076 const net::URLFetcher* source, int64 current, int64 total) { |
1075 // Adjust the progress values according to the range currently uploaded. | 1077 // Adjust the progress values according to the range currently uploaded. |
1076 NotifyProgress(params_.start_range + current, params_.content_length); | 1078 NotifyProgress(params_.start_range + current, params_.content_length); |
1077 } | 1079 } |
1078 | 1080 |
1079 } // namespace gdata | 1081 } // namespace gdata |
OLD | NEW |