| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 a HttpTransactionFactory implementation that can be | 5 // This file declares a HttpTransactionFactory implementation that can be |
| 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The | 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The |
| 7 // caching logic follows RFC 2616 (any exceptions are called out in the code). | 7 // caching logic follows RFC 2616 (any exceptions are called out in the code). |
| 8 // | 8 // |
| 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for | 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for |
| 10 // the cache storage. | 10 // the cache storage. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 disk_cache::Backend* disk_cache); | 90 disk_cache::Backend* disk_cache); |
| 91 | 91 |
| 92 HttpTransactionFactory* network_layer() { return network_layer_.get(); } | 92 HttpTransactionFactory* network_layer() { return network_layer_.get(); } |
| 93 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } | 93 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } |
| 94 | 94 |
| 95 // HttpTransactionFactory implementation: | 95 // HttpTransactionFactory implementation: |
| 96 virtual HttpTransaction* CreateTransaction(); | 96 virtual HttpTransaction* CreateTransaction(); |
| 97 virtual HttpCache* GetCache(); | 97 virtual HttpCache* GetCache(); |
| 98 virtual void Suspend(bool suspend); | 98 virtual void Suspend(bool suspend); |
| 99 | 99 |
| 100 // Helper function for reading response info from the disk cache. | 100 // Helper function for reading response info from the disk cache. If the |
| 101 // cache doesn't have the whole resource *|request_truncated| is set to true. |
| 101 static bool ReadResponseInfo(disk_cache::Entry* disk_entry, | 102 static bool ReadResponseInfo(disk_cache::Entry* disk_entry, |
| 102 HttpResponseInfo* response_info); | 103 HttpResponseInfo* response_info, |
| 104 bool* response_truncated); |
| 103 | 105 |
| 104 // Helper function for writing response info into the disk cache. | 106 // Helper function for writing response info into the disk cache. If the |
| 107 // cache doesn't have the whole resource |request_truncated| should be true. |
| 105 static bool WriteResponseInfo(disk_cache::Entry* disk_entry, | 108 static bool WriteResponseInfo(disk_cache::Entry* disk_entry, |
| 106 const HttpResponseInfo* response_info, | 109 const HttpResponseInfo* response_info, |
| 107 bool skip_transient_headers); | 110 bool skip_transient_headers, |
| 111 bool response_truncated); |
| 108 | 112 |
| 109 // Given a header data blob, convert it to a response info object. | 113 // Given a header data blob, convert it to a response info object. |
| 110 static bool ParseResponseInfo(const char* data, int len, | 114 static bool ParseResponseInfo(const char* data, int len, |
| 111 HttpResponseInfo* response_info); | 115 HttpResponseInfo* response_info, |
| 116 bool* response_truncated); |
| 112 | 117 |
| 113 // Get/Set the cache's mode. | 118 // Get/Set the cache's mode. |
| 114 void set_mode(Mode value) { mode_ = value; } | 119 void set_mode(Mode value) { mode_ = value; } |
| 115 Mode mode() { return mode_; } | 120 Mode mode() { return mode_; } |
| 116 | 121 |
| 117 void set_type(CacheType type) { type_ = type; } | 122 void set_type(CacheType type) { type_ = type; } |
| 118 CacheType type() { return type_; } | 123 CacheType type() { return type_; } |
| 119 | 124 |
| 120 // Close All Idle Sockets. This is for debugging. | 125 // Close All Idle Sockets. This is for debugging. |
| 121 void CloseIdleConnections(); | 126 void CloseIdleConnections(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void DoomEntry(const std::string& key); | 160 void DoomEntry(const std::string& key); |
| 156 void FinalizeDoomedEntry(ActiveEntry* entry); | 161 void FinalizeDoomedEntry(ActiveEntry* entry); |
| 157 ActiveEntry* FindActiveEntry(const std::string& key); | 162 ActiveEntry* FindActiveEntry(const std::string& key); |
| 158 ActiveEntry* ActivateEntry(const std::string& key, disk_cache::Entry*); | 163 ActiveEntry* ActivateEntry(const std::string& key, disk_cache::Entry*); |
| 159 void DeactivateEntry(ActiveEntry* entry); | 164 void DeactivateEntry(ActiveEntry* entry); |
| 160 void SlowDeactivateEntry(ActiveEntry* entry); | 165 void SlowDeactivateEntry(ActiveEntry* entry); |
| 161 ActiveEntry* OpenEntry(const std::string& key); | 166 ActiveEntry* OpenEntry(const std::string& key); |
| 162 ActiveEntry* CreateEntry(const std::string& cache_key); | 167 ActiveEntry* CreateEntry(const std::string& cache_key); |
| 163 void DestroyEntry(ActiveEntry* entry); | 168 void DestroyEntry(ActiveEntry* entry); |
| 164 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); | 169 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); |
| 165 void DoneWithEntry(ActiveEntry* entry, Transaction* trans); | 170 void DoneWithEntry(ActiveEntry* entry, Transaction* trans, bool cancel); |
| 166 void DoneWritingToEntry(ActiveEntry* entry, bool success); | 171 void DoneWritingToEntry(ActiveEntry* entry, bool success); |
| 167 void DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans); | 172 void DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans); |
| 168 void ConvertWriterToReader(ActiveEntry* entry); | 173 void ConvertWriterToReader(ActiveEntry* entry); |
| 169 void RemovePendingTransaction(Transaction* trans); | 174 void RemovePendingTransaction(Transaction* trans); |
| 170 void ProcessPendingQueue(ActiveEntry* entry); | 175 void ProcessPendingQueue(ActiveEntry* entry); |
| 171 | 176 |
| 172 | 177 |
| 173 // Events (called via PostTask) --------------------------------------------- | 178 // Events (called via PostTask) --------------------------------------------- |
| 174 | 179 |
| 175 void OnProcessPendingQueue(ActiveEntry* entry); | 180 void OnProcessPendingQueue(ActiveEntry* entry); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 202 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 207 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 203 | 208 |
| 204 RevocableStore transactions_; | 209 RevocableStore transactions_; |
| 205 | 210 |
| 206 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 211 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 207 }; | 212 }; |
| 208 | 213 |
| 209 } // namespace net | 214 } // namespace net |
| 210 | 215 |
| 211 #endif // NET_HTTP_HTTP_CACHE_H_ | 216 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |