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

Unified Diff: components/update_client/update_response.cc

Issue 2700733002: Mechanical refactoring of the parser and ActionUpdateCheck (Closed)
Patch Set: . Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/update_response.h ('k') | components/update_client/update_response_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/update_response.cc
diff --git a/components/update_client/update_response.cc b/components/update_client/update_response.cc
index 41670d317de9ff25162350fc280a42caa360b4f3..f9eefe80c60fc9917644488dfcb53f196bac530b 100644
--- a/components/update_client/update_response.cc
+++ b/components/update_client/update_response.cc
@@ -258,28 +258,39 @@ bool ParseUrlsTag(xmlNode* urls,
bool ParseUpdateCheckTag(xmlNode* updatecheck,
UpdateResponse::Result* result,
std::string* error) {
- if (GetAttribute(updatecheck, "status") == "noupdate") {
- return true;
- }
-
- // Get the <urls> tag.
- std::vector<xmlNode*> urls = GetChildren(updatecheck, "urls");
- if (urls.empty()) {
- *error = "Missing urls on updatecheck.";
+ // Read the |status| attribute.
+ result->status = GetAttribute(updatecheck, "status");
+ if (result->status.empty()) {
+ *error = "Missing status on updatecheck node";
return false;
}
- if (!ParseUrlsTag(urls[0], result, error)) {
- return false;
- }
+ if (result->status == "noupdate")
+ return true;
- std::vector<xmlNode*> manifests = GetChildren(updatecheck, "manifest");
- if (manifests.empty()) {
- *error = "Missing manifest on updatecheck.";
- return false;
+ if (result->status == "ok") {
+ std::vector<xmlNode*> urls = GetChildren(updatecheck, "urls");
+ if (urls.empty()) {
+ *error = "Missing urls on updatecheck.";
+ return false;
+ }
+
+ if (!ParseUrlsTag(urls[0], result, error)) {
+ return false;
+ }
+
+ std::vector<xmlNode*> manifests = GetChildren(updatecheck, "manifest");
+ if (manifests.empty()) {
+ *error = "Missing manifest on updatecheck.";
+ return false;
+ }
+
+ return ParseManifestTag(manifests[0], result, error);
}
- return ParseManifestTag(manifests[0], result, error);
+ // Return the |updatecheck| element status as a parsing error.
+ *error = result->status;
+ return false;
}
// Parses a single <app> tag.
@@ -320,7 +331,7 @@ bool UpdateResponse::Parse(const std::string& response_xml) {
results_.list.clear();
errors_.clear();
- if (response_xml.length() < 1) {
+ if (response_xml.empty()) {
ParseError("Empty xml");
return false;
}
« no previous file with comments | « components/update_client/update_response.h ('k') | components/update_client/update_response_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698