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

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

Issue 11577002: Converted ResumeUploadOperation to use JSON in response instead of XML. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 8 years 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_operations.h" 5 #include "chrome/browser/google_apis/base_operations.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } else { 62 } else {
63 url_fetcher->GetResponseHeaders()->GetNormalizedHeaders(&headers); 63 url_fetcher->GetResponseHeaders()->GetNormalizedHeaders(&headers);
64 } 64 }
65 return headers; 65 return headers;
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 namespace google_apis { 70 namespace google_apis {
71 71
72 void parseJson(const std::string& data, const ParseJsonCallback& callback) {
73 base::PostTaskAndReplyWithResult(
74 BrowserThread::GetBlockingPool(),
75 FROM_HERE,
76 base::Bind(&ParseJsonOnBlockingPool, data),
77 callback);
78 }
79
72 //============================ UrlFetchOperationBase =========================== 80 //============================ UrlFetchOperationBase ===========================
73 81
74 UrlFetchOperationBase::UrlFetchOperationBase( 82 UrlFetchOperationBase::UrlFetchOperationBase(
75 OperationRegistry* registry, 83 OperationRegistry* registry,
76 net::URLRequestContextGetter* url_request_context_getter) 84 net::URLRequestContextGetter* url_request_context_getter)
77 : OperationRegistry::Operation(registry), 85 : OperationRegistry::Operation(registry),
78 url_request_context_getter_(url_request_context_getter), 86 url_request_context_getter_(url_request_context_getter),
79 re_authenticate_count_(0), 87 re_authenticate_count_(0),
80 started_(false), 88 started_(false),
81 save_temp_file_(false), 89 save_temp_file_(false),
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 290 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
283 DCHECK(!callback_.is_null()); 291 DCHECK(!callback_.is_null());
284 } 292 }
285 293
286 GetDataOperation::~GetDataOperation() {} 294 GetDataOperation::~GetDataOperation() {}
287 295
288 void GetDataOperation::ParseResponse(GDataErrorCode fetch_error_code, 296 void GetDataOperation::ParseResponse(GDataErrorCode fetch_error_code,
289 const std::string& data) { 297 const std::string& data) {
290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
291 299
292 base::PostTaskAndReplyWithResult( 300 base::PostTaskAndReplyWithResult(
satorux1 2012/12/14 00:17:24 I think you can use ParseJson() here.
mtomasz 2012/12/14 04:58:36 Done.
293 BrowserThread::GetBlockingPool(), 301 BrowserThread::GetBlockingPool(),
294 FROM_HERE, 302 FROM_HERE,
295 base::Bind(&ParseJsonOnBlockingPool, data), 303 base::Bind(&ParseJsonOnBlockingPool, data),
296 base::Bind(&GetDataOperation::OnDataParsed, 304 base::Bind(&GetDataOperation::OnDataParsed,
297 weak_ptr_factory_.GetWeakPtr(), 305 weak_ptr_factory_.GetWeakPtr(),
298 fetch_error_code)); 306 fetch_error_code));
299 } 307 }
300 308
301 void GetDataOperation::ProcessURLFetchResults(const URLFetcher* source) { 309 void GetDataOperation::ProcessURLFetchResults(const URLFetcher* source) {
302 std::string data; 310 std::string data;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 OnProcessURLFetchResultsComplete(success); 347 OnProcessURLFetchResultsComplete(success);
340 } 348 }
341 349
342 void GetDataOperation::RunCallbackOnSuccess(GDataErrorCode fetch_error_code, 350 void GetDataOperation::RunCallbackOnSuccess(GDataErrorCode fetch_error_code,
343 scoped_ptr<base::Value> value) { 351 scoped_ptr<base::Value> value) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 callback_.Run(fetch_error_code, value.Pass()); 353 callback_.Run(fetch_error_code, value.Pass());
346 } 354 }
347 355
348 } // namespace google_apis 356 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698