Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: webkit/appcache/appcache_response.h

Issue 9064007: base::Bind: Remove OldCompletionCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_ 5 #ifndef WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_
6 #define WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_ 6 #define WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 virtual ~AppCacheDiskCacheInterface() {} 93 virtual ~AppCacheDiskCacheInterface() {}
94 }; 94 };
95 95
96 // Common base class for response reader and writer. 96 // Common base class for response reader and writer.
97 class APPCACHE_EXPORT AppCacheResponseIO { 97 class APPCACHE_EXPORT AppCacheResponseIO {
98 public: 98 public:
99 virtual ~AppCacheResponseIO(); 99 virtual ~AppCacheResponseIO();
100 int64 response_id() const { return response_id_; } 100 int64 response_id() const { return response_id_; }
101 101
102 protected: 102 protected:
103 template <class T>
104 class EntryCallback : public net::CancelableOldCompletionCallback<T> {
105 public:
106 typedef net::CancelableOldCompletionCallback<T> BaseClass;
107 EntryCallback(T* object, void (T::* method)(int))
108 : BaseClass(object, method), entry_ptr_(NULL) {}
109
110 AppCacheDiskCacheInterface::Entry* entry_ptr_; // Accessed directly.
111 private:
112 ~EntryCallback() {
113 if (entry_ptr_)
114 entry_ptr_->Close();
115 }
116 };
117
118 AppCacheResponseIO(int64 response_id, 103 AppCacheResponseIO(int64 response_id,
119 int64 group_id, 104 int64 group_id,
120 AppCacheDiskCacheInterface* disk_cache); 105 AppCacheDiskCacheInterface* disk_cache);
121 106
122 virtual void OnIOComplete(int result) = 0; 107 virtual void OnIOComplete(int result) = 0;
123 108
124 bool IsIOPending() { return !callback_.is_null(); } 109 bool IsIOPending() { return !callback_.is_null(); }
125 void ScheduleIOCompletionCallback(int result); 110 void ScheduleIOCompletionCallback(int result);
126 void InvokeUserCompletionCallback(int result); 111 void InvokeUserCompletionCallback(int result);
127 void ReadRaw(int index, int offset, net::IOBuffer* buf, int buf_len); 112 void ReadRaw(int index, int offset, net::IOBuffer* buf, int buf_len);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 172
188 // Should only be constructed by the storage class. 173 // Should only be constructed by the storage class.
189 AppCacheResponseReader(int64 response_id, 174 AppCacheResponseReader(int64 response_id,
190 int64 group_id, 175 int64 group_id,
191 AppCacheDiskCacheInterface* disk_cache); 176 AppCacheDiskCacheInterface* disk_cache);
192 177
193 virtual void OnIOComplete(int result) OVERRIDE; 178 virtual void OnIOComplete(int result) OVERRIDE;
194 void ContinueReadInfo(); 179 void ContinueReadInfo();
195 void ContinueReadData(); 180 void ContinueReadData();
196 void OpenEntryIfNeededAndContinue(); 181 void OpenEntryIfNeededAndContinue();
197 void OnOpenEntryComplete(int rv); 182 void OnOpenEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv);
198 183
199 int range_offset_; 184 int range_offset_;
200 int range_length_; 185 int range_length_;
201 int read_position_; 186 int read_position_;
202 scoped_refptr<EntryCallback<AppCacheResponseReader> > open_callback_; 187 net::CompletionCallback open_callback_;
188 base::WeakPtrFactory<AppCacheResponseReader> weak_factory_;
203 }; 189 };
204 190
205 // Writes new response data to storage. If the object is deleted 191 // Writes new response data to storage. If the object is deleted
206 // and there is a write in progress, the implementation will return 192 // and there is a write in progress, the implementation will return
207 // immediately but will take care of any side effect of cancelling the 193 // immediately but will take care of any side effect of cancelling the
208 // operation. In other words, instances are safe to delete at will. 194 // operation. In other words, instances are safe to delete at will.
209 class APPCACHE_EXPORT AppCacheResponseWriter : public AppCacheResponseIO { 195 class APPCACHE_EXPORT AppCacheResponseWriter : public AppCacheResponseIO {
210 public: 196 public:
211 virtual ~AppCacheResponseWriter(); 197 virtual ~AppCacheResponseWriter();
212 198
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 236
251 // Should only be constructed by the storage class. 237 // Should only be constructed by the storage class.
252 AppCacheResponseWriter(int64 response_id, 238 AppCacheResponseWriter(int64 response_id,
253 int64 group_id, 239 int64 group_id,
254 AppCacheDiskCacheInterface* disk_cache); 240 AppCacheDiskCacheInterface* disk_cache);
255 241
256 virtual void OnIOComplete(int result) OVERRIDE; 242 virtual void OnIOComplete(int result) OVERRIDE;
257 void ContinueWriteInfo(); 243 void ContinueWriteInfo();
258 void ContinueWriteData(); 244 void ContinueWriteData();
259 void CreateEntryIfNeededAndContinue(); 245 void CreateEntryIfNeededAndContinue();
260 void OnCreateEntryComplete(int rv); 246 void OnCreateEntryComplete(AppCacheDiskCacheInterface::Entry** entry, int rv);
261 247
262 int info_size_; 248 int info_size_;
263 int write_position_; 249 int write_position_;
264 int write_amount_; 250 int write_amount_;
265 CreationPhase creation_phase_; 251 CreationPhase creation_phase_;
266 scoped_refptr<EntryCallback<AppCacheResponseWriter> > create_callback_; 252 net::CompletionCallback create_callback_;
253 base::WeakPtrFactory<AppCacheResponseWriter> weak_factory_;
267 }; 254 };
268 255
269 } // namespace appcache 256 } // namespace appcache
270 257
271 #endif // WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_ 258 #endif // WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_
272 259
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698