Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/nacl_host/nacl_browser.h" | 5 #include "chrome/browser/nacl_host/nacl_browser.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 8 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 10 #include "base/pickle.h" | 11 #include "base/pickle.h" |
| 11 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/chrome_paths_internal.h" | 15 #include "chrome/common/chrome_paths_internal.h" |
| 16 #include "chrome/common/chrome_switches.h" | |
| 15 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // An arbitrary delay to coalesce multiple writes to the cache. | 21 // An arbitrary delay to coalesce multiple writes to the cache. |
| 20 const int kValidationCacheCoalescingTimeMS = 6000; | 22 const int kValidationCacheCoalescingTimeMS = 6000; |
| 21 const char kValidationCacheSequenceName[] = "NaClValidationCache"; | 23 const char kValidationCacheSequenceName[] = "NaClValidationCache"; |
| 22 const FilePath::CharType kValidationCacheFileName[] = | 24 const FilePath::CharType kValidationCacheFileName[] = |
| 23 FILE_PATH_LITERAL("nacl_validation_cache.bin"); | 25 FILE_PATH_LITERAL("nacl_validation_cache.bin"); |
| 24 | 26 |
| 25 const bool kValidationCacheEnabledByDefault = true; | 27 const bool kValidationCacheEnabledByDefault = true; |
| 26 | 28 |
| 27 enum ValidationCacheStatus { | 29 enum ValidationCacheStatus { |
| 28 CACHE_MISS = 0, | 30 CACHE_MISS = 0, |
| 29 CACHE_HIT, | 31 CACHE_HIT, |
| 30 CACHE_MAX | 32 CACHE_MAX |
| 31 }; | 33 }; |
| 32 | 34 |
| 33 // Determine the name of the IRT file based on the architecture. | 35 // Determine the name of the IRT file based on the architecture. |
| 34 #define NACL_IRT_FILE_NAME(arch_string) \ | 36 #define NACL_IRT_FILE_NAME(type, arch_string) \ |
| 35 (FILE_PATH_LITERAL("nacl_irt_") \ | 37 (FILE_PATH_LITERAL(type) \ |
| 38 FILE_PATH_LITERAL("_") \ | |
| 36 FILE_PATH_LITERAL(arch_string) \ | 39 FILE_PATH_LITERAL(arch_string) \ |
| 37 FILE_PATH_LITERAL(".nexe")) | 40 FILE_PATH_LITERAL(".nexe")) |
| 38 | 41 |
| 39 const FilePath::StringType NaClIrtName() { | 42 const FilePath::StringType NaClIrtName() { |
| 40 #if defined(ARCH_CPU_X86_FAMILY) | 43 #if defined(ARCH_CPU_X86_FAMILY) |
| 41 #if defined(ARCH_CPU_X86_64) | 44 #if defined(ARCH_CPU_X86_64) |
| 42 bool is64 = true; | 45 bool is64 = true; |
| 43 #elif defined(OS_WIN) | 46 #elif defined(OS_WIN) |
| 44 bool is64 = (base::win::OSInfo::GetInstance()->wow64_status() == | 47 bool is64 = (base::win::OSInfo::GetInstance()->wow64_status() == |
| 45 base::win::OSInfo::WOW64_ENABLED); | 48 base::win::OSInfo::WOW64_ENABLED); |
| 46 #else | 49 #else |
| 47 bool is64 = false; | 50 bool is64 = false; |
| 48 #endif | 51 #endif |
| 49 return is64 ? NACL_IRT_FILE_NAME("x86_64") : NACL_IRT_FILE_NAME("x86_32"); | 52 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 switches::kEnableNaClIPCProxy)) { | |
| 54 return is64 ? NACL_IRT_FILE_NAME("nacl_chrome_irt", "x86_64") : | |
|
Mark Seaborn
2012/08/14 01:12:05
Chrome's existing irt.nexe is Chrome-specific too,
dmichael (off chromium)
2012/08/14 17:03:31
Bill and I had talked about that name, too. It wou
bbudge
2012/08/14 18:35:18
'nacl_ipc_irt' was both David's and my first idea.
| |
| 55 NACL_IRT_FILE_NAME("nacl_chrome_irt", "x86_32"); | |
| 56 } else { | |
| 57 return is64 ? NACL_IRT_FILE_NAME("nacl_irt", "x86_64") : | |
| 58 NACL_IRT_FILE_NAME("nacl_irt", "x86_32"); | |
| 59 } | |
| 50 #elif defined(ARCH_CPU_ARMEL) | 60 #elif defined(ARCH_CPU_ARMEL) |
| 51 // TODO(mcgrathr): Eventually we'll need to distinguish arm32 vs thumb2. | 61 // TODO(mcgrathr): Eventually we'll need to distinguish arm32 vs thumb2. |
| 52 // That may need to be based on the actual nexe rather than a static | 62 // That may need to be based on the actual nexe rather than a static |
| 53 // choice, which would require substantial refactoring. | 63 // choice, which would require substantial refactoring. |
| 54 return NACL_IRT_FILE_NAME("arm"); | 64 return NACL_IRT_FILE_NAME("arm"); |
|
Mark Seaborn
2012/08/14 01:12:05
You need to update the ARM case too. It looks lik
bbudge
2012/08/14 18:35:18
Done.
| |
| 55 #else | 65 #else |
| 56 #error Add support for your architecture to NaCl IRT file selection | 66 #error Add support for your architecture to NaCl IRT file selection |
| 57 #endif | 67 #endif |
| 58 } | 68 } |
| 59 | 69 |
| 60 bool CheckEnvVar(const char* name, bool default_value) { | 70 bool CheckEnvVar(const char* name, bool default_value) { |
| 61 bool result = default_value; | 71 bool result = default_value; |
| 62 const char* var = getenv(name); | 72 const char* var = getenv(name); |
| 63 if (var && strlen(var) > 0) { | 73 if (var && strlen(var) > 0) { |
| 64 result = var[0] != '0'; | 74 result = var[0] != '0'; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 // because it can degrade the responsiveness of the browser. | 398 // because it can degrade the responsiveness of the browser. |
| 389 // The task is sequenced so that multiple writes happen in order. | 399 // The task is sequenced so that multiple writes happen in order. |
| 390 content::BrowserThread::PostBlockingPoolSequencedTask( | 400 content::BrowserThread::PostBlockingPoolSequencedTask( |
| 391 kValidationCacheSequenceName, | 401 kValidationCacheSequenceName, |
| 392 FROM_HERE, | 402 FROM_HERE, |
| 393 base::Bind(WriteCache, validation_cache_file_path_, | 403 base::Bind(WriteCache, validation_cache_file_path_, |
| 394 base::Owned(pickle))); | 404 base::Owned(pickle))); |
| 395 } | 405 } |
| 396 validation_cache_is_modified_ = false; | 406 validation_cache_is_modified_ = false; |
| 397 } | 407 } |
| OLD | NEW |