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

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

Issue 12192005: Add new simple disk cache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to felipeg review 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_ENTRY_IMPL_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
7
8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "net/disk_cache/disk_cache.h"
13
14 namespace net {
15 class IOBuffer;
16 }
17
18 namespace disk_cache {
19
20 class SimpleSynchronousEntry;
21
22 // SimpleEntryImpl is the IO thread interface to an entry in the very simple
23 // disk cache. It proxies for the SimpleSynchronousEntry, which performs IO
24 // on the worker thread.
25 class SimpleEntryImpl : public Entry {
26 public:
27 static int OpenEntry(const base::FilePath& path,
28 const std::string& key,
29 Entry** entry,
30 const CompletionCallback& callback);
31
32 static int CreateEntry(const base::FilePath& path,
33 const std::string& key,
34 Entry** entry,
35 const CompletionCallback& callback);
36
37 static int DoomEntry(const base::FilePath& path,
38 const std::string& key,
39 const CompletionCallback& callback);
40
41 // From Entry:
42 virtual void Doom() OVERRIDE;
43 virtual void Close() OVERRIDE;
44 virtual std::string GetKey() const OVERRIDE;
45 virtual base::Time GetLastUsed() const OVERRIDE;
46 virtual base::Time GetLastModified() const OVERRIDE;
47 virtual int32 GetDataSize(int index) const OVERRIDE;
48 virtual int ReadData(int index,
49 int offset,
50 net::IOBuffer* buf,
51 int buf_len,
52 const CompletionCallback& callback) OVERRIDE;
53 virtual int WriteData(int index,
54 int offset,
55 net::IOBuffer* buf,
56 int buf_len,
57 const CompletionCallback& callback,
58 bool truncate) OVERRIDE;
59 virtual int ReadSparseData(int64 offset,
60 net::IOBuffer* buf,
61 int buf_len,
62 const CompletionCallback& callback) OVERRIDE;
63 virtual int WriteSparseData(int64 offset,
64 net::IOBuffer* buf,
65 int buf_len,
66 const CompletionCallback& callback) OVERRIDE;
67 virtual int GetAvailableRange(int64 offset,
68 int len,
69 int64* start,
70 const CompletionCallback& callback) OVERRIDE;
71 virtual bool CouldBeSparse() const OVERRIDE;
72 virtual void CancelSparseIO() OVERRIDE;
73 virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE;
74
75 private:
76 explicit SimpleEntryImpl(SimpleSynchronousEntry* synchronous_entry);
77
78 virtual ~SimpleEntryImpl();
79
80 // Called after a SimpleSynchronousEntry has completed CreateEntry() or
81 // OpenEntry(). Constructs the new SimpleEntryImpl (if |result| is net::OK)
82 // and passes it back to the caller via |out_entry|. Also runs
83 // |completion_callback|.
84 static void CreationOperationComplete(
85 const CompletionCallback& completion_callback,
86 Entry** out_entry,
87 SimpleSynchronousEntry* sync_entry,
88 int result);
89
90 // Called after a SimpleSynchronousEntry has completed an asynchronous IO
91 // operation, such as ReadData() or WriteData(). Calls |completion_callback|.
92 static void EntryOperationComplete(
93 const CompletionCallback& completion_callback,
94 base::WeakPtr<SimpleEntryImpl> entry,
95 SimpleSynchronousEntry* sync_entry,
96 int result);
97
98 base::ThreadChecker thread_checker_;
rvargas (doing something else) 2013/02/13 01:48:46 Doesn't the class description makes it explicit th
gavinp 2013/02/14 15:29:55 Done.
99 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_;
100 std::string key_;
101
102 // The |synchronous_entry_| is the worker thread object that performs IO on
103 // entries.
104 SimpleSynchronousEntry* synchronous_entry_;
105
106 // Set to true when a worker operation is posted on the |synchronous_entry_|,
107 // and false after. Used to insure thread safety by not allowing multiple
108 // threads to access the |synchronous_entry_| simultaniously.
rvargas (doing something else) 2013/02/13 01:48:46 typo: simultaneously
gavinp 2013/02/14 15:29:55 Done.
109 bool synchronous_entry_in_use_by_worker_;
110
111 bool has_been_doomed_;
112 };
113
114 } // namespace disk_cache
115
116 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698