OLD | NEW |
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 // 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 7234 (any exceptions are called out in the code). | 7 // caching logic follows RFC 7234 (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. |
11 // | 11 // |
12 // See HttpTransactionFactory and HttpTransaction for more details. | 12 // See HttpTransactionFactory and HttpTransaction for more details. |
13 | 13 |
14 #ifndef NET_HTTP_HTTP_CACHE_H_ | 14 #ifndef NET_HTTP_HTTP_CACHE_H_ |
15 #define NET_HTTP_HTTP_CACHE_H_ | 15 #define NET_HTTP_HTTP_CACHE_H_ |
16 | 16 |
17 #include <list> | 17 #include <list> |
18 #include <memory> | 18 #include <memory> |
19 #include <set> | 19 #include <set> |
20 #include <string> | 20 #include <string> |
| 21 #include <unordered_map> |
21 | 22 |
22 #include "base/containers/hash_tables.h" | |
23 #include "base/files/file_path.h" | 23 #include "base/files/file_path.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" |
26 #include "base/threading/non_thread_safe.h" | 26 #include "base/threading/non_thread_safe.h" |
27 #include "base/time/clock.h" | 27 #include "base/time/clock.h" |
28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
29 #include "net/base/cache_type.h" | 29 #include "net/base/cache_type.h" |
30 #include "net/base/completion_callback.h" | 30 #include "net/base/completion_callback.h" |
31 #include "net/base/load_states.h" | 31 #include "net/base/load_states.h" |
32 #include "net/base/net_export.h" | 32 #include "net/base/net_export.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 ~ActiveEntry(); | 254 ~ActiveEntry(); |
255 | 255 |
256 disk_cache::Entry* disk_entry; | 256 disk_cache::Entry* disk_entry; |
257 Transaction* writer; | 257 Transaction* writer; |
258 TransactionList readers; | 258 TransactionList readers; |
259 TransactionList pending_queue; | 259 TransactionList pending_queue; |
260 bool will_process_pending_queue; | 260 bool will_process_pending_queue; |
261 bool doomed; | 261 bool doomed; |
262 }; | 262 }; |
263 | 263 |
264 typedef base::hash_map<std::string, ActiveEntry*> ActiveEntriesMap; | 264 using ActiveEntriesMap = std::unordered_map<std::string, ActiveEntry*>; |
265 typedef base::hash_map<std::string, PendingOp*> PendingOpsMap; | 265 using PendingOpsMap = std::unordered_map<std::string, PendingOp*>; |
266 typedef std::set<ActiveEntry*> ActiveEntriesSet; | 266 using ActiveEntriesSet = std::set<ActiveEntry*>; |
267 typedef base::hash_map<std::string, int> PlaybackCacheMap; | 267 using PlaybackCacheMap = std::unordered_map<std::string, int>; |
268 | 268 |
269 // Methods ------------------------------------------------------------------ | 269 // Methods ------------------------------------------------------------------ |
270 | 270 |
271 // Creates the |backend| object and notifies the |callback| when the operation | 271 // Creates the |backend| object and notifies the |callback| when the operation |
272 // completes. Returns an error code. | 272 // completes. Returns an error code. |
273 int CreateBackend(disk_cache::Backend** backend, | 273 int CreateBackend(disk_cache::Backend** backend, |
274 const CompletionCallback& callback); | 274 const CompletionCallback& callback); |
275 | 275 |
276 // Makes sure that the backend creation is complete before allowing the | 276 // Makes sure that the backend creation is complete before allowing the |
277 // provided transaction to use the object. Returns an error code. |trans| | 277 // provided transaction to use the object. Returns an error code. |trans| |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 std::unique_ptr<base::Clock> clock_; | 431 std::unique_ptr<base::Clock> clock_; |
432 | 432 |
433 base::WeakPtrFactory<HttpCache> weak_factory_; | 433 base::WeakPtrFactory<HttpCache> weak_factory_; |
434 | 434 |
435 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 435 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
436 }; | 436 }; |
437 | 437 |
438 } // namespace net | 438 } // namespace net |
439 | 439 |
440 #endif // NET_HTTP_HTTP_CACHE_H_ | 440 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |