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

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: build fix 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
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | net/disk_cache/simple/simple_entry_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_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 "net/disk_cache/disk_cache.h"
12
13 namespace net {
14 class IOBuffer;
15 }
16
17 namespace disk_cache {
18
19 class SimpleSynchronousEntry;
20
21 // SimpleEntryImpl is the IO thread interface to an entry in the very simple
22 // disk cache. It proxies for the SimpleSynchronousEntry, which performs IO
23 // on the worker thread.
24 class SimpleEntryImpl : public Entry {
25 public:
26 static int OpenEntry(const base::FilePath& path,
27 const std::string& key,
28 Entry** entry,
29 const CompletionCallback& callback);
30
31 static int CreateEntry(const base::FilePath& path,
32 const std::string& key,
33 Entry** entry,
34 const CompletionCallback& callback);
35
36 static int DoomEntry(const base::FilePath& path,
37 const std::string& key,
38 const CompletionCallback& callback);
39
40 // From Entry:
41 virtual void Doom() OVERRIDE;
42 virtual void Close() OVERRIDE;
43 virtual std::string GetKey() const OVERRIDE;
44 virtual base::Time GetLastUsed() const OVERRIDE;
45 virtual base::Time GetLastModified() const OVERRIDE;
46 virtual int32 GetDataSize(int index) const OVERRIDE;
47 virtual int ReadData(int index,
48 int offset,
49 net::IOBuffer* buf,
50 int buf_len,
51 const CompletionCallback& callback) OVERRIDE;
52 virtual int WriteData(int index,
53 int offset,
54 net::IOBuffer* buf,
55 int buf_len,
56 const CompletionCallback& callback,
57 bool truncate) OVERRIDE;
58 virtual int ReadSparseData(int64 offset,
59 net::IOBuffer* buf,
60 int buf_len,
61 const CompletionCallback& callback) OVERRIDE;
62 virtual int WriteSparseData(int64 offset,
63 net::IOBuffer* buf,
64 int buf_len,
65 const CompletionCallback& callback) OVERRIDE;
66 virtual int GetAvailableRange(int64 offset,
67 int len,
68 int64* start,
69 const CompletionCallback& callback) OVERRIDE;
70 virtual bool CouldBeSparse() const OVERRIDE;
71 virtual void CancelSparseIO() OVERRIDE;
72 virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE;
73
74 private:
75 explicit SimpleEntryImpl(SimpleSynchronousEntry* synchronous_entry);
76
77 virtual ~SimpleEntryImpl();
78
79 // Called after a SimpleSynchronousEntry has completed CreateEntry() or
80 // OpenEntry(). Constructs the new SimpleEntryImpl (if |result| is net::OK)
81 // and passes it back to the caller via |out_entry|. Also runs
82 // |completion_callback|.
83 static void CreationOperationComplete(
84 const CompletionCallback& completion_callback,
85 Entry** out_entry,
86 SimpleSynchronousEntry* sync_entry);
87
88 // Called after a SimpleSynchronousEntry has completed an asynchronous IO
89 // operation, such as ReadData() or WriteData(). Calls |completion_callback|.
90 static void EntryOperationComplete(
91 const CompletionCallback& completion_callback,
92 base::WeakPtr<SimpleEntryImpl> entry,
93 int result);
94
95 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_;
96 std::string key_;
97
98 // The |synchronous_entry_| is the worker thread object that performs IO on
99 // entries.
100 SimpleSynchronousEntry* synchronous_entry_;
101
102 // Set to true when a worker operation is posted on the |synchronous_entry_|,
103 // and false after. Used to insure thread safety by not allowing multiple
104 // threads to access the |synchronous_entry_| simultaneously.
105 bool synchronous_entry_in_use_by_worker_;
106
107 bool has_been_doomed_;
108 };
109
110 } // namespace disk_cache
111
112 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698