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

Side by Side Diff: chrome/browser/google_apis/base_requests.cc

Issue 63923002: net: Use SequencedTaskRunner for URLFetcherResponseWriter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add include Created 7 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) 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/google_apis/base_requests.h" 5 #include "chrome/browser/google_apis/base_requests.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/sequenced_task_runner.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/google_apis/request_sender.h" 14 #include "chrome/browser/google_apis/request_sender.h"
14 #include "chrome/browser/google_apis/task_util.h" 15 #include "chrome/browser/google_apis/task_util.h"
15 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
16 #include "net/base/load_flags.h" 17 #include "net/base/load_flags.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 #include "net/http/http_byte_range.h" 19 #include "net/http/http_byte_range.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const std::string& json, 96 const std::string& json,
96 const ParseJsonCallback& callback) { 97 const ParseJsonCallback& callback) {
97 base::PostTaskAndReplyWithResult( 98 base::PostTaskAndReplyWithResult(
98 blocking_task_runner, 99 blocking_task_runner,
99 FROM_HERE, 100 FROM_HERE,
100 base::Bind(&ParseJsonOnBlockingPool, json), 101 base::Bind(&ParseJsonOnBlockingPool, json),
101 callback); 102 callback);
102 } 103 }
103 104
104 //=========================== ResponseWriter ================================== 105 //=========================== ResponseWriter ==================================
105 ResponseWriter::ResponseWriter(base::TaskRunner* file_task_runner, 106 ResponseWriter::ResponseWriter(base::SequencedTaskRunner* file_task_runner,
106 const base::FilePath& file_path, 107 const base::FilePath& file_path,
107 const GetContentCallback& get_content_callback) 108 const GetContentCallback& get_content_callback)
108 : get_content_callback_(get_content_callback) { 109 : get_content_callback_(get_content_callback) {
109 if (!file_path.empty()) { 110 if (!file_path.empty()) {
110 file_writer_.reset( 111 file_writer_.reset(
111 new net::URLFetcherFileWriter(file_task_runner, file_path)); 112 new net::URLFetcherFileWriter(file_task_runner, file_path));
112 } 113 }
113 } 114 }
114 115
115 ResponseWriter::~ResponseWriter() { 116 ResponseWriter::~ResponseWriter() {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 code = GDATA_OTHER_ERROR; 296 code = GDATA_OTHER_ERROR;
296 } 297 }
297 } 298 }
298 return code; 299 return code;
299 } 300 }
300 301
301 bool UrlFetchRequestBase::CalledOnValidThread() { 302 bool UrlFetchRequestBase::CalledOnValidThread() {
302 return thread_checker_.CalledOnValidThread(); 303 return thread_checker_.CalledOnValidThread();
303 } 304 }
304 305
305 base::TaskRunner* UrlFetchRequestBase::blocking_task_runner() const { 306 base::SequencedTaskRunner* UrlFetchRequestBase::blocking_task_runner() const {
306 return sender_->blocking_task_runner(); 307 return sender_->blocking_task_runner();
307 } 308 }
308 309
309 void UrlFetchRequestBase::OnProcessURLFetchResultsComplete() { 310 void UrlFetchRequestBase::OnProcessURLFetchResultsComplete() {
310 sender_->RequestFinished(this); 311 sender_->RequestFinished(this);
311 } 312 }
312 313
313 void UrlFetchRequestBase::OnURLFetchComplete(const URLFetcher* source) { 314 void UrlFetchRequestBase::OnURLFetchComplete(const URLFetcher* source) {
314 GDataErrorCode code = GetErrorCode(source); 315 GDataErrorCode code = GetErrorCode(source);
315 DVLOG(1) << "Response headers:\n" << GetResponseHeadersAsString(source); 316 DVLOG(1) << "Response headers:\n" << GetResponseHeadersAsString(source);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 download_action_callback_.Run(code, temp_file); 720 download_action_callback_.Run(code, temp_file);
720 OnProcessURLFetchResultsComplete(); 721 OnProcessURLFetchResultsComplete();
721 } 722 }
722 723
723 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( 724 void DownloadFileRequestBase::RunCallbackOnPrematureFailure(
724 GDataErrorCode code) { 725 GDataErrorCode code) {
725 download_action_callback_.Run(code, base::FilePath()); 726 download_action_callback_.Run(code, base::FilePath());
726 } 727 }
727 728
728 } // namespace google_apis 729 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698