Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / chrome / common / extensions / update_manifest.h
blobd84774360fd83e26ffa1ff456299ddd6a715e198
1 // Copyright (c) 2010 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 CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_
6 #define CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_
8 #include <string>
9 #include <vector>
11 #include "googleurl/src/gurl.h"
13 class UpdateManifest {
14 public:
16 // An update manifest looks like this:
18 // <?xml version='1.0' encoding='UTF-8'?>
19 // <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
20 // <daystart elapsed_seconds='300' />
21 // <app appid='12345'>
22 // <updatecheck codebase='http://example.com/extension_1.2.3.4.crx'
23 // version='1.2.3.4' prodversionmin='2.0.143.0'
24 // hash="12345"/>
25 // </app>
26 // </gupdate>
28 // The <daystart> tag contains a "elapsed_seconds" attribute which refers to
29 // the server's notion of how many seconds it has been since midnight.
31 // The "appid" attribute of the <app> tag refers to the unique id of the
32 // extension. The "codebase" attribute of the <updatecheck> tag is the url to
33 // fetch the updated crx file, and the "prodversionmin" attribute refers to
34 // the minimum version of the chrome browser that the update applies to.
36 // The result of parsing one <app> tag in an xml update check manifest.
37 struct Result {
38 Result();
39 ~Result();
41 std::string extension_id;
42 std::string version;
43 std::string browser_min_version;
44 std::string package_hash;
45 GURL crx_url;
48 static const int kNoDaystart = -1;
49 struct Results {
50 Results();
51 ~Results();
53 std::vector<Result> list;
54 // This will be >= 0, or kNoDaystart if the <daystart> tag was not present.
55 int daystart_elapsed_seconds;
58 UpdateManifest();
59 ~UpdateManifest();
61 // Parses an update manifest xml string into Result data. Returns a bool
62 // indicating success or failure. On success, the results are available by
63 // calling results(). The details for any failures are available by calling
64 // errors().
65 bool Parse(const std::string& manifest_xml);
67 const Results& results() { return results_; }
68 const std::string& errors() { return errors_; }
70 private:
71 Results results_;
72 std::string errors_;
74 // Helper function that adds parse error details to our errors_ string.
75 void ParseError(const char* details, ...);
77 DISALLOW_COPY_AND_ASSIGN(UpdateManifest);
80 #endif // CHROME_COMMON_EXTENSIONS_UPDATE_MANIFEST_H_