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

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

Issue 14022012: Code quality and standards in SimpleBackend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remediate 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>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
15 #include "base/task_runner.h" 16 #include "base/task_runner.h"
16 #include "net/base/cache_type.h" 17 #include "net/base/cache_type.h"
17 #include "net/disk_cache/disk_cache.h" 18 #include "net/disk_cache/disk_cache.h"
18 #include "net/disk_cache/simple/simple_index.h"
19 19
20 namespace base { 20 namespace base {
21 class MessageLoopProxy; 21 class SingleThreadTaskRunner;
22 } 22 }
23 23
24 namespace disk_cache { 24 namespace disk_cache {
25 25
26 // SimpleBackendImpl is a new cache backend that stores entries in individual 26 // SimpleBackendImpl is a new cache backend that stores entries in individual
27 // files. 27 // files.
28 28
29 // It is currently a work in progress, missing many features of a real cache, 29 // It is currently a work in progress, missing many features of a real cache,
30 // such as eviction. 30 // such as eviction.
31 31
32 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend 32 // See http://www.chromium.org/developers/design-documents/network-stack/disk-ca che/very-simple-backend
33 33
34 class SimpleIndex;
35
34 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend { 36 class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend {
35 public: 37 public:
36 SimpleBackendImpl(const base::FilePath& path, int max_bytes, 38 SimpleBackendImpl(const base::FilePath& path, int max_bytes,
37 net::CacheType type, 39 net::CacheType type,
38 const scoped_refptr<base::TaskRunner>& cache_thread, 40 base::SingleThreadTaskRunner* cache_thread,
39 net::NetLog* net_log); 41 net::NetLog* net_log);
40 42
41 virtual ~SimpleBackendImpl(); 43 virtual ~SimpleBackendImpl();
42 44
43 // Must run on IO Thread. 45 // Must run on IO Thread.
44 int Init(const CompletionCallback& completion_callback); 46 int Init(const CompletionCallback& completion_callback);
45 47
46 // From Backend: 48 // From Backend:
47 virtual net::CacheType GetCacheType() const OVERRIDE; 49 virtual net::CacheType GetCacheType() const OVERRIDE;
48 virtual int32 GetEntryCount() const OVERRIDE; 50 virtual int32 GetEntryCount() const OVERRIDE;
(...skipping 18 matching lines...) Expand all
67 69
68 private: 70 private:
69 typedef base::Callback<void(int result)> InitializeIndexCallback; 71 typedef base::Callback<void(int result)> InitializeIndexCallback;
70 72
71 // Must run on IO Thread. 73 // Must run on IO Thread.
72 void InitializeIndex(const CompletionCallback& callback, int result); 74 void InitializeIndex(const CompletionCallback& callback, int result);
73 75
74 // Try to create the directory if it doesn't exist. 76 // Try to create the directory if it doesn't exist.
75 // Must run on Cache Thread. 77 // Must run on Cache Thread.
76 static void CreateDirectory( 78 static void CreateDirectory(
77 base::MessageLoopProxy* io_thread, 79 base::SingleThreadTaskRunner* io_thread,
78 const base::FilePath& path, 80 const base::FilePath& path,
79 const InitializeIndexCallback& initialize_index_callback); 81 const InitializeIndexCallback& initialize_index_callback);
80 82
81 const base::FilePath path_; 83 const base::FilePath path_;
82 scoped_refptr<SimpleIndex> index_; 84 scoped_ptr<SimpleIndex> index_;
83 const scoped_refptr<base::TaskRunner> cache_thread_; 85 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_;
84 }; 86 };
85 87
86 } // namespace disk_cache 88 } // namespace disk_cache
87 89
88 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 90 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_backend_impl.cc » ('j') | net/disk_cache/simple/simple_entry_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698