| OLD | NEW |
| 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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 CompletionCallback* callback) = 0; | 89 CompletionCallback* callback) = 0; |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // A default backend factory for the common use cases. | 92 // A default backend factory for the common use cases. |
| 93 class DefaultBackend : public BackendFactory { | 93 class DefaultBackend : public BackendFactory { |
| 94 public: | 94 public: |
| 95 // |path| is the destination for any files used by the backend, and | 95 // |path| is the destination for any files used by the backend, and |
| 96 // |cache_thread| is the thread where disk operations should take place. If | 96 // |cache_thread| is the thread where disk operations should take place. If |
| 97 // |max_bytes| is zero, a default value will be calculated automatically. | 97 // |max_bytes| is zero, a default value will be calculated automatically. |
| 98 DefaultBackend(CacheType type, const FilePath& path, int max_bytes, | 98 DefaultBackend(CacheType type, const FilePath& path, int max_bytes, |
| 99 base::MessageLoopProxy* thread) | 99 base::MessageLoopProxy* thread); |
| 100 : type_(type), path_(path), max_bytes_(max_bytes), thread_(thread) {} | 100 virtual ~DefaultBackend(); |
| 101 | 101 |
| 102 // Returns a factory for an in-memory cache. | 102 // Returns a factory for an in-memory cache. |
| 103 static BackendFactory* InMemory(int max_bytes) { | 103 static BackendFactory* InMemory(int max_bytes); |
| 104 return new DefaultBackend(MEMORY_CACHE, FilePath(), max_bytes, NULL); | |
| 105 } | |
| 106 | 104 |
| 107 // BackendFactory implementation. | 105 // BackendFactory implementation. |
| 108 virtual int CreateBackend(disk_cache::Backend** backend, | 106 virtual int CreateBackend(disk_cache::Backend** backend, |
| 109 CompletionCallback* callback); | 107 CompletionCallback* callback); |
| 110 | 108 |
| 111 private: | 109 private: |
| 112 CacheType type_; | 110 CacheType type_; |
| 113 const FilePath path_; | 111 const FilePath path_; |
| 114 int max_bytes_; | 112 int max_bytes_; |
| 115 scoped_refptr<base::MessageLoopProxy> thread_; | 113 scoped_refptr<base::MessageLoopProxy> thread_; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 369 |
| 372 typedef base::hash_map<std::string, int> PlaybackCacheMap; | 370 typedef base::hash_map<std::string, int> PlaybackCacheMap; |
| 373 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 371 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 374 | 372 |
| 375 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 373 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 376 }; | 374 }; |
| 377 | 375 |
| 378 } // namespace net | 376 } // namespace net |
| 379 | 377 |
| 380 #endif // NET_HTTP_HTTP_CACHE_H_ | 378 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |