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

Side by Side 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: rebase 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 unified diff | Download patch
OLDNEW
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 "extensions/browser/quota_service.h" 5 #include "extensions/browser/quota_service.h"
6 6
7 #include "base/message_loop/message_loop.h"
8 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/threading/thread_task_runner_handle.h"
9 #include "extensions/browser/extension_function.h" 9 #include "extensions/browser/extension_function.h"
10 #include "extensions/common/error_utils.h" 10 #include "extensions/common/error_utils.h"
11 11
12 namespace { 12 namespace {
13 13
14 // If the browser stays open long enough, we reset state once a day. 14 // If the browser stays open long enough, we reset state once a day.
15 // Whatever this value is, it should be an order of magnitude longer than 15 // Whatever this value is, it should be an order of magnitude longer than
16 // the longest interval in any of the QuotaLimitHeuristics in use. 16 // the longest interval in any of the QuotaLimitHeuristics in use.
17 const int kPurgeIntervalInDays = 1; 17 const int kPurgeIntervalInDays = 1;
18 18
19 const char kOverQuotaError[] = "This request exceeds the * quota."; 19 const char kOverQuotaError[] = "This request exceeds the * quota.";
20 20
21 } // namespace 21 } // namespace
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 QuotaService::QuotaService() { 25 QuotaService::QuotaService() {
26 if (base::MessageLoop::current() != NULL) { // Null in unit tests. 26 if (base::ThreadTaskRunnerHandle::IsSet()) { // Not always set in unit tests.
27 purge_timer_.Start(FROM_HERE, 27 purge_timer_.Start(FROM_HERE,
28 base::TimeDelta::FromDays(kPurgeIntervalInDays), 28 base::TimeDelta::FromDays(kPurgeIntervalInDays),
29 this, 29 this,
30 &QuotaService::Purge); 30 &QuotaService::Purge);
31 } 31 }
32 } 32 }
33 33
34 QuotaService::~QuotaService() { 34 QuotaService::~QuotaService() {
35 DCHECK(CalledOnValidThread()); 35 DCHECK(CalledOnValidThread());
36 purge_timer_.Stop(); 36 purge_timer_.Stop();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 bool QuotaService::TimedLimit::Apply(Bucket* bucket, 131 bool QuotaService::TimedLimit::Apply(Bucket* bucket,
132 const base::TimeTicks& event_time) { 132 const base::TimeTicks& event_time) {
133 if (event_time > bucket->expiration()) 133 if (event_time > bucket->expiration())
134 bucket->Reset(config(), event_time); 134 bucket->Reset(config(), event_time);
135 135
136 return bucket->DeductToken(); 136 return bucket->DeductToken();
137 } 137 }
138 138
139 } // namespace extensions 139 } // namespace extensions
OLDNEW
« extensions/browser/file_reader.h ('K') | « extensions/browser/process_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698