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

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

Issue 831813004: Get nacl building again for android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment out CheckEnvVar Created 5 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 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/nacl_browser.h" 5 #include "components/nacl/browser/nacl_browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_proxy.h" 8 #include "base/files/file_proxy.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 irt_name.append(FILE_PATH_LITERAL("arm")); 59 irt_name.append(FILE_PATH_LITERAL("arm"));
60 #elif defined(ARCH_CPU_MIPSEL) 60 #elif defined(ARCH_CPU_MIPSEL)
61 irt_name.append(FILE_PATH_LITERAL("mips32")); 61 irt_name.append(FILE_PATH_LITERAL("mips32"));
62 #else 62 #else
63 #error Add support for your architecture to NaCl IRT file selection 63 #error Add support for your architecture to NaCl IRT file selection
64 #endif 64 #endif
65 irt_name.append(FILE_PATH_LITERAL(".nexe")); 65 irt_name.append(FILE_PATH_LITERAL(".nexe"));
66 return irt_name; 66 return irt_name;
67 } 67 }
68 68
69 #if !defined(OS_ANDROID)
69 bool CheckEnvVar(const char* name, bool default_value) { 70 bool CheckEnvVar(const char* name, bool default_value) {
70 bool result = default_value; 71 bool result = default_value;
71 const char* var = getenv(name); 72 const char* var = getenv(name);
72 if (var && strlen(var) > 0) { 73 if (var && strlen(var) > 0) {
73 result = var[0] != '0'; 74 result = var[0] != '0';
74 } 75 }
75 return result; 76 return result;
76 } 77 }
78 #endif
77 79
78 void ReadCache(const base::FilePath& filename, std::string* data) { 80 void ReadCache(const base::FilePath& filename, std::string* data) {
79 if (!base::ReadFileToString(filename, data)) { 81 if (!base::ReadFileToString(filename, data)) {
80 // Zero-size data used as an in-band error code. 82 // Zero-size data used as an in-band error code.
81 data->clear(); 83 data->clear();
82 } 84 }
83 } 85 }
84 86
85 void WriteCache(const base::FilePath& filename, const Pickle* pickle) { 87 void WriteCache(const base::FilePath& filename, const Pickle* pickle) {
86 base::WriteFile(filename, static_cast<const char*>(pickle->data()), 88 base::WriteFile(filename, static_cast<const char*>(pickle->data()),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (!file.GetInfo(&file_info) || file_info.is_directory) 135 if (!file.GetInfo(&file_info) || file_info.is_directory)
134 return base::File(); 136 return base::File();
135 137
136 return file.Pass(); 138 return file.Pass();
137 } 139 }
138 140
139 NaClBrowser::NaClBrowser() 141 NaClBrowser::NaClBrowser()
140 : irt_filepath_(), 142 : irt_filepath_(),
141 irt_state_(NaClResourceUninitialized), 143 irt_state_(NaClResourceUninitialized),
142 validation_cache_file_path_(), 144 validation_cache_file_path_(),
143 validation_cache_is_enabled_( 145 validation_cache_is_enabled_(false),
144 CheckEnvVar("NACL_VALIDATION_CACHE",
145 kValidationCacheEnabledByDefault)),
146 validation_cache_is_modified_(false), 146 validation_cache_is_modified_(false),
147 validation_cache_state_(NaClResourceUninitialized), 147 validation_cache_state_(NaClResourceUninitialized),
148 path_cache_(kFilePathCacheSize), 148 path_cache_(kFilePathCacheSize),
149 ok_(true), 149 ok_(true),
150 weak_factory_(this) { 150 weak_factory_(this) {
151 #if !defined(OS_ANDROID)
152 validation_cache_is_enabled_ =
153 CheckEnvVar("NACL_VALIDATION_CACHE",
154 kValidationCacheEnabledByDefault);
155 #endif
151 } 156 }
152 157
153 void NaClBrowser::SetDelegate(NaClBrowserDelegate* delegate) { 158 void NaClBrowser::SetDelegate(NaClBrowserDelegate* delegate) {
154 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 159 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
155 nacl_browser->browser_delegate_.reset(delegate); 160 nacl_browser->browser_delegate_.reset(delegate);
156 } 161 }
157 162
158 NaClBrowserDelegate* NaClBrowser::GetDelegate() { 163 NaClBrowserDelegate* NaClBrowser::GetDelegate() {
159 // The delegate is not owned by the IO thread. This accessor method can be 164 // The delegate is not owned by the IO thread. This accessor method can be
160 // called from other threads. 165 // called from other threads.
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 bool NaClBrowser::IsThrottled() { 560 bool NaClBrowser::IsThrottled() {
556 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 561 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
557 if (crash_times_.size() != kMaxCrashesPerInterval) { 562 if (crash_times_.size() != kMaxCrashesPerInterval) {
558 return false; 563 return false;
559 } 564 }
560 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); 565 base::TimeDelta delta = base::Time::Now() - crash_times_.front();
561 return delta.InSeconds() <= kCrashesIntervalInSeconds; 566 return delta.InSeconds() <= kCrashesIntervalInSeconds;
562 } 567 }
563 568
564 } // namespace nacl 569 } // namespace nacl
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pepper_uma_host.cc ('k') | components/nacl/browser/nacl_browser_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698