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

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

Issue 13813015: Separate Simple Backend creation from initialization. (Closed) Base URL: http://git.chromium.org/chromium/src.git@trace-2
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 22
23 // It is currently a work in progress, missing many features of a real cache, 23 // It is currently a work in progress, missing many features of a real cache,
24 // such as eviction. 24 // such as eviction.
25 25
26 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend 26 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend
27 27
28 class SimpleIndex; 28 class SimpleIndex;
29 29
30 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend { 30 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend {
31 public: 31 public:
32 virtual ~SimpleBackendImpl(); 32 SimpleBackendImpl(const base::FilePath& path, int max_bytes,
33 net::CacheType type,
34 const scoped_refptr<base::TaskRunner>& cache_thread,
35 net::NetLog* net_log);
33 36
34 static int CreateBackend(const base::FilePath& full_path, 37 int Init(const CompletionCallback& callback);
35 int max_bytes,
36 net::CacheType type,
37 uint32 flags,
38 scoped_refptr<base::TaskRunner> cache_thread,
39 net::NetLog* net_log,
40 Backend** backend,
41 const CompletionCallback& callback);
42 38
43 // From Backend: 39 // From Backend:
44 virtual net::CacheType GetCacheType() const OVERRIDE; 40 virtual net::CacheType GetCacheType() const OVERRIDE;
45 virtual int32 GetEntryCount() const OVERRIDE; 41 virtual int32 GetEntryCount() const OVERRIDE;
46 virtual int OpenEntry(const std::string& key, Entry** entry, 42 virtual int OpenEntry(const std::string& key, Entry** entry,
47 const CompletionCallback& callback) OVERRIDE; 43 const CompletionCallback& callback) OVERRIDE;
48 virtual int CreateEntry(const std::string& key, Entry** entry, 44 virtual int CreateEntry(const std::string& key, Entry** entry,
49 const CompletionCallback& callback) OVERRIDE; 45 const CompletionCallback& callback) OVERRIDE;
50 virtual int DoomEntry(const std::string& key, 46 virtual int DoomEntry(const std::string& key,
51 const CompletionCallback& callback) OVERRIDE; 47 const CompletionCallback& callback) OVERRIDE;
52 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE; 48 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE;
53 virtual int DoomEntriesBetween(base::Time initial_time, 49 virtual int DoomEntriesBetween(base::Time initial_time,
54 base::Time end_time, 50 base::Time end_time,
55 const CompletionCallback& callback) OVERRIDE; 51 const CompletionCallback& callback) OVERRIDE;
56 virtual int DoomEntriesSince(base::Time initial_time, 52 virtual int DoomEntriesSince(base::Time initial_time,
57 const CompletionCallback& callback) OVERRIDE; 53 const CompletionCallback& callback) OVERRIDE;
58 virtual int OpenNextEntry(void** iter, Entry** next_entry, 54 virtual int OpenNextEntry(void** iter, Entry** next_entry,
59 const CompletionCallback& callback) OVERRIDE; 55 const CompletionCallback& callback) OVERRIDE;
60 virtual void EndEnumeration(void** iter) OVERRIDE; 56 virtual void EndEnumeration(void** iter) OVERRIDE;
61 virtual void GetStats( 57 virtual void GetStats(
62 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; 58 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
63 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 59 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
64 60
65 private: 61 private:
66 SimpleBackendImpl( 62 virtual ~SimpleBackendImpl();
gavinp 2013/04/09 16:03:49 This is weird: why redeclare the destructor as pri
pasko-google - do not use 2013/04/09 16:20:48 Moved back.
67 const scoped_refptr<base::TaskRunner>& cache_thread,
68 const base::FilePath& path);
69
70 // Creates the Cache directory if needed. Performs blocking IO, so it cannot
71 // be called on IO thread.
72 static void EnsureCachePathExists(
73 const base::FilePath& path,
74 const scoped_refptr<base::TaskRunner>& cache_thread,
75 const scoped_refptr<base::TaskRunner>& io_thread,
76 const CompletionCallback& callback,
77 Backend** backend);
78 63
79 // Must run on Cache Thread. 64 // Must run on Cache Thread.
80 void Initialize(); 65 void InitializeIndex(base::MessageLoopProxy* io_thread,
66 const CompletionCallback& callback);
81 67
82 const base::FilePath path_; 68 const base::FilePath path_;
83 69
84 scoped_ptr<SimpleIndex> index_; 70 scoped_ptr<SimpleIndex> index_;
71 const scoped_refptr<base::TaskRunner> cache_thread_;
85 }; 72 };
86 73
87 } // namespace disk_cache 74 } // namespace disk_cache
88 75
89 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 76 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698