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

Side by Side Diff: components/nacl/browser/pnacl_translation_cache.cc

Issue 163433015: Add sandbox ISA and extra compile flag fields to PNaCl translation cache key (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/browser/pnacl_translation_cache.h" 5 #include "components/nacl/browser/pnacl_translation_cache.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 in_memory_ = true; 391 in_memory_ = true;
392 return Init(net::MEMORY_CACHE, base::FilePath(), kMaxMemCacheSize, callback); 392 return Init(net::MEMORY_CACHE, base::FilePath(), kMaxMemCacheSize, callback);
393 } 393 }
394 394
395 int PnaclTranslationCache::Size() { 395 int PnaclTranslationCache::Size() {
396 if (!disk_cache_) 396 if (!disk_cache_)
397 return -1; 397 return -1;
398 return disk_cache_->GetEntryCount(); 398 return disk_cache_->GetEntryCount();
399 } 399 }
400 400
401 // Beware that any changes to this function or to PnaclCacheInfo will
402 // effectively invalidate existing translation cache entries.
403
401 // static 404 // static
402 std::string PnaclTranslationCache::GetKey(const nacl::PnaclCacheInfo& info) { 405 std::string PnaclTranslationCache::GetKey(const nacl::PnaclCacheInfo& info) {
403 if (!info.pexe_url.is_valid() || info.abi_version < 0 || info.opt_level < 0) 406 if (!info.pexe_url.is_valid() || info.abi_version < 0 || info.opt_level < 0 ||
407 info.extra_flags.size() > 512)
404 return std::string(); 408 return std::string();
405 std::string retval("ABI:"); 409 std::string retval("ABI:");
406 retval += IntToString(info.abi_version) + ";" + "opt:" + 410 retval += IntToString(info.abi_version) + ";" + "opt:" +
407 IntToString(info.opt_level) + ";" + "URL:"; 411 IntToString(info.opt_level) + ";" + "URL:";
408 // Filter the username, password, and ref components from the URL 412 // Filter the username, password, and ref components from the URL
409 GURL::Replacements replacements; 413 GURL::Replacements replacements;
410 replacements.ClearUsername(); 414 replacements.ClearUsername();
411 replacements.ClearPassword(); 415 replacements.ClearPassword();
412 replacements.ClearRef(); 416 replacements.ClearRef();
413 GURL key_url(info.pexe_url.ReplaceComponents(replacements)); 417 GURL key_url(info.pexe_url.ReplaceComponents(replacements));
414 retval += key_url.spec() + ";"; 418 retval += key_url.spec() + ";";
415 // You would think that there is already code to format base::Time values 419 // You would think that there is already code to format base::Time values
416 // somewhere, but I haven't found it yet. In any case, doing it ourselves 420 // somewhere, but I haven't found it yet. In any case, doing it ourselves
417 // here means we can keep the format stable. 421 // here means we can keep the format stable.
418 base::Time::Exploded exploded; 422 base::Time::Exploded exploded;
419 info.last_modified.UTCExplode(&exploded); 423 info.last_modified.UTCExplode(&exploded);
420 if (info.last_modified.is_null() || !exploded.HasValidValues()) { 424 if (info.last_modified.is_null() || !exploded.HasValidValues()) {
421 memset(&exploded, 0, sizeof(exploded)); 425 memset(&exploded, 0, sizeof(exploded));
422 } 426 }
423 retval += "modified:" + IntToString(exploded.year) + ":" + 427 retval += "modified:" + IntToString(exploded.year) + ":" +
424 IntToString(exploded.month) + ":" + 428 IntToString(exploded.month) + ":" +
425 IntToString(exploded.day_of_month) + ":" + 429 IntToString(exploded.day_of_month) + ":" +
426 IntToString(exploded.hour) + ":" + IntToString(exploded.minute) + 430 IntToString(exploded.hour) + ":" + IntToString(exploded.minute) +
427 ":" + IntToString(exploded.second) + ":" + 431 ":" + IntToString(exploded.second) + ":" +
428 IntToString(exploded.millisecond) + ":UTC;"; 432 IntToString(exploded.millisecond) + ":UTC;";
429 retval += "etag:" + info.etag; 433 retval += "etag:" + info.etag + ";";
434 retval += "sandbox:" + info.sandbox_isa + ";";
435 retval += "extra_flags:" + info.extra_flags + ";";
430 return retval; 436 return retval;
431 } 437 }
432 438
433 int PnaclTranslationCache::DoomEntriesBetween( 439 int PnaclTranslationCache::DoomEntriesBetween(
434 base::Time initial, 440 base::Time initial,
435 base::Time end, 441 base::Time end,
436 const CompletionCallback& callback) { 442 const CompletionCallback& callback) {
437 return disk_cache_->DoomEntriesBetween(initial, end, callback); 443 return disk_cache_->DoomEntriesBetween(initial, end, callback);
438 } 444 }
439 445
440 } // namespace pnacl 446 } // namespace pnacl
OLDNEW
« no previous file with comments | « no previous file | components/nacl/browser/pnacl_translation_cache_unittest.cc » ('j') | ppapi/api/private/ppb_nacl_private.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698