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

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: rebase before remediation Created 7 years, 10 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
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/file_path.h"
14 #include "base/task_runner.h"
15 #include "base/threading/thread_checker.h"
16 #include "net/base/cache_type.h"
17 #include "net/disk_cache/disk_cache.h"
18
19 namespace disk_cache {
20
21 // SimpleBackendImpl is a new cache backend that stores entries in individual
22 // files.
23
24 // It is currently a work in progress, missing many features of a real cache,
25 // such as eviction.
26
27 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend
28
29 class SimpleBackendImpl : public Backend {
30 public:
31 virtual ~SimpleBackendImpl();
32
33 static int CreateBackend(const base::FilePath& full_path,
34 bool force,
35 int max_bytes,
36 net::CacheType type,
37 uint32 flags,
38 scoped_refptr<base::TaskRunner> thread,
39 net::NetLog* net_log,
40 Backend** backend,
41 const CompletionCallback& callback);
42
43 // From Backend:
44 virtual net::CacheType GetCacheType() const OVERRIDE;
45 virtual int32 GetEntryCount() const OVERRIDE;
46 virtual int OpenEntry(const std::string& key, Entry** entry,
47 const CompletionCallback& callback) OVERRIDE;
48 virtual int CreateEntry(const std::string& key, Entry** entry,
49 const CompletionCallback& callback) OVERRIDE;
50 virtual int DoomEntry(const std::string& key,
51 const CompletionCallback& callback) OVERRIDE;
52 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE;
53 virtual int DoomEntriesBetween(base::Time initial_time,
54 base::Time end_time,
55 const CompletionCallback& callback) OVERRIDE;
56 virtual int DoomEntriesSince(base::Time initial_time,
57 const CompletionCallback& callback) OVERRIDE;
58 virtual int OpenNextEntry(void** iter, Entry** next_entry,
59 const CompletionCallback& callback) OVERRIDE;
60 virtual void EndEnumeration(void** iter) OVERRIDE;
61 virtual void GetStats(
62 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
63 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
64
65 private:
66 explicit SimpleBackendImpl(const base::FilePath& path);
67
68 static void EnsureCachePathExistsOnWorkerThread(
69 const base::FilePath& path,
70 const scoped_refptr<base::TaskRunner>& callback_runner,
71 const CompletionCallback& callback,
72 Backend** backend);
73
74 static void OnCachePathCreated(int result,
75 const base::FilePath& path,
76 const CompletionCallback& callback,
77 Backend** backend);
78
79 base::ThreadChecker thread_checker_;
80 const base::FilePath path_;
81 };
82
83 } // namespace disk_cache
84
85 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698