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

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: 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)
404 return std::string(); 407 return std::string();
405 std::string retval("ABI:"); 408 std::string retval("ABI:");
406 retval += IntToString(info.abi_version) + ";" + "opt:" + 409 retval += IntToString(info.abi_version) + ";" + "opt:" +
407 IntToString(info.opt_level) + ";" + "URL:"; 410 IntToString(info.opt_level) + ";" + "URL:";
408 // Filter the username, password, and ref components from the URL 411 // Filter the username, password, and ref components from the URL
409 GURL::Replacements replacements; 412 GURL::Replacements replacements;
410 replacements.ClearUsername(); 413 replacements.ClearUsername();
411 replacements.ClearPassword(); 414 replacements.ClearPassword();
412 replacements.ClearRef(); 415 replacements.ClearRef();
413 GURL key_url(info.pexe_url.ReplaceComponents(replacements)); 416 GURL key_url(info.pexe_url.ReplaceComponents(replacements));
414 retval += key_url.spec() + ";"; 417 retval += key_url.spec() + ";";
415 // You would think that there is already code to format base::Time values 418 // 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 419 // somewhere, but I haven't found it yet. In any case, doing it ourselves
417 // here means we can keep the format stable. 420 // here means we can keep the format stable.
418 base::Time::Exploded exploded; 421 base::Time::Exploded exploded;
419 info.last_modified.UTCExplode(&exploded); 422 info.last_modified.UTCExplode(&exploded);
420 if (info.last_modified.is_null() || !exploded.HasValidValues()) { 423 if (info.last_modified.is_null() || !exploded.HasValidValues()) {
421 memset(&exploded, 0, sizeof(exploded)); 424 memset(&exploded, 0, sizeof(exploded));
422 } 425 }
423 retval += "modified:" + IntToString(exploded.year) + ":" + 426 retval += "modified:" + IntToString(exploded.year) + ":" +
424 IntToString(exploded.month) + ":" + 427 IntToString(exploded.month) + ":" +
425 IntToString(exploded.day_of_month) + ":" + 428 IntToString(exploded.day_of_month) + ":" +
426 IntToString(exploded.hour) + ":" + IntToString(exploded.minute) + 429 IntToString(exploded.hour) + ":" + IntToString(exploded.minute) +
427 ":" + IntToString(exploded.second) + ":" + 430 ":" + IntToString(exploded.second) + ":" +
428 IntToString(exploded.millisecond) + ":UTC;"; 431 IntToString(exploded.millisecond) + ":UTC;";
429 retval += "etag:" + info.etag; 432 retval += "etag:" + info.etag + ";";
433 retval += "sandbox:" + info.sandbox_isa + ";";
434 retval += "extra_flags:" + info.extra_flags + ";";
430 return retval; 435 return retval;
431 } 436 }
432 437
433 int PnaclTranslationCache::DoomEntriesBetween( 438 int PnaclTranslationCache::DoomEntriesBetween(
434 base::Time initial, 439 base::Time initial,
435 base::Time end, 440 base::Time end,
436 const CompletionCallback& callback) { 441 const CompletionCallback& callback) {
437 return disk_cache_->DoomEntriesBetween(initial, end, callback); 442 return disk_cache_->DoomEntriesBetween(initial, end, callback);
438 } 443 }
439 444
440 } // namespace pnacl 445 } // namespace pnacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698