OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 size_t offset, disk_cache::FileIOCallback* callback); | 73 size_t offset, disk_cache::FileIOCallback* callback); |
74 void PostWrite(disk_cache::File* file, const void* buf, size_t buf_len, | 74 void PostWrite(disk_cache::File* file, const void* buf, size_t buf_len, |
75 size_t offset, disk_cache::FileIOCallback* callback); | 75 size_t offset, disk_cache::FileIOCallback* callback); |
76 | 76 |
77 protected: | 77 protected: |
78 // Invokes the users' completion callback at the end of the IO operation. | 78 // Invokes the users' completion callback at the end of the IO operation. |
79 // |cancel| is true if the actual task posted to the thread is still | 79 // |cancel| is true if the actual task posted to the thread is still |
80 // queued (because we are inside WaitForPendingIO), and false if said task is | 80 // queued (because we are inside WaitForPendingIO), and false if said task is |
81 // the one performing the call. | 81 // the one performing the call. |
82 virtual void OnOperationComplete(disk_cache::BackgroundIO* operation, | 82 virtual void OnOperationComplete(disk_cache::BackgroundIO* operation, |
83 bool cancel) OVERRIDE; | 83 bool cancel) override; |
84 | 84 |
85 private: | 85 private: |
86 DISALLOW_COPY_AND_ASSIGN(FileInFlightIO); | 86 DISALLOW_COPY_AND_ASSIGN(FileInFlightIO); |
87 }; | 87 }; |
88 | 88 |
89 // --------------------------------------------------------------------------- | 89 // --------------------------------------------------------------------------- |
90 | 90 |
91 // Runs on a worker thread. | 91 // Runs on a worker thread. |
92 void FileBackgroundIO::Read() { | 92 void FileBackgroundIO::Read() { |
93 if (file_->Read(const_cast<void*>(buf_), buf_len_, offset_)) { | 93 if (file_->Read(const_cast<void*>(buf_), buf_len_, offset_)) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 return false; | 288 return false; |
289 | 289 |
290 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); | 290 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); |
291 | 291 |
292 if (completed) | 292 if (completed) |
293 *completed = false; | 293 *completed = false; |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 } // namespace disk_cache | 297 } // namespace disk_cache |
OLD | NEW |