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

Unified Diff: extensions/browser/quota_service.cc

Issue 2085673002: Remove calls to MessageLoop::current() in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/quota_service.cc
diff --git a/extensions/browser/quota_service.cc b/extensions/browser/quota_service.cc
index dbd11768bf76bc88cab7b25563208656aeedbd8d..6d6aae8213a792042296f2815eed0a74ba53f748 100644
--- a/extensions/browser/quota_service.cc
+++ b/extensions/browser/quota_service.cc
@@ -4,8 +4,8 @@
#include "extensions/browser/quota_service.h"
-#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "extensions/browser/extension_function.h"
#include "extensions/common/error_utils.h"
@@ -14,16 +14,18 @@ namespace {
// If the browser stays open long enough, we reset state once a day.
// Whatever this value is, it should be an order of magnitude longer than
// the longest interval in any of the QuotaLimitHeuristics in use.
-const int kPurgeIntervalInDays = 1;
+constexpr int kPurgeIntervalInDays = 1;
-const char kOverQuotaError[] = "This request exceeds the * quota.";
+constexpr char kOverQuotaError[] = "This request exceeds the * quota.";
+
+bool g_purge_disabled_for_testing = false;
} // namespace
namespace extensions {
QuotaService::QuotaService() {
- if (base::MessageLoop::current() != NULL) { // Null in unit tests.
+ if (!g_purge_disabled_for_testing && base::ThreadTaskRunnerHandle::IsSet()) {
purge_timer_.Start(FROM_HERE,
base::TimeDelta::FromDays(kPurgeIntervalInDays),
this,
@@ -76,6 +78,16 @@ std::string QuotaService::Assess(const std::string& extension_id,
return error;
}
+QuotaService::ScopedDisablePurgeForTesting::ScopedDisablePurgeForTesting() {
+ DCHECK(!g_purge_disabled_for_testing);
+ g_purge_disabled_for_testing = true;
+}
+
+QuotaService::ScopedDisablePurgeForTesting::~ScopedDisablePurgeForTesting() {
+ DCHECK(g_purge_disabled_for_testing);
+ g_purge_disabled_for_testing = false;
+}
+
void QuotaService::PurgeFunctionHeuristicsMap(FunctionHeuristicsMap* map) {
FunctionHeuristicsMap::iterator heuristics = map->begin();
while (heuristics != map->end()) {

Powered by Google App Engine
This is Rietveld 408576698