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

Side by Side Diff: chrome/common/extensions/update_manifest.cc

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync to LKGR revision 207804. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/update_manifest.h" 5 #include "chrome/common/extensions/update_manifest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "libxml/tree.h" 15 #include "libxml/tree.h"
16 #include "third_party/libxml/chromium/libxml_utils.h" 16 #include "third_party/libxml/chromium/libxml_utils.h"
17 17
18 static const char* kExpectedGupdateProtocol = "2.0"; 18 static const char* kExpectedGupdateProtocol = "2.0";
19 static const char* kExpectedGupdateXmlns = 19 static const char* kExpectedGupdateXmlns =
20 "http://www.google.com/update2/response"; 20 "http://www.google.com/update2/response";
21 21
22 UpdateManifest::Result::Result() {} 22 UpdateManifest::Result::Result()
23 : size(0),
24 diff_size(0) {}
23 25
24 UpdateManifest::Result::~Result() {} 26 UpdateManifest::Result::~Result() {}
25 27
26 UpdateManifest::Results::Results() : daystart_elapsed_seconds(kNoDaystart) {} 28 UpdateManifest::Results::Results() : daystart_elapsed_seconds(kNoDaystart) {}
27 29
28 UpdateManifest::Results::~Results() {} 30 UpdateManifest::Results::~Results() {}
29 31
30 UpdateManifest::UpdateManifest() { 32 UpdateManifest::UpdateManifest() {
31 } 33 }
32 34
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 xmlNode *updatecheck = updates[0]; 149 xmlNode *updatecheck = updates[0];
148 150
149 if (GetAttribute(updatecheck, "status") == "noupdate") { 151 if (GetAttribute(updatecheck, "status") == "noupdate") {
150 return true; 152 return true;
151 } 153 }
152 154
153 // Find the url to the crx file. 155 // Find the url to the crx file.
154 result->crx_url = GURL(GetAttribute(updatecheck, "codebase")); 156 result->crx_url = GURL(GetAttribute(updatecheck, "codebase"));
155 if (!result->crx_url.is_valid()) { 157 if (!result->crx_url.is_valid()) {
156 *error_detail = "Invalid codebase url: '"; 158 *error_detail = "Invalid codebase url: '";
157 *error_detail += GetAttribute(updatecheck, "codebase"); 159 *error_detail += result->crx_url.possibly_invalid_spec();
158 *error_detail += "'."; 160 *error_detail += "'.";
159 return false; 161 return false;
160 } 162 }
161 163
162 // Get the version. 164 // Get the version.
163 result->version = GetAttribute(updatecheck, "version"); 165 result->version = GetAttribute(updatecheck, "version");
164 if (result->version.length() == 0) { 166 if (result->version.length() == 0) {
165 *error_detail = "Missing version for updatecheck."; 167 *error_detail = "Missing version for updatecheck.";
166 return false; 168 return false;
167 } 169 }
(...skipping 14 matching lines...) Expand all
182 *error_detail += result->browser_min_version; 184 *error_detail += result->browser_min_version;
183 *error_detail += "'."; 185 *error_detail += "'.";
184 return false; 186 return false;
185 } 187 }
186 } 188 }
187 189
188 // package_hash is optional. It is only required for blacklist. It is a 190 // package_hash is optional. It is only required for blacklist. It is a
189 // sha256 hash of the package in hex format. 191 // sha256 hash of the package in hex format.
190 result->package_hash = GetAttribute(updatecheck, "hash"); 192 result->package_hash = GetAttribute(updatecheck, "hash");
191 193
194 int size = 0;
195 if (base::StringToInt(GetAttribute(updatecheck, "size"), &size)) {
196 result->size = size;
197 }
198
199 // package_fingerprint is optional. It identifies the package, preferably
200 // with a modified sha256 hash of the package in hex format.
201 result->package_fingerprint = GetAttribute(updatecheck, "fp");
202
203 // Differential update information is optional.
204 result->diff_crx_url = GURL(GetAttribute(updatecheck, "codebasediff"));
205 result->diff_package_hash = GetAttribute(updatecheck, "hashdiff");
206 int sizediff = 0;
207 if (base::StringToInt(GetAttribute(updatecheck, "sizediff"), &sizediff)) {
208 result->diff_size = sizediff;
209 }
210
192 return true; 211 return true;
193 } 212 }
194 213
195 214
196 bool UpdateManifest::Parse(const std::string& manifest_xml) { 215 bool UpdateManifest::Parse(const std::string& manifest_xml) {
197 results_.list.resize(0); 216 results_.list.resize(0);
198 results_.daystart_elapsed_seconds = kNoDaystart; 217 results_.daystart_elapsed_seconds = kNoDaystart;
199 errors_ = ""; 218 errors_ = "";
200 219
201 if (manifest_xml.length() < 1) { 220 if (manifest_xml.length() < 1) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 std::string error; 276 std::string error;
258 if (!ParseSingleAppTag(apps[i], gupdate_ns, &current, &error)) { 277 if (!ParseSingleAppTag(apps[i], gupdate_ns, &current, &error)) {
259 ParseError("%s", error.c_str()); 278 ParseError("%s", error.c_str());
260 } else { 279 } else {
261 results_.list.push_back(current); 280 results_.list.push_back(current);
262 } 281 }
263 } 282 }
264 283
265 return true; 284 return true;
266 } 285 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/update_manifest.h ('k') | chrome/common/omaha_query_params/omaha_query_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698