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

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

Issue 18742002: Remove direct reference to GetBlockingPool() in c/b/google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix + rebase. Created 7 years, 5 months 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/gdata_wapi_requests.h" 5 #include "chrome/browser/google_apis/gdata_wapi_requests.h"
6 6
7 #include "base/location.h"
7 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
9 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
10 #include "base/threading/sequenced_worker_pool.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 12 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" 13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h"
14 #include "chrome/browser/google_apis/request_sender.h"
14 #include "chrome/browser/google_apis/request_util.h" 15 #include "chrome/browser/google_apis/request_util.h"
15 #include "chrome/browser/google_apis/time_util.h" 16 #include "chrome/browser/google_apis/time_util.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "net/base/escape.h" 17 #include "net/base/escape.h"
18 #include "net/base/url_util.h" 18 #include "net/base/url_util.h"
19 #include "third_party/libxml/chromium/libxml_utils.h" 19 #include "third_party/libxml/chromium/libxml_utils.h"
20 20
21 using content::BrowserThread;
22 using net::URLFetcher; 21 using net::URLFetcher;
23 22
24 namespace google_apis { 23 namespace google_apis {
25 24
26 namespace { 25 namespace {
27 26
28 const char kUploadContentRange[] = "Content-Range: bytes "; 27 const char kUploadContentRange[] = "Content-Range: bytes ";
29 28
30 const char kFeedField[] = "feed"; 29 const char kFeedField[] = "feed";
31 30
(...skipping 18 matching lines...) Expand all
50 49
51 // resource_list being NULL indicates there was a parsing error. 50 // resource_list being NULL indicates there was a parsing error.
52 if (!resource_list) 51 if (!resource_list)
53 error = GDATA_PARSE_ERROR; 52 error = GDATA_PARSE_ERROR;
54 53
55 callback.Run(error, resource_list.Pass()); 54 callback.Run(error, resource_list.Pass());
56 } 55 }
57 56
58 // Parses the JSON value to ResourceList on the blocking pool and runs 57 // Parses the JSON value to ResourceList on the blocking pool and runs
59 // |callback| on the UI thread once parsing is done. 58 // |callback| on the UI thread once parsing is done.
60 void ParseResourceListAndRun(const GetResourceListCallback& callback, 59 void ParseResourceListAndRun(
61 GDataErrorCode error, 60 scoped_refptr<base::TaskRunner> blocking_task_runner,
62 scoped_ptr<base::Value> value) { 61 const GetResourceListCallback& callback,
62 GDataErrorCode error,
63 scoped_ptr<base::Value> value) {
63 DCHECK(!callback.is_null()); 64 DCHECK(!callback.is_null());
64 65
65 if (!value) { 66 if (!value) {
66 callback.Run(error, scoped_ptr<ResourceList>()); 67 callback.Run(error, scoped_ptr<ResourceList>());
67 return; 68 return;
68 } 69 }
69 70
70 base::PostTaskAndReplyWithResult( 71 base::PostTaskAndReplyWithResult(
71 BrowserThread::GetBlockingPool(), 72 blocking_task_runner,
72 FROM_HERE, 73 FROM_HERE,
73 base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value)), 74 base::Bind(&ParseResourceListOnBlockingPool, base::Passed(&value)),
74 base::Bind(&DidParseResourceListOnBlockingPool, callback, error)); 75 base::Bind(&DidParseResourceListOnBlockingPool, callback, error));
75 } 76 }
76 77
77 // Parses the JSON value to AccountMetadata and runs |callback| on the UI 78 // Parses the JSON value to AccountMetadata and runs |callback| on the UI
78 // thread once parsing is done. 79 // thread once parsing is done.
79 void ParseAccounetMetadataAndRun(const GetAccountMetadataCallback& callback, 80 void ParseAccounetMetadataAndRun(const GetAccountMetadataCallback& callback,
80 GDataErrorCode error, 81 GDataErrorCode error,
81 scoped_ptr<base::Value> value) { 82 scoped_ptr<base::Value> value) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 //============================ GetResourceListRequest ======================== 156 //============================ GetResourceListRequest ========================
156 157
157 GetResourceListRequest::GetResourceListRequest( 158 GetResourceListRequest::GetResourceListRequest(
158 RequestSender* sender, 159 RequestSender* sender,
159 const GDataWapiUrlGenerator& url_generator, 160 const GDataWapiUrlGenerator& url_generator,
160 const GURL& override_url, 161 const GURL& override_url,
161 int64 start_changestamp, 162 int64 start_changestamp,
162 const std::string& search_string, 163 const std::string& search_string,
163 const std::string& directory_resource_id, 164 const std::string& directory_resource_id,
164 const GetResourceListCallback& callback) 165 const GetResourceListCallback& callback)
165 : GetDataRequest(sender, 166 : GetDataRequest(
166 base::Bind(&ParseResourceListAndRun, callback)), 167 sender,
168 base::Bind(&ParseResourceListAndRun,
169 make_scoped_refptr(sender->blocking_task_runner()),
170 callback)),
167 url_generator_(url_generator), 171 url_generator_(url_generator),
168 override_url_(override_url), 172 override_url_(override_url),
169 start_changestamp_(start_changestamp), 173 start_changestamp_(start_changestamp),
170 search_string_(search_string), 174 search_string_(search_string),
171 directory_resource_id_(directory_resource_id) { 175 directory_resource_id_(directory_resource_id) {
172 DCHECK(!callback.is_null()); 176 DCHECK(!callback.is_null());
173 } 177 }
174 178
175 GetResourceListRequest::~GetResourceListRequest() {} 179 GetResourceListRequest::~GetResourceListRequest() {}
176 180
177 GURL GetResourceListRequest::GetURL() const { 181 GURL GetResourceListRequest::GetURL() const {
178 return url_generator_.GenerateResourceListUrl(override_url_, 182 return url_generator_.GenerateResourceListUrl(override_url_,
179 start_changestamp_, 183 start_changestamp_,
180 search_string_, 184 search_string_,
181 directory_resource_id_); 185 directory_resource_id_);
182 } 186 }
183 187
184 //============================ SearchByTitleRequest ========================== 188 //============================ SearchByTitleRequest ==========================
185 189
186 SearchByTitleRequest::SearchByTitleRequest( 190 SearchByTitleRequest::SearchByTitleRequest(
187 RequestSender* sender, 191 RequestSender* sender,
188 const GDataWapiUrlGenerator& url_generator, 192 const GDataWapiUrlGenerator& url_generator,
189 const std::string& title, 193 const std::string& title,
190 const std::string& directory_resource_id, 194 const std::string& directory_resource_id,
191 const GetResourceListCallback& callback) 195 const GetResourceListCallback& callback)
192 : GetDataRequest(sender, 196 : GetDataRequest(
193 base::Bind(&ParseResourceListAndRun, callback)), 197 sender,
198 base::Bind(&ParseResourceListAndRun,
199 make_scoped_refptr(sender->blocking_task_runner()),
200 callback)),
194 url_generator_(url_generator), 201 url_generator_(url_generator),
195 title_(title), 202 title_(title),
196 directory_resource_id_(directory_resource_id) { 203 directory_resource_id_(directory_resource_id) {
197 DCHECK(!callback.is_null()); 204 DCHECK(!callback.is_null());
198 } 205 }
199 206
200 SearchByTitleRequest::~SearchByTitleRequest() {} 207 SearchByTitleRequest::~SearchByTitleRequest() {}
201 208
202 GURL SearchByTitleRequest::GetURL() const { 209 GURL SearchByTitleRequest::GetURL() const {
203 return url_generator_.GenerateSearchByTitleUrl( 210 return url_generator_.GenerateSearchByTitleUrl(
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 get_content_callback, 731 get_content_callback,
725 progress_callback, 732 progress_callback,
726 url_generator.GenerateDownloadFileUrl(resource_id), 733 url_generator.GenerateDownloadFileUrl(resource_id),
727 output_file_path) { 734 output_file_path) {
728 } 735 }
729 736
730 DownloadFileRequest::~DownloadFileRequest() { 737 DownloadFileRequest::~DownloadFileRequest() {
731 } 738 }
732 739
733 } // namespace google_apis 740 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698