summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/backend_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/backend_impl.cc')
-rw-r--r--net/disk_cache/backend_impl.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 0709238..6162a77 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -13,6 +13,7 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/sys_info.h"
+#include "base/thread_restrictions.h"
#include "base/time.h"
#include "base/timer.h"
#include "base/worker_pool.h"
@@ -115,6 +116,10 @@ FilePath GetTempCacheName(const FilePath& path, const std::string& name) {
// Moves the cache files to a new folder and creates a task to delete them.
bool DelayedCacheCleanup(const FilePath& full_path) {
+ // GetTempCacheName() and MoveCache() use synchronous file
+ // operations.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+
FilePath current_path = full_path.StripTrailingSeparators();
FilePath path = current_path.DirName();
@@ -169,13 +174,13 @@ bool SetFieldTrialInfo(int size_group) {
// Field trials involve static objects so we have to do this only once.
first = false;
- scoped_refptr<base::FieldTrial> trial1 =
- new base::FieldTrial("CacheSize", 10);
+ scoped_refptr<base::FieldTrial> trial1(
+ new base::FieldTrial("CacheSize", 10));
std::string group1 = base::StringPrintf("CacheSizeGroup_%d", size_group);
trial1->AppendGroup(group1, base::FieldTrial::kAllRemainingProbability);
- scoped_refptr<base::FieldTrial> trial2 =
- new base::FieldTrial("CacheThrottle", 100);
+ scoped_refptr<base::FieldTrial> trial2(
+ new base::FieldTrial("CacheThrottle", 100));
int group2a = trial2->AppendGroup("CacheThrottle_On", 10); // 10 % in.
trial2->AppendGroup("CacheThrottle_Off", 10); // 10 % control.
@@ -1310,6 +1315,13 @@ int BackendImpl::RunTaskForTest(Task* task, CompletionCallback* callback) {
return net::ERR_IO_PENDING;
}
+void BackendImpl::ThrottleRequestsForTest(bool throttle) {
+ if (throttle)
+ background_queue_.StartQueingOperations();
+ else
+ background_queue_.StopQueingOperations();
+}
+
int BackendImpl::SelfCheck() {
if (!init_) {
LOG(ERROR) << "Init failed";