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 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 OP_MAX_BACKEND, | 100 OP_MAX_BACKEND, |
101 OP_READ, | 101 OP_READ, |
102 OP_WRITE, | 102 OP_WRITE, |
103 OP_READ_SPARSE, | 103 OP_READ_SPARSE, |
104 OP_WRITE_SPARSE, | 104 OP_WRITE_SPARSE, |
105 OP_GET_RANGE, | 105 OP_GET_RANGE, |
106 OP_CANCEL_IO, | 106 OP_CANCEL_IO, |
107 OP_IS_READY | 107 OP_IS_READY |
108 }; | 108 }; |
109 | 109 |
110 virtual ~BackendIO(); | 110 ~BackendIO() override; |
111 | 111 |
112 // Returns true if this operation returns an entry. | 112 // Returns true if this operation returns an entry. |
113 bool ReturnsEntry(); | 113 bool ReturnsEntry(); |
114 | 114 |
115 // Returns the time that has passed since the operation was created. | 115 // Returns the time that has passed since the operation was created. |
116 base::TimeDelta ElapsedTime() const; | 116 base::TimeDelta ElapsedTime() const; |
117 | 117 |
118 void ExecuteBackendOperation(); | 118 void ExecuteBackendOperation(); |
119 void ExecuteEntryOperation(); | 119 void ExecuteEntryOperation(); |
120 | 120 |
(...skipping 21 matching lines...) Expand all Loading... |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(BackendIO); | 143 DISALLOW_COPY_AND_ASSIGN(BackendIO); |
144 }; | 144 }; |
145 | 145 |
146 // The specialized controller that keeps track of current operations. | 146 // The specialized controller that keeps track of current operations. |
147 class InFlightBackendIO : public InFlightIO { | 147 class InFlightBackendIO : public InFlightIO { |
148 public: | 148 public: |
149 InFlightBackendIO( | 149 InFlightBackendIO( |
150 BackendImpl* backend, | 150 BackendImpl* backend, |
151 const scoped_refptr<base::SingleThreadTaskRunner>& background_thread); | 151 const scoped_refptr<base::SingleThreadTaskRunner>& background_thread); |
152 virtual ~InFlightBackendIO(); | 152 ~InFlightBackendIO() override; |
153 | 153 |
154 // Proxied operations. | 154 // Proxied operations. |
155 void Init(const net::CompletionCallback& callback); | 155 void Init(const net::CompletionCallback& callback); |
156 void OpenEntry(const std::string& key, Entry** entry, | 156 void OpenEntry(const std::string& key, Entry** entry, |
157 const net::CompletionCallback& callback); | 157 const net::CompletionCallback& callback); |
158 void CreateEntry(const std::string& key, Entry** entry, | 158 void CreateEntry(const std::string& key, Entry** entry, |
159 const net::CompletionCallback& callback); | 159 const net::CompletionCallback& callback); |
160 void DoomEntry(const std::string& key, | 160 void DoomEntry(const std::string& key, |
161 const net::CompletionCallback& callback); | 161 const net::CompletionCallback& callback); |
162 void DoomAllEntries(const net::CompletionCallback& callback); | 162 void DoomAllEntries(const net::CompletionCallback& callback); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 197 } |
198 | 198 |
199 // Returns true if the current thread is the background thread. | 199 // Returns true if the current thread is the background thread. |
200 bool BackgroundIsCurrentThread() { | 200 bool BackgroundIsCurrentThread() { |
201 return background_thread_->RunsTasksOnCurrentThread(); | 201 return background_thread_->RunsTasksOnCurrentThread(); |
202 } | 202 } |
203 | 203 |
204 base::WeakPtr<InFlightBackendIO> GetWeakPtr(); | 204 base::WeakPtr<InFlightBackendIO> GetWeakPtr(); |
205 | 205 |
206 protected: | 206 protected: |
207 virtual void OnOperationComplete(BackgroundIO* operation, | 207 void OnOperationComplete(BackgroundIO* operation, bool cancel) override; |
208 bool cancel) override; | |
209 | 208 |
210 private: | 209 private: |
211 void PostOperation(BackendIO* operation); | 210 void PostOperation(BackendIO* operation); |
212 | 211 |
213 BackendImpl* backend_; | 212 BackendImpl* backend_; |
214 scoped_refptr<base::SingleThreadTaskRunner> background_thread_; | 213 scoped_refptr<base::SingleThreadTaskRunner> background_thread_; |
215 base::WeakPtrFactory<InFlightBackendIO> ptr_factory_; | 214 base::WeakPtrFactory<InFlightBackendIO> ptr_factory_; |
216 | 215 |
217 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); | 216 DISALLOW_COPY_AND_ASSIGN(InFlightBackendIO); |
218 }; | 217 }; |
219 | 218 |
220 } // namespace disk_cache | 219 } // namespace disk_cache |
221 | 220 |
222 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ | 221 #endif // NET_DISK_CACHE_BLOCKFILE_IN_FLIGHT_BACKEND_IO_H_ |
OLD | NEW |