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

Side by Side Diff: content/browser/appcache/appcache_response.h

Issue 1499423004: Remove kint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint9
Patch Set: rebase Created 5 years 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
OLDNEW
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 CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
7 7
8 #include <stdint.h>
9
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "content/common/appcache_interfaces.h" 14 #include "content/common/appcache_interfaces.h"
13 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
14 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
15 #include "net/http/http_response_info.h" 17 #include "net/http/http_response_info.h"
16 #include "url/gurl.h" 18 #include "url/gurl.h"
17 19
18 namespace net { 20 namespace net {
19 class IOBuffer; 21 class IOBuffer;
20 } 22 }
21 23
22 namespace content { 24 namespace content {
23 class AppCacheStorage; 25 class AppCacheStorage;
24 class MockAppCacheStorage; 26 class MockAppCacheStorage;
25 27
26 static const int kUnkownResponseDataSize = -1; 28 static const int kUnkownResponseDataSize = -1;
27 29
28 // Response info for a particular response id. Instances are tracked in 30 // Response info for a particular response id. Instances are tracked in
29 // the working set. 31 // the working set.
30 class CONTENT_EXPORT AppCacheResponseInfo 32 class CONTENT_EXPORT AppCacheResponseInfo
31 : public base::RefCounted<AppCacheResponseInfo> { 33 : public base::RefCounted<AppCacheResponseInfo> {
32 public: 34 public:
33 // AppCacheResponseInfo takes ownership of the http_info. 35 // AppCacheResponseInfo takes ownership of the http_info.
34 AppCacheResponseInfo(AppCacheStorage* storage, const GURL& manifest_url, 36 AppCacheResponseInfo(AppCacheStorage* storage,
35 int64 response_id, net::HttpResponseInfo* http_info, 37 const GURL& manifest_url,
36 int64 response_data_size); 38 int64_t response_id,
39 net::HttpResponseInfo* http_info,
40 int64_t response_data_size);
37 41
38 const GURL& manifest_url() const { return manifest_url_; } 42 const GURL& manifest_url() const { return manifest_url_; }
39 int64 response_id() const { return response_id_; } 43 int64_t response_id() const { return response_id_; }
40 const net::HttpResponseInfo* http_response_info() const { 44 const net::HttpResponseInfo* http_response_info() const {
41 return http_response_info_.get(); 45 return http_response_info_.get();
42 } 46 }
43 int64 response_data_size() const { return response_data_size_; } 47 int64_t response_data_size() const { return response_data_size_; }
44 48
45 private: 49 private:
46 friend class base::RefCounted<AppCacheResponseInfo>; 50 friend class base::RefCounted<AppCacheResponseInfo>;
47 virtual ~AppCacheResponseInfo(); 51 virtual ~AppCacheResponseInfo();
48 52
49 const GURL manifest_url_; 53 const GURL manifest_url_;
50 const int64 response_id_; 54 const int64_t response_id_;
51 const scoped_ptr<net::HttpResponseInfo> http_response_info_; 55 const scoped_ptr<net::HttpResponseInfo> http_response_info_;
52 const int64 response_data_size_; 56 const int64_t response_data_size_;
53 AppCacheStorage* storage_; 57 AppCacheStorage* storage_;
54 }; 58 };
55 59
56 // A refcounted wrapper for HttpResponseInfo so we can apply the 60 // A refcounted wrapper for HttpResponseInfo so we can apply the
57 // refcounting semantics used with IOBuffer with these structures too. 61 // refcounting semantics used with IOBuffer with these structures too.
58 struct CONTENT_EXPORT HttpResponseInfoIOBuffer 62 struct CONTENT_EXPORT HttpResponseInfoIOBuffer
59 : public base::RefCountedThreadSafe<HttpResponseInfoIOBuffer> { 63 : public base::RefCountedThreadSafe<HttpResponseInfoIOBuffer> {
60 scoped_ptr<net::HttpResponseInfo> http_info; 64 scoped_ptr<net::HttpResponseInfo> http_info;
61 int response_data_size; 65 int response_data_size;
62 66
63 HttpResponseInfoIOBuffer(); 67 HttpResponseInfoIOBuffer();
64 explicit HttpResponseInfoIOBuffer(net::HttpResponseInfo* info); 68 explicit HttpResponseInfoIOBuffer(net::HttpResponseInfo* info);
65 69
66 protected: 70 protected:
67 friend class base::RefCountedThreadSafe<HttpResponseInfoIOBuffer>; 71 friend class base::RefCountedThreadSafe<HttpResponseInfoIOBuffer>;
68 virtual ~HttpResponseInfoIOBuffer(); 72 virtual ~HttpResponseInfoIOBuffer();
69 }; 73 };
70 74
71 // Low level storage API used by the response reader and writer. 75 // Low level storage API used by the response reader and writer.
72 class CONTENT_EXPORT AppCacheDiskCacheInterface { 76 class CONTENT_EXPORT AppCacheDiskCacheInterface {
73 public: 77 public:
74 class Entry { 78 class Entry {
75 public: 79 public:
76 virtual int Read(int index, int64 offset, net::IOBuffer* buf, int buf_len, 80 virtual int Read(int index,
81 int64_t offset,
82 net::IOBuffer* buf,
83 int buf_len,
77 const net::CompletionCallback& callback) = 0; 84 const net::CompletionCallback& callback) = 0;
78 virtual int Write(int index, int64 offset, net::IOBuffer* buf, int buf_len, 85 virtual int Write(int index,
86 int64_t offset,
87 net::IOBuffer* buf,
88 int buf_len,
79 const net::CompletionCallback& callback) = 0; 89 const net::CompletionCallback& callback) = 0;
80 virtual int64 GetSize(int index) = 0; 90 virtual int64_t GetSize(int index) = 0;
81 virtual void Close() = 0; 91 virtual void Close() = 0;
82 protected: 92 protected:
83 virtual ~Entry() {} 93 virtual ~Entry() {}
84 }; 94 };
85 95
86 virtual int CreateEntry(int64 key, Entry** entry, 96 virtual int CreateEntry(int64_t key,
97 Entry** entry,
87 const net::CompletionCallback& callback) = 0; 98 const net::CompletionCallback& callback) = 0;
88 virtual int OpenEntry(int64 key, Entry** entry, 99 virtual int OpenEntry(int64_t key,
100 Entry** entry,
89 const net::CompletionCallback& callback) = 0; 101 const net::CompletionCallback& callback) = 0;
90 virtual int DoomEntry(int64 key, const net::CompletionCallback& callback) = 0; 102 virtual int DoomEntry(int64_t key,
103 const net::CompletionCallback& callback) = 0;
91 104
92 protected: 105 protected:
93 friend class base::RefCounted<AppCacheDiskCacheInterface>; 106 friend class base::RefCounted<AppCacheDiskCacheInterface>;
94 virtual ~AppCacheDiskCacheInterface() {} 107 virtual ~AppCacheDiskCacheInterface() {}
95 }; 108 };
96 109
97 // Common base class for response reader and writer. 110 // Common base class for response reader and writer.
98 class CONTENT_EXPORT AppCacheResponseIO { 111 class CONTENT_EXPORT AppCacheResponseIO {
99 public: 112 public:
100 virtual ~AppCacheResponseIO(); 113 virtual ~AppCacheResponseIO();
101 int64 response_id() const { return response_id_; } 114 int64_t response_id() const { return response_id_; }
102 115
103 protected: 116 protected:
104 AppCacheResponseIO(int64 response_id, 117 AppCacheResponseIO(int64_t response_id,
105 int64 group_id, 118 int64_t group_id,
106 AppCacheDiskCacheInterface* disk_cache); 119 AppCacheDiskCacheInterface* disk_cache);
107 120
108 virtual void OnIOComplete(int result) = 0; 121 virtual void OnIOComplete(int result) = 0;
109 virtual void OnOpenEntryComplete() {} 122 virtual void OnOpenEntryComplete() {}
110 123
111 bool IsIOPending() { return !callback_.is_null(); } 124 bool IsIOPending() { return !callback_.is_null(); }
112 void ScheduleIOCompletionCallback(int result); 125 void ScheduleIOCompletionCallback(int result);
113 void InvokeUserCompletionCallback(int result); 126 void InvokeUserCompletionCallback(int result);
114 void ReadRaw(int index, int offset, net::IOBuffer* buf, int buf_len); 127 void ReadRaw(int index, int offset, net::IOBuffer* buf, int buf_len);
115 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);
116 void OpenEntryIfNeeded(); 129 void OpenEntryIfNeeded();
117 130
118 const int64 response_id_; 131 const int64_t response_id_;
119 const int64 group_id_; 132 const int64_t group_id_;
120 AppCacheDiskCacheInterface* disk_cache_; 133 AppCacheDiskCacheInterface* disk_cache_;
121 AppCacheDiskCacheInterface::Entry* entry_; 134 AppCacheDiskCacheInterface::Entry* entry_;
122 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; 135 scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_;
123 scoped_refptr<net::IOBuffer> buffer_; 136 scoped_refptr<net::IOBuffer> buffer_;
124 int buffer_len_; 137 int buffer_len_;
125 net::CompletionCallback callback_; 138 net::CompletionCallback callback_;
126 net::CompletionCallback open_callback_; 139 net::CompletionCallback open_callback_;
127 base::WeakPtrFactory<AppCacheResponseIO> weak_factory_; 140 base::WeakPtrFactory<AppCacheResponseIO> weak_factory_;
128 141
129 private: 142 private:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Used to support range requests. If not called, the reader will 183 // Used to support range requests. If not called, the reader will
171 // read the entire response body. If called, this must be called prior 184 // read the entire response body. If called, this must be called prior
172 // to the first call to the ReadData method. 185 // to the first call to the ReadData method.
173 void SetReadRange(int offset, int length); 186 void SetReadRange(int offset, int length);
174 187
175 protected: 188 protected:
176 friend class AppCacheStorageImpl; 189 friend class AppCacheStorageImpl;
177 friend class content::MockAppCacheStorage; 190 friend class content::MockAppCacheStorage;
178 191
179 // Should only be constructed by the storage class and derivatives. 192 // Should only be constructed by the storage class and derivatives.
180 AppCacheResponseReader(int64 response_id, 193 AppCacheResponseReader(int64_t response_id,
181 int64 group_id, 194 int64_t group_id,
182 AppCacheDiskCacheInterface* disk_cache); 195 AppCacheDiskCacheInterface* disk_cache);
183 196
184 void OnIOComplete(int result) override; 197 void OnIOComplete(int result) override;
185 void OnOpenEntryComplete() override; 198 void OnOpenEntryComplete() override;
186 void ContinueReadInfo(); 199 void ContinueReadInfo();
187 void ContinueReadData(); 200 void ContinueReadData();
188 201
189 int range_offset_; 202 int range_offset_;
190 int range_length_; 203 int range_length_;
191 int read_position_; 204 int read_position_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Should only be called where there is no Write operation in progress. 236 // Should only be called where there is no Write operation in progress.
224 // (virtual for testing) 237 // (virtual for testing)
225 virtual void WriteData(net::IOBuffer* buf, 238 virtual void WriteData(net::IOBuffer* buf,
226 int buf_len, 239 int buf_len,
227 const net::CompletionCallback& callback); 240 const net::CompletionCallback& callback);
228 241
229 // Returns true if there is a write pending. 242 // Returns true if there is a write pending.
230 bool IsWritePending() { return IsIOPending(); } 243 bool IsWritePending() { return IsIOPending(); }
231 244
232 // Returns the amount written, info and data. 245 // Returns the amount written, info and data.
233 int64 amount_written() { return info_size_ + write_position_; } 246 int64_t amount_written() { return info_size_ + write_position_; }
234 247
235 protected: 248 protected:
236 // Should only be constructed by the storage class and derivatives. 249 // Should only be constructed by the storage class and derivatives.
237 AppCacheResponseWriter(int64 response_id, 250 AppCacheResponseWriter(int64_t response_id,
238 int64 group_id, 251 int64_t group_id,
239 AppCacheDiskCacheInterface* disk_cache); 252 AppCacheDiskCacheInterface* disk_cache);
240 253
241 private: 254 private:
242 friend class AppCacheStorageImpl; 255 friend class AppCacheStorageImpl;
243 friend class content::MockAppCacheStorage; 256 friend class content::MockAppCacheStorage;
244 257
245 enum CreationPhase { 258 enum CreationPhase {
246 NO_ATTEMPT, 259 NO_ATTEMPT,
247 INITIAL_ATTEMPT, 260 INITIAL_ATTEMPT,
248 DOOM_EXISTING, 261 DOOM_EXISTING,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 int buf_len, 298 int buf_len,
286 const net::CompletionCallback& callback); 299 const net::CompletionCallback& callback);
287 300
288 // Returns true if there is a write pending. 301 // Returns true if there is a write pending.
289 bool IsWritePending() { return IsIOPending(); } 302 bool IsWritePending() { return IsIOPending(); }
290 303
291 protected: 304 protected:
292 friend class AppCacheStorageImpl; 305 friend class AppCacheStorageImpl;
293 friend class content::MockAppCacheStorage; 306 friend class content::MockAppCacheStorage;
294 // Should only be constructed by the storage class and derivatives. 307 // Should only be constructed by the storage class and derivatives.
295 AppCacheResponseMetadataWriter(int64 response_id, 308 AppCacheResponseMetadataWriter(int64_t response_id,
296 int64 group_id, 309 int64_t group_id,
297 AppCacheDiskCacheInterface* disk_cache); 310 AppCacheDiskCacheInterface* disk_cache);
298 311
299 private: 312 private:
300 void OnIOComplete(int result) override; 313 void OnIOComplete(int result) override;
301 void OnOpenEntryComplete() override; 314 void OnOpenEntryComplete() override;
302 315
303 int write_amount_; 316 int write_amount_;
304 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_; 317 base::WeakPtrFactory<AppCacheResponseMetadataWriter> weak_factory_;
305 }; 318 };
306 319
307 } // namespace content 320 } // namespace content
308 321
309 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_ 322 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_RESPONSE_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_disk_cache.cc ('k') | content/browser/appcache/appcache_response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698