| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | |
| 9 #include <limits> | 8 #include <limits> |
| 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
| 17 #include "base/threading/sequenced_worker_pool.h" | 17 #include "base/threading/sequenced_worker_pool.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/disk_cache/disk_cache.h" | 19 #include "net/disk_cache/disk_cache.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 base::LazyInstance<FileWorkerPool>::Leaky s_worker_pool = | 34 base::LazyInstance<FileWorkerPool>::Leaky s_worker_pool = |
| 35 LAZY_INSTANCE_INITIALIZER; | 35 LAZY_INSTANCE_INITIALIZER; |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 namespace disk_cache { | 39 namespace disk_cache { |
| 40 | 40 |
| 41 File::File(base::File file) | 41 File::File(base::File file) |
| 42 : init_(true), | 42 : init_(true), mixed_(true), base_file_(std::move(file)) {} |
| 43 mixed_(true), | |
| 44 base_file_(file.Pass()) { | |
| 45 } | |
| 46 | 43 |
| 47 bool File::Init(const base::FilePath& name) { | 44 bool File::Init(const base::FilePath& name) { |
| 48 if (base_file_.IsValid()) | 45 if (base_file_.IsValid()) |
| 49 return false; | 46 return false; |
| 50 | 47 |
| 51 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | | 48 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | |
| 52 base::File::FLAG_WRITE; | 49 base::File::FLAG_WRITE; |
| 53 base_file_.Initialize(name, flags); | 50 base_file_.Initialize(name, flags); |
| 54 return base_file_.IsValid(); | 51 return base_file_.IsValid(); |
| 55 } | 52 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return net::ERR_CACHE_WRITE_FAILURE; | 179 return net::ERR_CACHE_WRITE_FAILURE; |
| 183 } | 180 } |
| 184 | 181 |
| 185 // This method actually makes sure that the last reference to the file doesn't | 182 // This method actually makes sure that the last reference to the file doesn't |
| 186 // go away on the worker pool. | 183 // go away on the worker pool. |
| 187 void File::OnOperationComplete(FileIOCallback* callback, int result) { | 184 void File::OnOperationComplete(FileIOCallback* callback, int result) { |
| 188 callback->OnFileIOComplete(result); | 185 callback->OnFileIOComplete(result); |
| 189 } | 186 } |
| 190 | 187 |
| 191 } // namespace disk_cache | 188 } // namespace disk_cache |
| OLD | NEW |