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

Unified Diff: components/update_client/update_response.cc

Issue 2252093002: Add support for Omaha cohorts to the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't serialize the attrs when they are empty. Created 4 years, 4 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
Index: components/update_client/update_response.cc
diff --git a/components/update_client/update_response.cc b/components/update_client/update_response.cc
index e89a774ae7a77627b0800cf8b6218642c96de385..b6c8c44b8c27683fac680fc91fac9ec202842b49 100644
--- a/components/update_client/update_response.cc
+++ b/components/update_client/update_response.cc
@@ -80,6 +80,18 @@ static std::vector<xmlNode*> GetChildren(xmlNode* root, const char* name) {
return result;
}
+// Returns whether the attribute is present.
+static bool HasAttribute(xmlNode* node, const char* attribute_name) {
+ const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name);
+ for (xmlAttr* attr = node->properties; attr != NULL; attr = attr->next) {
+ if (!xmlStrcmp(attr->name, name) && attr->children &&
+ attr->children->content) {
+ return true;
+ }
+ }
+ return false;
+}
+
// Returns the value of a named attribute, or the empty string.
static std::string GetAttribute(xmlNode* node, const char* attribute_name) {
const xmlChar* name = reinterpret_cast<const xmlChar*>(attribute_name);
@@ -268,6 +280,14 @@ bool ParseUpdateCheckTag(xmlNode* updatecheck,
bool ParseAppTag(xmlNode* app,
UpdateResponse::Result* result,
std::string* error) {
+ // Read cohort information.
+ result->set_cohort = HasAttribute(app, "cohort");
+ result->cohort = GetAttribute(app, "cohort");
Sorin Jianu 2016/08/18 21:15:15 Would it make sense to dynamically allocate the co
waffles 2016/08/18 22:29:23 According to the spec, if the server serializes an
+ result->set_cohort_hint = HasAttribute(app, "cohorthint");
+ result->cohort_hint = GetAttribute(app, "cohorthint");
+ result->set_cohort_name = HasAttribute(app, "cohortname");
+ result->cohort_name = GetAttribute(app, "cohortname");
+
// Read the crx id.
result->extension_id = GetAttribute(app, "appid");
if (result->extension_id.empty()) {

Powered by Google App Engine
This is Rietveld 408576698