| 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/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 bool CheckEnvVar(const char* name, bool default_value) { | 79 bool CheckEnvVar(const char* name, bool default_value) { |
| 80 bool result = default_value; | 80 bool result = default_value; |
| 81 const char* var = getenv(name); | 81 const char* var = getenv(name); |
| 82 if (var && strlen(var) > 0) { | 82 if (var && strlen(var) > 0) { |
| 83 result = var[0] != '0'; | 83 result = var[0] != '0'; |
| 84 } | 84 } |
| 85 return result; | 85 return result; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ReadCache(const base::FilePath& filename, std::string* data) { | 88 void ReadCache(const base::FilePath& filename, std::string* data) { |
| 89 if (!file_util::ReadFileToString(filename, data)) { | 89 if (!base::ReadFileToString(filename, data)) { |
| 90 // Zero-size data used as an in-band error code. | 90 // Zero-size data used as an in-band error code. |
| 91 data->clear(); | 91 data->clear(); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 void WriteCache(const base::FilePath& filename, const Pickle* pickle) { | 95 void WriteCache(const base::FilePath& filename, const Pickle* pickle) { |
| 96 file_util::WriteFile(filename, static_cast<const char*>(pickle->data()), | 96 file_util::WriteFile(filename, static_cast<const char*>(pickle->data()), |
| 97 pickle->size()); | 97 pickle->size()); |
| 98 } | 98 } |
| 99 | 99 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 | 593 |
| 594 bool NaClBrowser::IsThrottled() { | 594 bool NaClBrowser::IsThrottled() { |
| 595 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 595 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 596 if (crash_times_.size() != kMaxCrashesPerInterval) { | 596 if (crash_times_.size() != kMaxCrashesPerInterval) { |
| 597 return false; | 597 return false; |
| 598 } | 598 } |
| 599 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 599 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
| 600 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 600 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
| 601 } | 601 } |
| OLD | NEW |