OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_IN_FLIGHT_BACKEND_IO_H_ | 5 #ifndef NET_DISK_CACHE_IN_FLIGHT_BACKEND_IO_H_ |
6 #define NET_DISK_CACHE_IN_FLIGHT_BACKEND_IO_H_ | 6 #define NET_DISK_CACHE_IN_FLIGHT_BACKEND_IO_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "base/time.h" | 13 #include "base/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/in_flight_io.h" | 16 #include "net/disk_cache/in_flight_io.h" |
17 | 17 |
18 namespace disk_cache { | 18 namespace disk_cache { |
19 | 19 |
20 class BackendImpl; | 20 class BackendImpl; |
21 class Entry; | 21 class Entry; |
22 class EntryImpl; | 22 class EntryImpl; |
23 | 23 |
24 // This class represents a single asynchronous disk cache IO operation while it | 24 // This class represents a single asynchronous disk cache IO operation while it |
25 // is being bounced between threads. | 25 // is being bounced between threads. |
26 class BackendIO : public BackgroundIO { | 26 class BackendIO : public BackgroundIO { |
27 public: | 27 public: |
28 BackendIO(InFlightIO* controller, BackendImpl* backend, | 28 BackendIO(InFlightIO* controller, BackendImpl* backend, |
29 net::OldCompletionCallback* callback); | 29 net::OldCompletionCallback* callback); |
| 30 BackendIO(InFlightIO* controller, BackendImpl* backend, |
| 31 const net::CompletionCallback& callback); |
30 | 32 |
31 // Runs the actual operation on the background thread. | 33 // Runs the actual operation on the background thread. |
32 void ExecuteOperation(); | 34 void ExecuteOperation(); |
33 | 35 |
34 // Callback implementation. | 36 // Callback implementation. |
35 void OnIOComplete(int result); | 37 void OnIOComplete(int result); |
36 | 38 |
37 // Returns true if this operation is directed to an entry (vs. the backend). | 39 // Returns true if this operation is directed to an entry (vs. the backend). |
38 bool IsEntryOperation(); | 40 bool IsEntryOperation(); |
39 | 41 |
40 net::OldCompletionCallback* callback() { return callback_; } | 42 net::OldCompletionCallback* old_callback() const { return old_callback_; } |
| 43 net::CompletionCallback callback() const { return callback_; } |
41 | 44 |
42 // Grabs an extra reference of entry_. | 45 // Grabs an extra reference of entry_. |
43 void ReferenceEntry(); | 46 void ReferenceEntry(); |
44 | 47 |
45 // Returns the time that has passed since the operation was created. | 48 // Returns the time that has passed since the operation was created. |
46 base::TimeDelta ElapsedTime() const; | 49 base::TimeDelta ElapsedTime() const; |
47 | 50 |
48 // The operations we proxy: | 51 // The operations we proxy: |
49 void Init(); | 52 void Init(); |
50 void OpenEntry(const std::string& key, Entry** entry); | 53 void OpenEntry(const std::string& key, Entry** entry); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 OP_CANCEL_IO, | 109 OP_CANCEL_IO, |
107 OP_IS_READY | 110 OP_IS_READY |
108 }; | 111 }; |
109 | 112 |
110 virtual ~BackendIO(); | 113 virtual ~BackendIO(); |
111 | 114 |
112 void ExecuteBackendOperation(); | 115 void ExecuteBackendOperation(); |
113 void ExecuteEntryOperation(); | 116 void ExecuteEntryOperation(); |
114 | 117 |
115 BackendImpl* backend_; | 118 BackendImpl* backend_; |
116 net::OldCompletionCallback* callback_; | 119 net::OldCompletionCallback* old_callback_; |
| 120 net::CompletionCallback callback_; |
117 Operation operation_; | 121 Operation operation_; |
118 net::OldCompletionCallbackImpl<BackendIO> my_callback_; | 122 net::OldCompletionCallbackImpl<BackendIO> my_callback_; |
119 | 123 |
120 // The arguments of all the operations we proxy: | 124 // The arguments of all the operations we proxy: |
121 std::string key_; | 125 std::string key_; |
122 Entry** entry_ptr_; | 126 Entry** entry_ptr_; |
123 base::Time initial_time_; | 127 base::Time initial_time_; |
124 base::Time end_time_; | 128 base::Time end_time_; |
125 void** iter_ptr_; | 129 void** iter_ptr_; |
126 void* iter_; | 130 void* iter_; |
(...skipping 19 matching lines...) Expand all Loading... |
146 virtual ~InFlightBackendIO(); | 150 virtual ~InFlightBackendIO(); |
147 | 151 |
148 // The operations we proxy: | 152 // The operations we proxy: |
149 void Init(net::OldCompletionCallback* callback); | 153 void Init(net::OldCompletionCallback* callback); |
150 void OpenEntry(const std::string& key, Entry** entry, | 154 void OpenEntry(const std::string& key, Entry** entry, |
151 net::OldCompletionCallback* callback); | 155 net::OldCompletionCallback* callback); |
152 void CreateEntry(const std::string& key, Entry** entry, | 156 void CreateEntry(const std::string& key, Entry** entry, |
153 net::OldCompletionCallback* callback); | 157 net::OldCompletionCallback* callback); |
154 void DoomEntry(const std::string& key, net::OldCompletionCallback* callback); | 158 void DoomEntry(const std::string& key, net::OldCompletionCallback* callback); |
155 void DoomAllEntries(net::OldCompletionCallback* callback); | 159 void DoomAllEntries(net::OldCompletionCallback* callback); |
| 160 void DoomAllEntries(const net::CompletionCallback& callback); |
156 void DoomEntriesBetween(const base::Time initial_time, | 161 void DoomEntriesBetween(const base::Time initial_time, |
157 const base::Time end_time, | 162 const base::Time end_time, |
158 net::OldCompletionCallback* callback); | 163 net::OldCompletionCallback* callback); |
| 164 void DoomEntriesBetween(const base::Time initial_time, |
| 165 const base::Time end_time, |
| 166 const net::CompletionCallback& callback); |
159 void DoomEntriesSince(const base::Time initial_time, | 167 void DoomEntriesSince(const base::Time initial_time, |
160 net::OldCompletionCallback* callback); | 168 net::OldCompletionCallback* callback); |
161 void OpenNextEntry(void** iter, Entry** next_entry, | 169 void OpenNextEntry(void** iter, Entry** next_entry, |
162 net::OldCompletionCallback* callback); | 170 net::OldCompletionCallback* callback); |
163 void OpenPrevEntry(void** iter, Entry** prev_entry, | 171 void OpenPrevEntry(void** iter, Entry** prev_entry, |
164 net::OldCompletionCallback* callback); | 172 net::OldCompletionCallback* callback); |
165 void EndEnumeration(void* iterator); | 173 void EndEnumeration(void* iterator); |
166 void OnExternalCacheHit(const std::string& key); | 174 void OnExternalCacheHit(const std::string& key); |
167 void CloseEntryImpl(EntryImpl* entry); | 175 void CloseEntryImpl(EntryImpl* entry); |
168 void DoomEntryImpl(EntryImpl* entry); | 176 void DoomEntryImpl(EntryImpl* entry); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 210 |
203 BackendImpl* backend_; | 211 BackendImpl* backend_; |
204 scoped_refptr<base::MessageLoopProxy> background_thread_; | 212 scoped_refptr<base::MessageLoopProxy> background_thread_; |
205 | 213 |
206 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); | 214 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); |
207 }; | 215 }; |
208 | 216 |
209 } // namespace disk_cache | 217 } // namespace disk_cache |
210 | 218 |
211 #endif // NET_DISK_CACHE_IN_FLIGHT_BACKEND_IO_H_ | 219 #endif // NET_DISK_CACHE_IN_FLIGHT_BACKEND_IO_H_ |
OLD | NEW |