| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 if (IsOk() && validation_cache_state_ == NaClResourceUninitialized) { | 370 if (IsOk() && validation_cache_state_ == NaClResourceUninitialized) { |
| 371 if (ValidationCacheIsEnabled()) { | 371 if (ValidationCacheIsEnabled()) { |
| 372 validation_cache_state_ = NaClResourceRequested; | 372 validation_cache_state_ = NaClResourceRequested; |
| 373 | 373 |
| 374 // Structure for carrying data between the callbacks. | 374 // Structure for carrying data between the callbacks. |
| 375 std::string* data = new std::string(); | 375 std::string* data = new std::string(); |
| 376 // We can get away not giving this a sequence ID because this is the first | 376 // We can get away not giving this a sequence ID because this is the first |
| 377 // task and further file access will not occur until after we get a | 377 // task and further file access will not occur until after we get a |
| 378 // response. | 378 // response. |
| 379 base::PostTaskWithTraitsAndReply( | 379 base::PostTaskWithTraitsAndReply( |
| 380 FROM_HERE, | 380 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 381 base::TaskTraits().MayBlock().WithPriority( | |
| 382 base::TaskPriority::BACKGROUND), | |
| 383 base::Bind(ReadCache, validation_cache_file_path_, data), | 381 base::Bind(ReadCache, validation_cache_file_path_, data), |
| 384 base::Bind(&NaClBrowser::OnValidationCacheLoaded, | 382 base::Bind(&NaClBrowser::OnValidationCacheLoaded, |
| 385 base::Unretained(this), base::Owned(data))); | 383 base::Unretained(this), base::Owned(data))); |
| 386 } else { | 384 } else { |
| 387 RunWithoutValidationCache(); | 385 RunWithoutValidationCache(); |
| 388 } | 386 } |
| 389 } | 387 } |
| 390 } | 388 } |
| 391 | 389 |
| 392 void NaClBrowser::OnValidationCacheLoaded(const std::string *data) { | 390 void NaClBrowser::OnValidationCacheLoaded(const std::string *data) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 bool NaClBrowser::IsThrottled() { | 608 bool NaClBrowser::IsThrottled() { |
| 611 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 609 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 612 if (crash_times_.size() != kMaxCrashesPerInterval) { | 610 if (crash_times_.size() != kMaxCrashesPerInterval) { |
| 613 return false; | 611 return false; |
| 614 } | 612 } |
| 615 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 613 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
| 616 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 614 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
| 617 } | 615 } |
| 618 | 616 |
| 619 } // namespace nacl | 617 } // namespace nacl |
| OLD | NEW |