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

Side by Side Diff: net/http/http_cache_transaction.h

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 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
« no previous file with comments | « net/http/http_basic_stream.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file declares HttpCache::Transaction, a private class of HttpCache so 5 // This file declares HttpCache::Transaction, a private class of HttpCache so
6 // it should only be included by http_cache.cc 6 // it should only be included by http_cache.cc
7 7
8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_ 8 #ifndef NET_HTTP_HTTP_CACHE_TRANSACTION_H_
9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_ 9 #define NET_HTTP_HTTP_CACHE_TRANSACTION_H_
10 #pragma once 10 #pragma once
(...skipping 10 matching lines...) Expand all
21 namespace net { 21 namespace net {
22 22
23 class HttpResponseHeaders; 23 class HttpResponseHeaders;
24 class PartialData; 24 class PartialData;
25 struct HttpRequestInfo; 25 struct HttpRequestInfo;
26 26
27 // This is the transaction that is returned by the HttpCache transaction 27 // This is the transaction that is returned by the HttpCache transaction
28 // factory. 28 // factory.
29 class HttpCache::Transaction : public HttpTransaction { 29 class HttpCache::Transaction : public HttpTransaction {
30 public: 30 public:
31 Transaction(HttpCache* cache);
32 virtual ~Transaction();
33
34 // HttpTransaction methods:
35 virtual int Start(const HttpRequestInfo*, CompletionCallback*,
36 const BoundNetLog&);
37 virtual int RestartIgnoringLastError(CompletionCallback* callback);
38 virtual int RestartWithCertificate(X509Certificate* client_cert,
39 CompletionCallback* callback);
40 virtual int RestartWithAuth(const string16& username,
41 const string16& password,
42 CompletionCallback* callback);
43 virtual bool IsReadyToRestartForAuth();
44 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
45 virtual void StopCaching();
46 virtual const HttpResponseInfo* GetResponseInfo() const;
47 virtual LoadState GetLoadState() const;
48 virtual uint64 GetUploadProgress(void) const;
49
50 // The transaction has the following modes, which apply to how it may access 31 // The transaction has the following modes, which apply to how it may access
51 // its cache entry. 32 // its cache entry.
52 // 33 //
53 // o If the mode of the transaction is NONE, then it is in "pass through" 34 // o If the mode of the transaction is NONE, then it is in "pass through"
54 // mode and all methods just forward to the inner network transaction. 35 // mode and all methods just forward to the inner network transaction.
55 // 36 //
56 // o If the mode of the transaction is only READ, then it may only read from 37 // o If the mode of the transaction is only READ, then it may only read from
57 // the cache entry. 38 // the cache entry.
58 // 39 //
59 // o If the mode of the transaction is only WRITE, then it may only write to 40 // o If the mode of the transaction is only WRITE, then it may only write to
60 // the cache entry. 41 // the cache entry.
61 // 42 //
62 // o If the mode of the transaction is READ_WRITE, then the transaction may 43 // o If the mode of the transaction is READ_WRITE, then the transaction may
63 // optionally modify the cache entry (e.g., possibly corresponding to 44 // optionally modify the cache entry (e.g., possibly corresponding to
64 // cache validation). 45 // cache validation).
65 // 46 //
66 // o If the mode of the transaction is UPDATE, then the transaction may 47 // o If the mode of the transaction is UPDATE, then the transaction may
67 // update existing cache entries, but will never create a new entry or 48 // update existing cache entries, but will never create a new entry or
68 // respond using the entry read from the cache. 49 // respond using the entry read from the cache.
69 enum Mode { 50 enum Mode {
70 NONE = 0, 51 NONE = 0,
71 READ_META = 1 << 0, 52 READ_META = 1 << 0,
72 READ_DATA = 1 << 1, 53 READ_DATA = 1 << 1,
73 READ = READ_META | READ_DATA, 54 READ = READ_META | READ_DATA,
74 WRITE = 1 << 2, 55 WRITE = 1 << 2,
75 READ_WRITE = READ | WRITE, 56 READ_WRITE = READ | WRITE,
76 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA 57 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA
77 }; 58 };
78 59
60 Transaction(HttpCache* cache);
61 virtual ~Transaction();
62
79 Mode mode() const { return mode_; } 63 Mode mode() const { return mode_; }
80 64
81 const std::string& key() const { return cache_key_; } 65 const std::string& key() const { return cache_key_; }
82 66
83 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the 67 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the
84 // HTTP cache entry that backs this transaction (if any). 68 // HTTP cache entry that backs this transaction (if any).
85 // Returns the number of bytes actually written, or a net error code. If the 69 // Returns the number of bytes actually written, or a net error code. If the
86 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a 70 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a
87 // reference to the buffer (until completion), and notifies the caller using 71 // reference to the buffer (until completion), and notifies the caller using
88 // the provided |callback| when the operatiopn finishes. 72 // the provided |callback| when the operatiopn finishes.
(...skipping 16 matching lines...) Expand all
105 // Returns the LoadState of the writer transaction of a given ActiveEntry. In 89 // Returns the LoadState of the writer transaction of a given ActiveEntry. In
106 // other words, returns the LoadState of this transaction without asking the 90 // other words, returns the LoadState of this transaction without asking the
107 // http cache, because this transaction should be the one currently writing 91 // http cache, because this transaction should be the one currently writing
108 // to the cache entry. 92 // to the cache entry.
109 LoadState GetWriterLoadState() const; 93 LoadState GetWriterLoadState() const;
110 94
111 CompletionCallback* io_callback() { return &io_callback_; } 95 CompletionCallback* io_callback() { return &io_callback_; }
112 96
113 const BoundNetLog& net_log() const; 97 const BoundNetLog& net_log() const;
114 98
99 // HttpTransaction methods:
100 virtual int Start(const HttpRequestInfo*, CompletionCallback*,
101 const BoundNetLog&);
102 virtual int RestartIgnoringLastError(CompletionCallback* callback);
103 virtual int RestartWithCertificate(X509Certificate* client_cert,
104 CompletionCallback* callback);
105 virtual int RestartWithAuth(const string16& username,
106 const string16& password,
107 CompletionCallback* callback);
108 virtual bool IsReadyToRestartForAuth();
109 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
110 virtual void StopCaching();
111 virtual const HttpResponseInfo* GetResponseInfo() const;
112 virtual LoadState GetLoadState() const;
113 virtual uint64 GetUploadProgress(void) const;
114
115 private: 115 private:
116 static const size_t kNumValidationHeaders = 2; 116 static const size_t kNumValidationHeaders = 2;
117 // Helper struct to pair a header name with its value, for 117 // Helper struct to pair a header name with its value, for
118 // headers used to validate cache entries. 118 // headers used to validate cache entries.
119 struct ValidationHeaders { 119 struct ValidationHeaders {
120 ValidationHeaders() : initialized(false) {} 120 ValidationHeaders() : initialized(false) {}
121 121
122 std::string values[kNumValidationHeaders]; 122 std::string values[kNumValidationHeaders];
123 bool initialized; 123 bool initialized;
124 }; 124 };
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 uint64 final_upload_progress_; 351 uint64 final_upload_progress_;
352 CompletionCallbackImpl<Transaction> io_callback_; 352 CompletionCallbackImpl<Transaction> io_callback_;
353 scoped_refptr<CancelableCompletionCallback<Transaction> > cache_callback_; 353 scoped_refptr<CancelableCompletionCallback<Transaction> > cache_callback_;
354 scoped_refptr<CancelableCompletionCallback<Transaction> > 354 scoped_refptr<CancelableCompletionCallback<Transaction> >
355 write_headers_callback_; 355 write_headers_callback_;
356 }; 356 };
357 357
358 } // namespace net 358 } // namespace net
359 359
360 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ 360 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_
OLDNEW
« no previous file with comments | « net/http/http_basic_stream.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698