WebSocket header continuations test case.
[chromium-blink-merge.git] / components / update_client / update_response.h
blob003474f075505d5813d0abac912e012f4d14e173
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_RESPONSE_H_
6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_RESPONSE_H_
8 #include <string>
9 #include <vector>
11 #include "base/macros.h"
12 #include "url/gurl.h"
14 namespace update_client {
16 // Parses responses for the update protocol version 3.
17 // (http://code.google.com/p/omaha/wiki/ServerProtocol)
19 // An update response looks like this:
21 // <?xml version="1.0" encoding="UTF-8"?>
22 // <response protocol="3.0" server="prod">
23 // <daystart elapsed_seconds="56508"/>
24 // <app appid="{430FD4D0-B729-4F61-AA34-91526481799D}" status="ok">
25 // <updatecheck status="noupdate"/>
26 // <ping status="ok"/>
27 // </app>
28 // <app appid="{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}" status="ok">
29 // <updatecheck status="ok">
30 // <urls>
31 // <url codebase="http://host/edgedl/chrome/install/782.112/"
32 // <url codebasediff="http://fallback/chrome/diff/782.112/"/>
33 // </urls>
34 // <manifest version="13.0.782.112" prodversionmin="2.0.143.0">
35 // <packages>
36 // <package name="component.crx"
37 // namediff="diff_1.2.3.4.crx"
38 // fp="1.123"
39 // hash_sha256="9830b4245c4..." size="23963192"
40 // hashdiff_sha256="cfb6caf3d0..." sizediff="101"/>
41 // </packages>
42 // </manifest>
43 // </updatecheck>
44 // <ping status="ok"/>
45 // </app>
46 // </response>
48 // The <daystart> tag contains a "elapsed_seconds" attribute which refers to
49 // the server's notion of how many seconds it has been since midnight.
51 // The "appid" attribute of the <app> tag refers to the unique id of the
52 // extension. The "codebase" attribute of the <updatecheck> tag is the url to
53 // fetch the updated crx file, and the "prodversionmin" attribute refers to
54 // the minimum version of the chrome browser that the update applies to.
56 // The diff data members correspond to the differential update package, if
57 // a differential update is specified in the response.
58 class UpdateResponse {
59 public:
60 // The result of parsing one <app> tag in an xml update check response.
61 struct Result {
62 struct Manifest {
63 struct Package {
64 Package();
65 ~Package();
67 std::string fingerprint;
69 // Attributes for the full update.
70 std::string name;
71 std::string hash_sha256;
72 int size;
74 // Attributes for the differential update.
75 std::string namediff;
76 std::string hashdiff_sha256;
77 int sizediff;
80 Manifest();
81 ~Manifest();
83 std::string version;
84 std::string browser_min_version;
85 std::vector<Package> packages;
88 Result();
89 ~Result();
91 std::string extension_id;
93 // The list of fallback urls, for full and diff updates respectively.
94 // These urls are base urls; they don't include the filename.
95 std::vector<GURL> crx_urls;
96 std::vector<GURL> crx_diffurls;
98 Manifest manifest;
101 static const int kNoDaystart = -1;
102 struct Results {
103 Results();
104 ~Results();
106 // This will be >= 0, or kNoDaystart if the <daystart> tag was not present.
107 int daystart_elapsed_seconds;
108 std::vector<Result> list;
111 UpdateResponse();
112 ~UpdateResponse();
114 // Parses an update response xml string into Result data. Returns a bool
115 // indicating success or failure. On success, the results are available by
116 // calling results(). The details for any failures are available by calling
117 // errors().
118 bool Parse(const std::string& manifest_xml);
120 const Results& results() const { return results_; }
121 const std::string& errors() const { return errors_; }
123 private:
124 Results results_;
125 std::string errors_;
127 // Adds parse error details to |errors_| string.
128 void ParseError(const char* details, ...);
130 DISALLOW_COPY_AND_ASSIGN(UpdateResponse);
133 } // namespace update_client
135 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_RESPONSE_H_