Chromium Code Reviews| 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..c6757c6b64038c27551450952464f866f5175003 100644 |
| --- a/components/update_client/update_response.cc |
| +++ b/components/update_client/update_response.cc |
| @@ -32,9 +32,25 @@ UpdateResponse::Results::Results(const Results& other) = default; |
| UpdateResponse::Results::~Results() { |
| } |
| -UpdateResponse::Result::Result() { |
| +UpdateResponse::Result::Result() {} |
| +UpdateResponse::Result::Result(const Result& other) |
| + : crx_urls(other.crx_urls), |
| + crx_diffurls(other.crx_diffurls), |
| + manifest(other.manifest), |
| + cohort(new std::string(*other.cohort)), |
| + cohort_hint(new std::string(*other.cohort_hint)), |
| + cohort_name(new std::string(*other.cohort_name)) {} |
| +UpdateResponse::Result& UpdateResponse::Result::operator=(const Result& other) { |
|
Sorin Jianu
2016/08/22 19:59:34
oh, no.
waffles
2016/08/22 23:40:32
Yeah. :(
Tried another approach using a map.
|
| + crx_urls = other.crx_urls; |
| + crx_diffurls = other.crx_diffurls; |
| + manifest = other.manifest; |
| + cohort = std::unique_ptr<std::string>(new std::string(*other.cohort)); |
| + cohort_name = |
| + std::unique_ptr<std::string>(new std::string(*other.cohort_name)); |
| + cohort_hint = |
| + std::unique_ptr<std::string>(new std::string(*other.cohort_hint)); |
| + return *this; |
| } |
| -UpdateResponse::Result::Result(const Result& other) = default; |
| UpdateResponse::Result::~Result() { |
| } |
| @@ -93,6 +109,21 @@ static std::string GetAttribute(xmlNode* node, const char* attribute_name) { |
| return std::string(); |
| } |
| +// Returns the value of a named attribute, or nullptr . |
| +static std::unique_ptr<std::string> GetAttributePtr( |
| + 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 std::unique_ptr<std::string>(new std::string( |
| + reinterpret_cast<const char*>(attr->children->content))); |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| // This is used for the xml parser to report errors. This assumes the context |
| // is a pointer to a std::string where the error message should be appended. |
| static void XmlErrorFunc(void* context, const char* message, ...) { |
| @@ -268,6 +299,11 @@ bool ParseUpdateCheckTag(xmlNode* updatecheck, |
| bool ParseAppTag(xmlNode* app, |
| UpdateResponse::Result* result, |
| std::string* error) { |
| + // Read cohort information. |
| + result->cohort = GetAttributePtr(app, "cohort"); |
| + result->cohort_hint = GetAttributePtr(app, "cohorthint"); |
| + result->cohort_name = GetAttributePtr(app, "cohortname"); |
| + |
| // Read the crx id. |
| result->extension_id = GetAttribute(app, "appid"); |
| if (result->extension_id.empty()) { |