Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Side by Side Diff: net/disk_cache/mem_backend_impl.h

Issue 2739007: Disk cache: Update the disk cache tools and tests to use... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/disk_cache_test_util.cc ('k') | net/disk_cache/mem_backend_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // See net/disk_cache/disk_cache.h for the public interface of the cache. 5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
6 6
7 #ifndef NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 7 #ifndef NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
8 #define NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 8 #define NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 11
12 #include "net/disk_cache/disk_cache.h" 12 #include "net/disk_cache/disk_cache.h"
13 #include "net/disk_cache/mem_rankings.h" 13 #include "net/disk_cache/mem_rankings.h"
14 14
15 namespace disk_cache { 15 namespace disk_cache {
16 16
17 class MemEntryImpl; 17 class MemEntryImpl;
18 18
19 // This class implements the Backend interface. An object of this class handles 19 // This class implements the Backend interface. An object of this class handles
20 // the operations of the cache without writing to disk. 20 // the operations of the cache without writing to disk.
21 class MemBackendImpl : public Backend { 21 class MemBackendImpl : public Backend {
22 public: 22 public:
23 MemBackendImpl() : max_size_(0), current_size_(0) {} 23 MemBackendImpl() : max_size_(0), current_size_(0) {}
24 ~MemBackendImpl(); 24 ~MemBackendImpl();
25 25
26 // Returns an instance of a Backend implemented only in memory. The returned
27 // object should be deleted when not needed anymore. max_bytes is the maximum
28 // size the cache can grow to. If zero is passed in as max_bytes, the cache
29 // will determine the value to use based on the available memory. The returned
30 // pointer can be NULL if a fatal error is found.
31 static Backend* CreateBackend(int max_bytes);
32
26 // Performs general initialization for this current instance of the cache. 33 // Performs general initialization for this current instance of the cache.
27 bool Init(); 34 bool Init();
28 35
29 // Backend interface. 36 // Backend interface.
30 virtual int32 GetEntryCount() const; 37 virtual int32 GetEntryCount() const;
31 virtual bool OpenEntry(const std::string& key, Entry** entry); 38 virtual bool OpenEntry(const std::string& key, Entry** entry);
32 virtual int OpenEntry(const std::string& key, Entry** entry, 39 virtual int OpenEntry(const std::string& key, Entry** entry,
33 CompletionCallback* callback); 40 CompletionCallback* callback);
34 virtual bool CreateEntry(const std::string& key, Entry** entry); 41 virtual bool CreateEntry(const std::string& key, Entry** entry);
35 virtual int CreateEntry(const std::string& key, Entry** entry, 42 virtual int CreateEntry(const std::string& key, Entry** entry,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 MemRankings rankings_; // Rankings to be able to trim the cache. 100 MemRankings rankings_; // Rankings to be able to trim the cache.
94 int32 max_size_; // Maximum data size for this instance. 101 int32 max_size_; // Maximum data size for this instance.
95 int32 current_size_; 102 int32 current_size_;
96 103
97 DISALLOW_COPY_AND_ASSIGN(MemBackendImpl); 104 DISALLOW_COPY_AND_ASSIGN(MemBackendImpl);
98 }; 105 };
99 106
100 } // namespace disk_cache 107 } // namespace disk_cache
101 108
102 #endif // NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 109 #endif // NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_util.cc ('k') | net/disk_cache/mem_backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698