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

Side by Side Diff: net/disk_cache/simple/simple_backend_impl.h

Issue 12192005: Add new simple disk cache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 years, 9 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/backend_impl.cc ('k') | net/disk_cache/simple/simple_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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
7
8 #include <string>
9 #include <utility>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "base/task_runner.h"
15 #include "net/base/cache_type.h"
16 #include "net/disk_cache/disk_cache.h"
17
18 namespace disk_cache {
19
20 // SimpleBackendImpl is a new cache backend that stores entries in individual
21 // files.
22
23 // It is currently a work in progress, missing many features of a real cache,
24 // such as eviction.
25
26 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend
27
28 class SimpleBackendImpl : public Backend {
29 public:
30 virtual ~SimpleBackendImpl();
31
32 static int CreateBackend(const base::FilePath& full_path,
33 bool force,
34 int max_bytes,
35 net::CacheType type,
36 uint32 flags,
37 scoped_refptr<base::TaskRunner> thread,
38 net::NetLog* net_log,
39 Backend** backend,
40 const CompletionCallback& callback);
41
42 // From Backend:
43 virtual net::CacheType GetCacheType() const OVERRIDE;
44 virtual int32 GetEntryCount() const OVERRIDE;
45 virtual int OpenEntry(const std::string& key, Entry** entry,
46 const CompletionCallback& callback) OVERRIDE;
47 virtual int CreateEntry(const std::string& key, Entry** entry,
48 const CompletionCallback& callback) OVERRIDE;
49 virtual int DoomEntry(const std::string& key,
50 const CompletionCallback& callback) OVERRIDE;
51 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE;
52 virtual int DoomEntriesBetween(base::Time initial_time,
53 base::Time end_time,
54 const CompletionCallback& callback) OVERRIDE;
55 virtual int DoomEntriesSince(base::Time initial_time,
56 const CompletionCallback& callback) OVERRIDE;
57 virtual int OpenNextEntry(void** iter, Entry** next_entry,
58 const CompletionCallback& callback) OVERRIDE;
59 virtual void EndEnumeration(void** iter) OVERRIDE;
60 virtual void GetStats(
61 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
62 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
63
64 private:
65 explicit SimpleBackendImpl(const base::FilePath& path);
66
67 // Creates the Cache directory if needed. Performs blocking IO, so it cannot
68 // be called on IO thread.
69 static void EnsureCachePathExists(
70 const base::FilePath& path,
71 const scoped_refptr<base::TaskRunner>& callback_runner,
72 const CompletionCallback& callback,
73 Backend** backend);
74
75 // IO thread completion of cache creation, called from EnsureCachePath exists
76 // to complete initialization of the cache on the IO thread.
77 static void OnCachePathCreated(int result,
78 const base::FilePath& path,
79 const CompletionCallback& callback,
80 Backend** backend);
81
82 const base::FilePath path_;
83 };
84
85 } // namespace disk_cache
86
87 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | net/disk_cache/simple/simple_backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698