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

Unified 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: Rebased. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google_apis/base_operations.cc
diff --git a/chrome/browser/google_apis/base_operations.cc b/chrome/browser/google_apis/base_operations.cc
index ea35779d38443cb3cc0f1d983de2d945882a77b6..664baf9b8acac6126f54641b46865bd1ecb5de41 100644
--- a/chrome/browser/google_apis/base_operations.cc
+++ b/chrome/browser/google_apis/base_operations.cc
@@ -30,17 +30,17 @@ const char kGDataVersionHeader[] = "GData-Version: 3.0";
const int kMaxReAuthenticateAttemptsPerOperation = 1;
// Parse JSON string to base::Value object.
-scoped_ptr<base::Value> ParseJsonOnBlockingPool(const std::string& data) {
+scoped_ptr<base::Value> ParseJsonOnBlockingPool(const std::string& json) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
int error_code = -1;
std::string error_message;
scoped_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
- data, base::JSON_PARSE_RFC, &error_code, &error_message));
+ json, base::JSON_PARSE_RFC, &error_code, &error_message));
if (!value.get()) {
LOG(ERROR) << "Error while parsing entry response: " << error_message
- << ", code: " << error_code << ", data:\n" << data;
+ << ", code: " << error_code << ", json:\n" << json;
}
return value.Pass();
}
@@ -69,6 +69,14 @@ std::string GetResponseHeadersAsString(
namespace google_apis {
+void ParseJson(const std::string& json, const ParseJsonCallback& callback) {
+ base::PostTaskAndReplyWithResult(
+ BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&ParseJsonOnBlockingPool, json),
+ callback);
+}
+
//============================ UrlFetchOperationBase ===========================
UrlFetchOperationBase::UrlFetchOperationBase(
@@ -289,13 +297,10 @@ void GetDataOperation::ParseResponse(GDataErrorCode fetch_error_code,
const std::string& data) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- base::PostTaskAndReplyWithResult(
- BrowserThread::GetBlockingPool(),
- FROM_HERE,
- base::Bind(&ParseJsonOnBlockingPool, data),
- base::Bind(&GetDataOperation::OnDataParsed,
- weak_ptr_factory_.GetWeakPtr(),
- fetch_error_code));
+ ParseJson(data,
+ base::Bind(&GetDataOperation::OnDataParsed,
+ weak_ptr_factory_.GetWeakPtr(),
+ fetch_error_code));
}
void GetDataOperation::ProcessURLFetchResults(const URLFetcher* source) {
« no previous file with comments | « chrome/browser/google_apis/base_operations.h ('k') | chrome/browser/google_apis/base_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698