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

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: 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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const std::string& json, 95 const std::string& json,
96 const ParseJsonCallback& callback) { 96 const ParseJsonCallback& callback) {
97 base::PostTaskAndReplyWithResult( 97 base::PostTaskAndReplyWithResult(
98 blocking_task_runner, 98 blocking_task_runner,
99 FROM_HERE, 99 FROM_HERE,
100 base::Bind(&ParseJsonOnBlockingPool, json), 100 base::Bind(&ParseJsonOnBlockingPool, json),
101 callback); 101 callback);
102 } 102 }
103 103
104 //=========================== ResponseWriter ================================== 104 //=========================== ResponseWriter ==================================
105 ResponseWriter::ResponseWriter(base::TaskRunner* file_task_runner, 105 ResponseWriter::ResponseWriter(base::SequencedTaskRunner* file_task_runner,
106 const base::FilePath& file_path, 106 const base::FilePath& file_path,
107 const GetContentCallback& get_content_callback) 107 const GetContentCallback& get_content_callback)
108 : get_content_callback_(get_content_callback) { 108 : get_content_callback_(get_content_callback) {
109 if (!file_path.empty()) { 109 if (!file_path.empty()) {
110 file_writer_.reset( 110 file_writer_.reset(
111 new net::URLFetcherFileWriter(file_task_runner, file_path)); 111 new net::URLFetcherFileWriter(file_task_runner, file_path));
mmenke 2013/11/07 17:02:36 Don't we need sequenced_task_runner here, to incre
hashimoto 2013/11/08 04:08:17 chrome/browser/google_apis/task_util.h includes se
112 } 112 }
113 } 113 }
114 114
115 ResponseWriter::~ResponseWriter() { 115 ResponseWriter::~ResponseWriter() {
116 } 116 }
117 117
118 void ResponseWriter::DisownFile() { 118 void ResponseWriter::DisownFile() {
119 DCHECK(file_writer_); 119 DCHECK(file_writer_);
120 file_writer_->DisownFile(); 120 file_writer_->DisownFile();
121 } 121 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 code = GDATA_OTHER_ERROR; 295 code = GDATA_OTHER_ERROR;
296 } 296 }
297 } 297 }
298 return code; 298 return code;
299 } 299 }
300 300
301 bool UrlFetchRequestBase::CalledOnValidThread() { 301 bool UrlFetchRequestBase::CalledOnValidThread() {
302 return thread_checker_.CalledOnValidThread(); 302 return thread_checker_.CalledOnValidThread();
303 } 303 }
304 304
305 base::TaskRunner* UrlFetchRequestBase::blocking_task_runner() const { 305 base::SequencedTaskRunner* UrlFetchRequestBase::blocking_task_runner() const {
306 return sender_->blocking_task_runner(); 306 return sender_->blocking_task_runner();
307 } 307 }
308 308
309 void UrlFetchRequestBase::OnProcessURLFetchResultsComplete() { 309 void UrlFetchRequestBase::OnProcessURLFetchResultsComplete() {
310 sender_->RequestFinished(this); 310 sender_->RequestFinished(this);
311 } 311 }
312 312
313 void UrlFetchRequestBase::OnURLFetchComplete(const URLFetcher* source) { 313 void UrlFetchRequestBase::OnURLFetchComplete(const URLFetcher* source) {
314 GDataErrorCode code = GetErrorCode(source); 314 GDataErrorCode code = GetErrorCode(source);
315 DVLOG(1) << "Response headers:\n" << GetResponseHeadersAsString(source); 315 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); 719 download_action_callback_.Run(code, temp_file);
720 OnProcessURLFetchResultsComplete(); 720 OnProcessURLFetchResultsComplete();
721 } 721 }
722 722
723 void DownloadFileRequestBase::RunCallbackOnPrematureFailure( 723 void DownloadFileRequestBase::RunCallbackOnPrematureFailure(
724 GDataErrorCode code) { 724 GDataErrorCode code) {
725 download_action_callback_.Run(code, base::FilePath()); 725 download_action_callback_.Run(code, base::FilePath());
726 } 726 }
727 727
728 } // namespace google_apis 728 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698