| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "net/disk_cache/simple/simple_backend_impl.h" | 5 #include "net/disk_cache/simple/simple_backend_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <functional> | 9 #include <functional> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 const char kThreadNamePrefix[] = "SimpleCache"; | 59 const char kThreadNamePrefix[] = "SimpleCache"; |
| 60 | 60 |
| 61 // Maximum fraction of the cache that one entry can consume. | 61 // Maximum fraction of the cache that one entry can consume. |
| 62 const int kMaxFileRatio = 8; | 62 const int kMaxFileRatio = 8; |
| 63 | 63 |
| 64 class LeakySequencedWorkerPool { | 64 class LeakySequencedWorkerPool { |
| 65 public: | 65 public: |
| 66 LeakySequencedWorkerPool() | 66 LeakySequencedWorkerPool() |
| 67 : sequenced_worker_pool_( | 67 : sequenced_worker_pool_( |
| 68 new SequencedWorkerPool(kMaxWorkerThreads, kThreadNamePrefix)) {} | 68 new SequencedWorkerPool(kMaxWorkerThreads, |
| 69 kThreadNamePrefix, |
| 70 base::TaskPriority::USER_BLOCKING)) {} |
| 69 | 71 |
| 70 void FlushForTesting() { sequenced_worker_pool_->FlushForTesting(); } | 72 void FlushForTesting() { sequenced_worker_pool_->FlushForTesting(); } |
| 71 | 73 |
| 72 scoped_refptr<base::TaskRunner> GetTaskRunner() { | 74 scoped_refptr<base::TaskRunner> GetTaskRunner() { |
| 73 return sequenced_worker_pool_->GetTaskRunnerWithShutdownBehavior( | 75 return sequenced_worker_pool_->GetTaskRunnerWithShutdownBehavior( |
| 74 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); | 76 SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); |
| 75 } | 77 } |
| 76 | 78 |
| 77 private: | 79 private: |
| 78 scoped_refptr<SequencedWorkerPool> sequenced_worker_pool_; | 80 scoped_refptr<SequencedWorkerPool> sequenced_worker_pool_; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 } | 718 } |
| 717 | 719 |
| 718 // static | 720 // static |
| 719 void SimpleBackendImpl::FlushWorkerPoolForTesting() { | 721 void SimpleBackendImpl::FlushWorkerPoolForTesting() { |
| 720 // We only need to do this if we there is an active task runner. | 722 // We only need to do this if we there is an active task runner. |
| 721 if (base::ThreadTaskRunnerHandle::IsSet()) | 723 if (base::ThreadTaskRunnerHandle::IsSet()) |
| 722 g_sequenced_worker_pool.Get().FlushForTesting(); | 724 g_sequenced_worker_pool.Get().FlushForTesting(); |
| 723 } | 725 } |
| 724 | 726 |
| 725 } // namespace disk_cache | 727 } // namespace disk_cache |
| OLD | NEW |