| 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 #ifndef NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ | 5 #ifndef NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ |
| 6 #define NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ | 6 #define NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 16 #include "net/disk_cache/blockfile/in_flight_io.h" | 16 #include "net/disk_cache/blockfile/in_flight_io.h" |
| 17 #include "net/disk_cache/blockfile/rankings.h" |
| 17 | 18 |
| 18 namespace disk_cache { | 19 namespace disk_cache { |
| 19 | 20 |
| 20 class BackendImpl; | 21 class BackendImpl; |
| 21 class Entry; | 22 class Entry; |
| 22 class EntryImpl; | 23 class EntryImpl; |
| 23 | 24 |
| 24 // This class represents a single asynchronous disk cache IO operation while it | 25 // This class represents a single asynchronous disk cache IO operation while it |
| 25 // is being bounced between threads. | 26 // is being bounced between threads. |
| 26 class BackendIO : public BackgroundIO { | 27 class BackendIO : public BackgroundIO { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 // The operations we proxy: | 50 // The operations we proxy: |
| 50 void Init(); | 51 void Init(); |
| 51 void OpenEntry(const std::string& key, Entry** entry); | 52 void OpenEntry(const std::string& key, Entry** entry); |
| 52 void CreateEntry(const std::string& key, Entry** entry); | 53 void CreateEntry(const std::string& key, Entry** entry); |
| 53 void DoomEntry(const std::string& key); | 54 void DoomEntry(const std::string& key); |
| 54 void DoomAllEntries(); | 55 void DoomAllEntries(); |
| 55 void DoomEntriesBetween(const base::Time initial_time, | 56 void DoomEntriesBetween(const base::Time initial_time, |
| 56 const base::Time end_time); | 57 const base::Time end_time); |
| 57 void DoomEntriesSince(const base::Time initial_time); | 58 void DoomEntriesSince(const base::Time initial_time); |
| 58 void OpenNextEntry(void** iter, Entry** next_entry); | 59 void OpenNextEntry(Rankings::Iterator* iterator, Entry** next_entry); |
| 59 void EndEnumeration(void* iterator); | 60 void EndEnumeration(scoped_ptr<Rankings::Iterator> iterator); |
| 60 void OnExternalCacheHit(const std::string& key); | 61 void OnExternalCacheHit(const std::string& key); |
| 61 void CloseEntryImpl(EntryImpl* entry); | 62 void CloseEntryImpl(EntryImpl* entry); |
| 62 void DoomEntryImpl(EntryImpl* entry); | 63 void DoomEntryImpl(EntryImpl* entry); |
| 63 void FlushQueue(); // Dummy operation. | 64 void FlushQueue(); // Dummy operation. |
| 64 void RunTask(const base::Closure& task); | 65 void RunTask(const base::Closure& task); |
| 65 void ReadData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, | 66 void ReadData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, |
| 66 int buf_len); | 67 int buf_len); |
| 67 void WriteData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, | 68 void WriteData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, |
| 68 int buf_len, bool truncate); | 69 int buf_len, bool truncate); |
| 69 void ReadSparseData(EntryImpl* entry, int64 offset, net::IOBuffer* buf, | 70 void ReadSparseData(EntryImpl* entry, int64 offset, net::IOBuffer* buf, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 120 |
| 120 BackendImpl* backend_; | 121 BackendImpl* backend_; |
| 121 net::CompletionCallback callback_; | 122 net::CompletionCallback callback_; |
| 122 Operation operation_; | 123 Operation operation_; |
| 123 | 124 |
| 124 // The arguments of all the operations we proxy: | 125 // The arguments of all the operations we proxy: |
| 125 std::string key_; | 126 std::string key_; |
| 126 Entry** entry_ptr_; | 127 Entry** entry_ptr_; |
| 127 base::Time initial_time_; | 128 base::Time initial_time_; |
| 128 base::Time end_time_; | 129 base::Time end_time_; |
| 129 void** iter_ptr_; | 130 Rankings::Iterator* iterator_; |
| 130 void* iter_; | 131 scoped_ptr<Rankings::Iterator> scoped_iterator_; |
| 131 EntryImpl* entry_; | 132 EntryImpl* entry_; |
| 132 int index_; | 133 int index_; |
| 133 int offset_; | 134 int offset_; |
| 134 scoped_refptr<net::IOBuffer> buf_; | 135 scoped_refptr<net::IOBuffer> buf_; |
| 135 int buf_len_; | 136 int buf_len_; |
| 136 bool truncate_; | 137 bool truncate_; |
| 137 int64 offset64_; | 138 int64 offset64_; |
| 138 int64* start_; | 139 int64* start_; |
| 139 base::TimeTicks start_time_; | 140 base::TimeTicks start_time_; |
| 140 base::Closure task_; | 141 base::Closure task_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 void CreateEntry(const std::string& key, Entry** entry, | 158 void CreateEntry(const std::string& key, Entry** entry, |
| 158 const net::CompletionCallback& callback); | 159 const net::CompletionCallback& callback); |
| 159 void DoomEntry(const std::string& key, | 160 void DoomEntry(const std::string& key, |
| 160 const net::CompletionCallback& callback); | 161 const net::CompletionCallback& callback); |
| 161 void DoomAllEntries(const net::CompletionCallback& callback); | 162 void DoomAllEntries(const net::CompletionCallback& callback); |
| 162 void DoomEntriesBetween(const base::Time initial_time, | 163 void DoomEntriesBetween(const base::Time initial_time, |
| 163 const base::Time end_time, | 164 const base::Time end_time, |
| 164 const net::CompletionCallback& callback); | 165 const net::CompletionCallback& callback); |
| 165 void DoomEntriesSince(const base::Time initial_time, | 166 void DoomEntriesSince(const base::Time initial_time, |
| 166 const net::CompletionCallback& callback); | 167 const net::CompletionCallback& callback); |
| 167 void OpenNextEntry(void** iter, Entry** next_entry, | 168 void OpenNextEntry(Rankings::Iterator* iterator, Entry** next_entry, |
| 168 const net::CompletionCallback& callback); | 169 const net::CompletionCallback& callback); |
| 169 void EndEnumeration(void* iterator); | 170 void EndEnumeration(scoped_ptr<Rankings::Iterator> iterator); |
| 170 void OnExternalCacheHit(const std::string& key); | 171 void OnExternalCacheHit(const std::string& key); |
| 171 void CloseEntryImpl(EntryImpl* entry); | 172 void CloseEntryImpl(EntryImpl* entry); |
| 172 void DoomEntryImpl(EntryImpl* entry); | 173 void DoomEntryImpl(EntryImpl* entry); |
| 173 void FlushQueue(const net::CompletionCallback& callback); | 174 void FlushQueue(const net::CompletionCallback& callback); |
| 174 void RunTask(const base::Closure& task, | 175 void RunTask(const base::Closure& task, |
| 175 const net::CompletionCallback& callback); | 176 const net::CompletionCallback& callback); |
| 176 void ReadData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, | 177 void ReadData(EntryImpl* entry, int index, int offset, net::IOBuffer* buf, |
| 177 int buf_len, const net::CompletionCallback& callback); | 178 int buf_len, const net::CompletionCallback& callback); |
| 178 void WriteData( | 179 void WriteData( |
| 179 EntryImpl* entry, int index, int offset, net::IOBuffer* buf, | 180 EntryImpl* entry, int index, int offset, net::IOBuffer* buf, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 BackendImpl* backend_; | 213 BackendImpl* backend_; |
| 213 scoped_refptr<base::SingleThreadTaskRunner> background_thread_; | 214 scoped_refptr<base::SingleThreadTaskRunner> background_thread_; |
| 214 base::WeakPtrFactory<InFlightBackendIO> ptr_factory_; | 215 base::WeakPtrFactory<InFlightBackendIO> ptr_factory_; |
| 215 | 216 |
| 216 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); | 217 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); |
| 217 }; | 218 }; |
| 218 | 219 |
| 219 } // namespace disk_cache | 220 } // namespace disk_cache |
| 220 | 221 |
| 221 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ | 222 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ |
| OLD | NEW |