blob: 7f280c563d256348a59cafbc351edb2dff8a09d9 [file] [log] [blame]
[email protected]de0fdca22014-08-19 05:26:091// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]2cddef42013-11-22 08:23:222// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
sorin7cff6e52017-05-17 16:37:235#include "components/update_client/protocol_parser.h"
[email protected]2cddef42013-11-22 08:23:226#include "base/strings/stringprintf.h"
[email protected]2cddef42013-11-22 08:23:227
sorin52ac0882015-01-24 01:15:008namespace update_client {
[email protected]2cddef42013-11-22 08:23:229
sorin7cff6e52017-05-17 16:37:2310const char ProtocolParser::Result::kCohort[] = "cohort";
11const char ProtocolParser::Result::kCohortHint[] = "cohorthint";
12const char ProtocolParser::Result::kCohortName[] = "cohortname";
[email protected]2cddef42013-11-22 08:23:2213
sorin7cff6e52017-05-17 16:37:2314ProtocolParser::ProtocolParser() = default;
15ProtocolParser::~ProtocolParser() = default;
[email protected]2cddef42013-11-22 08:23:2216
sorin7cff6e52017-05-17 16:37:2317ProtocolParser::Results::Results() = default;
18ProtocolParser::Results::Results(const Results& other) = default;
19ProtocolParser::Results::~Results() = default;
[email protected]2cddef42013-11-22 08:23:2220
sorin7cff6e52017-05-17 16:37:2321ProtocolParser::Result::Result() = default;
22ProtocolParser::Result::Result(const Result& other) = default;
23ProtocolParser::Result::~Result() = default;
[email protected]2cddef42013-11-22 08:23:2224
sorin7cff6e52017-05-17 16:37:2325ProtocolParser::Result::Manifest::Manifest() = default;
26ProtocolParser::Result::Manifest::Manifest(const Manifest& other) = default;
27ProtocolParser::Result::Manifest::~Manifest() = default;
[email protected]2cddef42013-11-22 08:23:2228
sorin7cff6e52017-05-17 16:37:2329ProtocolParser::Result::Manifest::Package::Package() = default;
30ProtocolParser::Result::Manifest::Package::Package(const Package& other) =
vmpstrb6449d512016-02-25 23:55:4031 default;
sorin7cff6e52017-05-17 16:37:2332ProtocolParser::Result::Manifest::Package::~Package() = default;
[email protected]2cddef42013-11-22 08:23:2233
sorin7cff6e52017-05-17 16:37:2334void ProtocolParser::ParseError(const char* details, ...) {
[email protected]2cddef42013-11-22 08:23:2235 va_list args;
36 va_start(args, details);
37
38 if (!errors_.empty()) {
39 errors_ += "\r\n";
40 }
41
42 base::StringAppendV(&errors_, details, args);
43 va_end(args);
44}
45
Sorin Jianu039032b2018-10-12 21:48:1346bool ProtocolParser::Parse(const std::string& response) {
[email protected]2cddef42013-11-22 08:23:2247 results_.daystart_elapsed_seconds = kNoDaystart;
wafflesd2d9a332016-04-09 01:59:5748 results_.daystart_elapsed_days = kNoDaystart;
[email protected]2cddef42013-11-22 08:23:2249 results_.list.clear();
50 errors_.clear();
51
Sorin Jianu039032b2018-10-12 21:48:1352 return DoParse(response, &results_);
53}
[email protected]2cddef42013-11-22 08:23:2254
sorin52ac0882015-01-24 01:15:0055} // namespace update_client