OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_proxy.h" | 10 #include "base/files/file_proxy.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 EnsureIrtAvailable(); | 240 EnsureIrtAvailable(); |
241 EnsureValidationCacheAvailable(); | 241 EnsureValidationCacheAvailable(); |
242 } | 242 } |
243 | 243 |
244 // Load the IRT async. | 244 // Load the IRT async. |
245 void NaClBrowser::EnsureIrtAvailable() { | 245 void NaClBrowser::EnsureIrtAvailable() { |
246 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 246 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
247 if (IsOk() && irt_state_ == NaClResourceUninitialized) { | 247 if (IsOk() && irt_state_ == NaClResourceUninitialized) { |
248 irt_state_ = NaClResourceRequested; | 248 irt_state_ = NaClResourceRequested; |
249 // TODO(ncbray) use blocking pool. | 249 // TODO(ncbray) use blocking pool. |
250 std::unique_ptr<base::FileProxy> file_proxy(new base::FileProxy( | 250 std::unique_ptr<base::FileProxy> file_proxy( |
251 content::BrowserThread::GetMessageLoopProxyForThread( | 251 new base::FileProxy(content::BrowserThread::GetTaskRunnerForThread( |
252 content::BrowserThread::FILE) | 252 content::BrowserThread::FILE) |
253 .get())); | 253 .get())); |
254 base::FileProxy* proxy = file_proxy.get(); | 254 base::FileProxy* proxy = file_proxy.get(); |
255 if (!proxy->CreateOrOpen(irt_filepath_, | 255 if (!proxy->CreateOrOpen(irt_filepath_, |
256 base::File::FLAG_OPEN | base::File::FLAG_READ, | 256 base::File::FLAG_OPEN | base::File::FLAG_READ, |
257 base::Bind(&NaClBrowser::OnIrtOpened, | 257 base::Bind(&NaClBrowser::OnIrtOpened, |
258 weak_factory_.GetWeakPtr(), | 258 weak_factory_.GetWeakPtr(), |
259 Passed(&file_proxy)))) { | 259 Passed(&file_proxy)))) { |
260 LOG(ERROR) << "Internal error, NaCl disabled."; | 260 LOG(ERROR) << "Internal error, NaCl disabled."; |
261 MarkAsFailed(); | 261 MarkAsFailed(); |
262 } | 262 } |
263 } | 263 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 bool NaClBrowser::IsThrottled() { | 566 bool NaClBrowser::IsThrottled() { |
567 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 567 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
568 if (crash_times_.size() != kMaxCrashesPerInterval) { | 568 if (crash_times_.size() != kMaxCrashesPerInterval) { |
569 return false; | 569 return false; |
570 } | 570 } |
571 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 571 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
572 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 572 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
573 } | 573 } |
574 | 574 |
575 } // namespace nacl | 575 } // namespace nacl |
OLD | NEW |