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 // 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 |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "net/base/net_log.h" | 15 #include "net/base/net_log.h" |
16 #include "net/http/http_cache.h" | 16 #include "net/http/http_cache.h" |
17 #include "net/http/http_response_info.h" | 17 #include "net/http/http_response_info.h" |
18 #include "net/http/http_request_headers.h" | 18 #include "net/http/http_request_headers.h" |
19 #include "net/http/http_transaction.h" | 19 #include "net/http/http_transaction.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class HttpResponseHeaders; | |
24 class PartialData; | 23 class PartialData; |
25 struct HttpRequestInfo; | 24 struct HttpRequestInfo; |
26 | 25 |
27 // This is the transaction that is returned by the HttpCache transaction | 26 // This is the transaction that is returned by the HttpCache transaction |
28 // factory. | 27 // factory. |
29 class HttpCache::Transaction : public HttpTransaction { | 28 class HttpCache::Transaction : public HttpTransaction { |
30 public: | 29 public: |
31 // The transaction has the following modes, which apply to how it may access | 30 // The transaction has the following modes, which apply to how it may access |
32 // its cache entry. | 31 // its cache entry. |
33 // | 32 // |
(...skipping 16 matching lines...) Expand all Loading... |
50 enum Mode { | 49 enum Mode { |
51 NONE = 0, | 50 NONE = 0, |
52 READ_META = 1 << 0, | 51 READ_META = 1 << 0, |
53 READ_DATA = 1 << 1, | 52 READ_DATA = 1 << 1, |
54 READ = READ_META | READ_DATA, | 53 READ = READ_META | READ_DATA, |
55 WRITE = 1 << 2, | 54 WRITE = 1 << 2, |
56 READ_WRITE = READ | WRITE, | 55 READ_WRITE = READ | WRITE, |
57 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA | 56 UPDATE = READ_META | WRITE, // READ_WRITE & ~READ_DATA |
58 }; | 57 }; |
59 | 58 |
60 Transaction(HttpCache* cache); | 59 explicit Transaction(HttpCache* cache); |
61 virtual ~Transaction(); | 60 virtual ~Transaction(); |
62 | 61 |
63 Mode mode() const { return mode_; } | 62 Mode mode() const { return mode_; } |
64 | 63 |
65 const std::string& key() const { return cache_key_; } | 64 const std::string& key() const { return cache_key_; } |
66 | 65 |
67 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the | 66 // Writes |buf_len| bytes of meta-data from the provided buffer |buf|. to the |
68 // HTTP cache entry that backs this transaction (if any). | 67 // HTTP cache entry that backs this transaction (if any). |
69 // Returns the number of bytes actually written, or a net error code. If the | 68 // Returns the number of bytes actually written, or a net error code. If the |
70 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a | 69 // operation cannot complete immediately, returns ERR_IO_PENDING, grabs a |
71 // reference to the buffer (until completion), and notifies the caller using | 70 // reference to the buffer (until completion), and notifies the caller using |
72 // the provided |callback| when the operatiopn finishes. | 71 // the provided |callback| when the operatiopn finishes. |
73 // | 72 // |
74 // The first time this method is called for a given transaction, previous | 73 // The first time this method is called for a given transaction, previous |
75 // meta-data will be overwritten with the provided data, and subsequent | 74 // meta-data will be overwritten with the provided data, and subsequent |
76 // invocations will keep appending to the cached entry. | 75 // invocations will keep appending to the cached entry. |
77 // | 76 // |
78 // In order to guarantee that the metadata is set to the correct entry, the | 77 // In order to guarantee that the metadata is set to the correct entry, the |
79 // response (or response info) must be evaluated by the caller, for instance | 78 // response (or response info) must be evaluated by the caller, for instance |
80 // to make sure that the response_time is as expected, before calling this | 79 // to make sure that the response_time is as expected, before calling this |
81 // method. | 80 // method. |
82 int WriteMetadata(IOBuffer* buf, int buf_len, OldCompletionCallback* callback)
; | 81 int WriteMetadata(IOBuffer* buf, |
| 82 int buf_len, |
| 83 OldCompletionCallback* callback); |
83 | 84 |
84 // This transaction is being deleted and we are not done writing to the cache. | 85 // This transaction is being deleted and we are not done writing to the cache. |
85 // We need to indicate that the response data was truncated. Returns true on | 86 // We need to indicate that the response data was truncated. Returns true on |
86 // success. | 87 // success. |
87 bool AddTruncatedFlag(); | 88 bool AddTruncatedFlag(); |
88 | 89 |
89 // Returns the LoadState of the writer transaction of a given ActiveEntry. In | 90 // Returns the LoadState of the writer transaction of a given ActiveEntry. In |
90 // other words, returns the LoadState of this transaction without asking the | 91 // other words, returns the LoadState of this transaction without asking the |
91 // http cache, because this transaction should be the one currently writing | 92 // http cache, because this transaction should be the one currently writing |
92 // to the cache entry. | 93 // to the cache entry. |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 uint64 final_upload_progress_; | 359 uint64 final_upload_progress_; |
359 OldCompletionCallbackImpl<Transaction> io_callback_; | 360 OldCompletionCallbackImpl<Transaction> io_callback_; |
360 scoped_refptr<CancelableOldCompletionCallback<Transaction> > cache_callback_; | 361 scoped_refptr<CancelableOldCompletionCallback<Transaction> > cache_callback_; |
361 scoped_refptr<CancelableOldCompletionCallback<Transaction> > | 362 scoped_refptr<CancelableOldCompletionCallback<Transaction> > |
362 write_headers_callback_; | 363 write_headers_callback_; |
363 }; | 364 }; |
364 | 365 |
365 } // namespace net | 366 } // namespace net |
366 | 367 |
367 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ | 368 #endif // NET_HTTP_HTTP_CACHE_TRANSACTION_H_ |
OLD | NEW |