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

Side by Side Diff: chrome/browser/component_updater/pnacl_component_installer.cc

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes mistake in previous patch set. Created 4 years, 10 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
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/browser/component_updater/pnacl_component_installer.h" 5 #include "chrome/browser/component_updater/pnacl_component_installer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const char kMinPnaclVersion[] = "0.46.0.4"; 70 const char kMinPnaclVersion[] = "0.46.0.4";
71 71
72 // Initially say that we do not need OnDemand updates. This should be 72 // Initially say that we do not need OnDemand updates. This should be
73 // updated by CheckVersionCompatiblity(), before doing any URLRequests 73 // updated by CheckVersionCompatiblity(), before doing any URLRequests
74 // that depend on PNaCl. 74 // that depend on PNaCl.
75 volatile base::subtle::Atomic32 needs_on_demand_update = 0; 75 volatile base::subtle::Atomic32 needs_on_demand_update = 0;
76 76
77 void CheckVersionCompatiblity(const base::Version& current_version) { 77 void CheckVersionCompatiblity(const base::Version& current_version) {
78 // Using NoBarrier, since needs_on_demand_update is standalone and does 78 // Using NoBarrier, since needs_on_demand_update is standalone and does
79 // not have other associated data. 79 // not have other associated data.
80 base::subtle::NoBarrier_Store(&needs_on_demand_update, 80 base::subtle::NoBarrier_Store(
81 current_version.IsOlderThan(kMinPnaclVersion)); 81 &needs_on_demand_update,
82 current_version < base::Version(kMinPnaclVersion));
82 } 83 }
83 84
84 // PNaCl is packaged as a multi-CRX. This returns the platform-specific 85 // PNaCl is packaged as a multi-CRX. This returns the platform-specific
85 // subdirectory that is part of that multi-CRX. 86 // subdirectory that is part of that multi-CRX.
86 base::FilePath GetPlatformDir(const base::FilePath& base_path) { 87 base::FilePath GetPlatformDir(const base::FilePath& base_path) {
87 std::string arch = SanitizeForPath(UpdateQueryParams::GetNaclArch()); 88 std::string arch = SanitizeForPath(UpdateQueryParams::GetNaclArch());
88 return base_path.AppendASCII("_platform_specific").AppendASCII(arch); 89 return base_path.AppendASCII("_platform_specific").AppendASCII(arch);
89 } 90 }
90 91
91 // Tell the rest of the world where to find the platform-specific PNaCl files. 92 // Tell the rest of the world where to find the platform-specific PNaCl files.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 OverrideDirPnaclComponent(path); 266 OverrideDirPnaclComponent(path);
266 return true; 267 return true;
267 } 268 }
268 269
269 // Given |file|, which can be a path like "_platform_specific/arm/pnacl_foo", 270 // Given |file|, which can be a path like "_platform_specific/arm/pnacl_foo",
270 // returns the assumed install path. The path separator in |file| is '/' 271 // returns the assumed install path. The path separator in |file| is '/'
271 // for all platforms. Caller is responsible for checking that the 272 // for all platforms. Caller is responsible for checking that the
272 // |installed_file| actually exists. 273 // |installed_file| actually exists.
273 bool PnaclComponentInstaller::GetInstalledFile(const std::string& file, 274 bool PnaclComponentInstaller::GetInstalledFile(const std::string& file,
274 base::FilePath* installed_file) { 275 base::FilePath* installed_file) {
275 if (current_version().Equals(Version(kNullVersion))) 276 if (current_version() == Version(kNullVersion))
276 return false; 277 return false;
277 278
278 *installed_file = GetPnaclBaseDirectory() 279 *installed_file = GetPnaclBaseDirectory()
279 .AppendASCII(current_version().GetString()) 280 .AppendASCII(current_version().GetString())
280 .AppendASCII(file); 281 .AppendASCII(file);
281 return true; 282 return true;
282 } 283 }
283 284
284 bool PnaclComponentInstaller::Uninstall() { 285 bool PnaclComponentInstaller::Uninstall() {
285 return false; 286 return false;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 scoped_ptr<base::DictionaryValue> manifest(ReadComponentManifest(path)); 333 scoped_ptr<base::DictionaryValue> manifest(ReadComponentManifest(path));
333 scoped_ptr<base::DictionaryValue> pnacl_manifest(ReadPnaclManifest(path)); 334 scoped_ptr<base::DictionaryValue> pnacl_manifest(ReadPnaclManifest(path));
334 Version manifest_version; 335 Version manifest_version;
335 // Check that the component manifest and PNaCl manifest files 336 // Check that the component manifest and PNaCl manifest files
336 // are legit, and that the indicated version matches the one 337 // are legit, and that the indicated version matches the one
337 // encoded within the path name. 338 // encoded within the path name.
338 if (manifest == NULL || pnacl_manifest == NULL || 339 if (manifest == NULL || pnacl_manifest == NULL ||
339 !CheckPnaclComponentManifest(*manifest, 340 !CheckPnaclComponentManifest(*manifest,
340 *pnacl_manifest, 341 *pnacl_manifest,
341 &manifest_version) || 342 &manifest_version) ||
342 !current_version.Equals(manifest_version)) { 343 current_version != manifest_version) {
343 current_version = Version(kNullVersion); 344 current_version = Version(kNullVersion);
344 } else { 345 } else {
345 OverrideDirPnaclComponent(path); 346 OverrideDirPnaclComponent(path);
346 base::ReadFileToString(path.AppendASCII("manifest.fingerprint"), 347 base::ReadFileToString(path.AppendASCII("manifest.fingerprint"),
347 &current_fingerprint); 348 &current_fingerprint);
348 } 349 }
349 } 350 }
350 351
351 BrowserThread::PostTask(BrowserThread::UI, 352 BrowserThread::PostTask(BrowserThread::UI,
352 FROM_HERE, 353 FROM_HERE,
(...skipping 23 matching lines...) Expand all
376 } // namespace component_updater 377 } // namespace component_updater
377 378
378 namespace pnacl { 379 namespace pnacl {
379 380
380 bool NeedsOnDemandUpdate() { 381 bool NeedsOnDemandUpdate() {
381 return base::subtle::NoBarrier_Load( 382 return base::subtle::NoBarrier_Load(
382 &component_updater::needs_on_demand_update) != 0; 383 &component_updater::needs_on_demand_update) != 0;
383 } 384 }
384 385
385 } // namespace pnacl 386 } // namespace pnacl
OLDNEW
« no previous file with comments | « chrome/app/chrome_crash_reporter_client.cc ('k') | chrome/browser/extensions/chrome_extensions_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698