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 "net/disk_cache/blockfile/file.h" | 5 #include "net/disk_cache/blockfile/file.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/disk_cache/disk_cache.h" | 15 #include "net/disk_cache/disk_cache.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // The maximum number of threads for this pool. | 19 // The maximum number of threads for this pool. |
20 const int kMaxThreads = 5; | 20 const int kMaxThreads = 5; |
21 | 21 |
22 class FileWorkerPool : public base::SequencedWorkerPool { | 22 class FileWorkerPool : public base::SequencedWorkerPool { |
23 public: | 23 public: |
24 FileWorkerPool() : base::SequencedWorkerPool(kMaxThreads, "CachePool") {} | 24 FileWorkerPool() : base::SequencedWorkerPool(kMaxThreads, "CachePool") {} |
25 | 25 |
26 protected: | 26 protected: |
27 virtual ~FileWorkerPool() {} | 27 ~FileWorkerPool() override {} |
28 }; | 28 }; |
29 | 29 |
30 base::LazyInstance<FileWorkerPool>::Leaky s_worker_pool = | 30 base::LazyInstance<FileWorkerPool>::Leaky s_worker_pool = |
31 LAZY_INSTANCE_INITIALIZER; | 31 LAZY_INSTANCE_INITIALIZER; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 namespace disk_cache { | 35 namespace disk_cache { |
36 | 36 |
37 File::File(base::File file) | 37 File::File(base::File file) |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return net::ERR_CACHE_WRITE_FAILURE; | 178 return net::ERR_CACHE_WRITE_FAILURE; |
179 } | 179 } |
180 | 180 |
181 // This method actually makes sure that the last reference to the file doesn't | 181 // This method actually makes sure that the last reference to the file doesn't |
182 // go away on the worker pool. | 182 // go away on the worker pool. |
183 void File::OnOperationComplete(FileIOCallback* callback, int result) { | 183 void File::OnOperationComplete(FileIOCallback* callback, int result) { |
184 callback->OnFileIOComplete(result); | 184 callback->OnFileIOComplete(result); |
185 } | 185 } |
186 | 186 |
187 } // namespace disk_cache | 187 } // namespace disk_cache |
OLD | NEW |