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 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" |
11 #include "base/task.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "net/base/completion_callback.h" | 13 #include "net/base/completion_callback.h" |
14 #include "net/http/http_response_info.h" | 14 #include "net/http/http_response_info.h" |
15 #include "webkit/appcache/appcache_interfaces.h" | 15 #include "webkit/appcache/appcache_interfaces.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class IOBuffer; | 18 class IOBuffer; |
19 } | 19 } |
20 | 20 |
21 namespace appcache { | 21 namespace appcache { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 friend class ScopedRunnableMethodFactory<AppCacheResponseIO>; | |
104 | |
105 template <class T> | 103 template <class T> |
106 class EntryCallback : public net::CancelableOldCompletionCallback<T> { | 104 class EntryCallback : public net::CancelableOldCompletionCallback<T> { |
107 public: | 105 public: |
108 typedef net::CancelableOldCompletionCallback<T> BaseClass; | 106 typedef net::CancelableOldCompletionCallback<T> BaseClass; |
109 EntryCallback(T* object, void (T::* method)(int)) | 107 EntryCallback(T* object, void (T::* method)(int)) |
110 : BaseClass(object, method), entry_ptr_(NULL) {} | 108 : BaseClass(object, method), entry_ptr_(NULL) {} |
111 | 109 |
112 AppCacheDiskCacheInterface::Entry* entry_ptr_; // Accessed directly. | 110 AppCacheDiskCacheInterface::Entry* entry_ptr_; // Accessed directly. |
113 private: | 111 private: |
114 ~EntryCallback() { | 112 ~EntryCallback() { |
(...skipping 15 matching lines...) Expand all Loading... |
130 void WriteRaw(int index, int offset, net::IOBuffer* buf, int buf_len); | 128 void WriteRaw(int index, int offset, net::IOBuffer* buf, int buf_len); |
131 | 129 |
132 const int64 response_id_; | 130 const int64 response_id_; |
133 const int64 group_id_; | 131 const int64 group_id_; |
134 AppCacheDiskCacheInterface* disk_cache_; | 132 AppCacheDiskCacheInterface* disk_cache_; |
135 AppCacheDiskCacheInterface::Entry* entry_; | 133 AppCacheDiskCacheInterface::Entry* entry_; |
136 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; | 134 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; |
137 scoped_refptr<net::IOBuffer> buffer_; | 135 scoped_refptr<net::IOBuffer> buffer_; |
138 int buffer_len_; | 136 int buffer_len_; |
139 net::OldCompletionCallback* user_callback_; | 137 net::OldCompletionCallback* user_callback_; |
140 ScopedRunnableMethodFactory<AppCacheResponseIO> method_factory_; | 138 base::WeakPtrFactory<AppCacheResponseIO> weak_factory_; |
141 | 139 |
142 private: | 140 private: |
143 void OnRawIOComplete(int result); | 141 void OnRawIOComplete(int result); |
144 | 142 |
145 scoped_refptr<net::CancelableOldCompletionCallback<AppCacheResponseIO> > | 143 scoped_refptr<net::CancelableOldCompletionCallback<AppCacheResponseIO> > |
146 raw_callback_; | 144 raw_callback_; |
147 }; | 145 }; |
148 | 146 |
149 // Reads existing response data from storage. If the object is deleted | 147 // Reads existing response data from storage. If the object is deleted |
150 // and there is a read in progress, the implementation will return | 148 // and there is a read in progress, the implementation will return |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 int write_position_; | 266 int write_position_; |
269 int write_amount_; | 267 int write_amount_; |
270 CreationPhase creation_phase_; | 268 CreationPhase creation_phase_; |
271 scoped_refptr<EntryCallback<AppCacheResponseWriter> > create_callback_; | 269 scoped_refptr<EntryCallback<AppCacheResponseWriter> > create_callback_; |
272 }; | 270 }; |
273 | 271 |
274 } // namespace appcache | 272 } // namespace appcache |
275 | 273 |
276 #endif // WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_ | 274 #endif // WEBKIT_APPCACHE_APPCACHE_RESPONSE_H_ |
277 | 275 |
OLD | NEW |