| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "net/disk_cache/disk_cache.h" | 14 #include "net/disk_cache/disk_cache.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // Structure used for asynchronous operations. | 18 // Structure used for asynchronous operations. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 context_.overlapped.Offset = static_cast<DWORD>(offset); | 67 context_.overlapped.Offset = static_cast<DWORD>(offset); |
| 67 file_ = file; | 68 file_ = file; |
| 68 callback_ = callback; | 69 callback_ = callback; |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace | 72 } // namespace |
| 72 | 73 |
| 73 namespace disk_cache { | 74 namespace disk_cache { |
| 74 | 75 |
| 75 File::File(base::File file) | 76 File::File(base::File file) |
| 76 : init_(true), | 77 : init_(true), mixed_(true), sync_base_file_(std::move(file)) {} |
| 77 mixed_(true), | |
| 78 sync_base_file_(file.Pass()) { | |
| 79 } | |
| 80 | 78 |
| 81 bool File::Init(const base::FilePath& name) { | 79 bool File::Init(const base::FilePath& name) { |
| 82 DCHECK(!init_); | 80 DCHECK(!init_); |
| 83 if (init_) | 81 if (init_) |
| 84 return false; | 82 return false; |
| 85 | 83 |
| 86 DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; | 84 DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
| 87 DWORD access = GENERIC_READ | GENERIC_WRITE | DELETE; | 85 DWORD access = GENERIC_READ | GENERIC_WRITE | DELETE; |
| 88 base_file_ = | 86 base_file_ = |
| 89 base::File(CreateFile(name.value().c_str(), access, sharing, NULL, | 87 base::File(CreateFile(name.value().c_str(), access, sharing, NULL, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer(); | 249 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer(); |
| 252 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); | 250 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); |
| 253 } | 251 } |
| 254 } | 252 } |
| 255 | 253 |
| 256 // Static. | 254 // Static. |
| 257 void File::DropPendingIO() { | 255 void File::DropPendingIO() { |
| 258 } | 256 } |
| 259 | 257 |
| 260 } // namespace disk_cache | 258 } // namespace disk_cache |
| OLD | NEW |