| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // Helper function for reading response info from the disk cache. | 100 // Helper function for reading response info from the disk cache. |
| 101 static bool ReadResponseInfo(disk_cache::Entry* disk_entry, | 101 static bool ReadResponseInfo(disk_cache::Entry* disk_entry, |
| 102 HttpResponseInfo* response_info); | 102 HttpResponseInfo* response_info); |
| 103 | 103 |
| 104 // Helper function for writing response info into the disk cache. | 104 // Helper function for writing response info into the disk cache. |
| 105 static bool WriteResponseInfo(disk_cache::Entry* disk_entry, | 105 static bool WriteResponseInfo(disk_cache::Entry* disk_entry, |
| 106 const HttpResponseInfo* response_info, | 106 const HttpResponseInfo* response_info, |
| 107 bool skip_transient_headers); | 107 bool skip_transient_headers); |
| 108 | 108 |
| 109 // Generate a key that can be used inside the cache. | |
| 110 std::string GenerateCacheKey(const HttpRequestInfo* request); | |
| 111 | |
| 112 // Get/Set the cache's mode. | 109 // Get/Set the cache's mode. |
| 113 void set_mode(Mode value) { mode_ = value; } | 110 void set_mode(Mode value) { mode_ = value; } |
| 114 Mode mode() { return mode_; } | 111 Mode mode() { return mode_; } |
| 115 | 112 |
| 116 void set_type(Type type) { type_ = type; } | 113 void set_type(Type type) { type_ = type; } |
| 117 Type type() { return type_; } | 114 Type type() { return type_; } |
| 118 | 115 |
| 119 private: | 116 private: |
| 120 | 117 |
| 121 // Types -------------------------------------------------------------------- | 118 // Types -------------------------------------------------------------------- |
| (...skipping 14 matching lines...) Expand all Loading... |
| 136 explicit ActiveEntry(disk_cache::Entry*); | 133 explicit ActiveEntry(disk_cache::Entry*); |
| 137 ~ActiveEntry(); | 134 ~ActiveEntry(); |
| 138 }; | 135 }; |
| 139 | 136 |
| 140 typedef base::hash_map<std::string, ActiveEntry*> ActiveEntriesMap; | 137 typedef base::hash_map<std::string, ActiveEntry*> ActiveEntriesMap; |
| 141 typedef std::set<ActiveEntry*> ActiveEntriesSet; | 138 typedef std::set<ActiveEntry*> ActiveEntriesSet; |
| 142 | 139 |
| 143 | 140 |
| 144 // Methods ------------------------------------------------------------------ | 141 // Methods ------------------------------------------------------------------ |
| 145 | 142 |
| 143 std::string GenerateCacheKey(const HttpRequestInfo*); |
| 146 void DoomEntry(const std::string& key); | 144 void DoomEntry(const std::string& key); |
| 147 void FinalizeDoomedEntry(ActiveEntry* entry); | 145 void FinalizeDoomedEntry(ActiveEntry* entry); |
| 148 ActiveEntry* FindActiveEntry(const std::string& key); | 146 ActiveEntry* FindActiveEntry(const std::string& key); |
| 149 ActiveEntry* ActivateEntry(const std::string& key, disk_cache::Entry*); | 147 ActiveEntry* ActivateEntry(const std::string& key, disk_cache::Entry*); |
| 150 void DeactivateEntry(ActiveEntry* entry); | 148 void DeactivateEntry(ActiveEntry* entry); |
| 151 ActiveEntry* OpenEntry(const std::string& key); | 149 ActiveEntry* OpenEntry(const std::string& key); |
| 152 ActiveEntry* CreateEntry(const std::string& cache_key); | 150 ActiveEntry* CreateEntry(const std::string& cache_key); |
| 153 void DestroyEntry(ActiveEntry* entry); | 151 void DestroyEntry(ActiveEntry* entry); |
| 154 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); | 152 int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans); |
| 155 void DoneWithEntry(ActiveEntry* entry, Transaction* trans); | 153 void DoneWithEntry(ActiveEntry* entry, Transaction* trans); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 189 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 192 | 190 |
| 193 RevocableStore transactions_; | 191 RevocableStore transactions_; |
| 194 | 192 |
| 195 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 193 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 196 }; | 194 }; |
| 197 | 195 |
| 198 } // namespace net | 196 } // namespace net |
| 199 | 197 |
| 200 #endif // NET_HTTP_HTTP_CACHE_H_ | 198 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |