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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 273 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
274 EnsureIrtAvailable(); | 274 EnsureIrtAvailable(); |
275 EnsureValidationCacheAvailable(); | 275 EnsureValidationCacheAvailable(); |
276 } | 276 } |
277 | 277 |
278 // Load the IRT async. | 278 // Load the IRT async. |
279 void NaClBrowser::EnsureIrtAvailable() { | 279 void NaClBrowser::EnsureIrtAvailable() { |
280 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 280 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
281 if (IsOk() && irt_state_ == NaClResourceUninitialized) { | 281 if (IsOk() && irt_state_ == NaClResourceUninitialized) { |
282 irt_state_ = NaClResourceRequested; | 282 irt_state_ = NaClResourceRequested; |
283 // TODO(ncbray) use blocking pool. | 283 auto task_runner = base::CreateTaskRunnerWithTraits( |
| 284 {base::MayBlock , base::TaskPriority::BACKGROUND, |
| 285 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}); |
284 std::unique_ptr<base::FileProxy> file_proxy( | 286 std::unique_ptr<base::FileProxy> file_proxy( |
285 new base::FileProxy(content::BrowserThread::GetTaskRunnerForThread( | 287 new base::FileProxy(task_runner.get())); |
286 content::BrowserThread::FILE) | |
287 .get())); | |
288 base::FileProxy* proxy = file_proxy.get(); | 288 base::FileProxy* proxy = file_proxy.get(); |
289 if (!proxy->CreateOrOpen( | 289 if (!proxy->CreateOrOpen( |
290 irt_filepath_, base::File::FLAG_OPEN | base::File::FLAG_READ, | 290 irt_filepath_, base::File::FLAG_OPEN | base::File::FLAG_READ, |
291 base::Bind(&NaClBrowser::OnIrtOpened, base::Unretained(this), | 291 base::Bind(&NaClBrowser::OnIrtOpened, base::Unretained(this), |
292 base::Passed(&file_proxy)))) { | 292 base::Passed(&file_proxy)))) { |
293 LOG(ERROR) << "Internal error, NaCl disabled."; | 293 LOG(ERROR) << "Internal error, NaCl disabled."; |
294 MarkAsFailed(); | 294 MarkAsFailed(); |
295 } | 295 } |
296 } | 296 } |
297 } | 297 } |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 bool NaClBrowser::IsThrottled() { | 608 bool NaClBrowser::IsThrottled() { |
609 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 609 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
610 if (crash_times_.size() != kMaxCrashesPerInterval) { | 610 if (crash_times_.size() != kMaxCrashesPerInterval) { |
611 return false; | 611 return false; |
612 } | 612 } |
613 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 613 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
614 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 614 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
615 } | 615 } |
616 | 616 |
617 } // namespace nacl | 617 } // namespace nacl |
OLD | NEW |