OLD | NEW |
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_ENTRY_IMPL_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/files/file_path.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "net/disk_cache/disk_cache.h" | 12 #include "net/disk_cache/disk_cache.h" |
| 13 #include "net/disk_cache/simple/simple_disk_format.h" |
12 | 14 |
13 namespace net { | 15 namespace net { |
14 class IOBuffer; | 16 class IOBuffer; |
15 } | 17 } |
16 | 18 |
17 namespace disk_cache { | 19 namespace disk_cache { |
18 | 20 |
19 class SimpleSynchronousEntry; | 21 class SimpleSynchronousEntry; |
20 | 22 |
21 // SimpleEntryImpl is the IO thread interface to an entry in the very simple | 23 // SimpleEntryImpl is the IO thread interface to an entry in the very simple |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Entry** out_entry, | 87 Entry** out_entry, |
86 SimpleSynchronousEntry* sync_entry); | 88 SimpleSynchronousEntry* sync_entry); |
87 | 89 |
88 // Called after a SimpleSynchronousEntry has completed an asynchronous IO | 90 // Called after a SimpleSynchronousEntry has completed an asynchronous IO |
89 // operation, such as ReadData() or WriteData(). Calls |completion_callback|. | 91 // operation, such as ReadData() or WriteData(). Calls |completion_callback|. |
90 static void EntryOperationComplete( | 92 static void EntryOperationComplete( |
91 const CompletionCallback& completion_callback, | 93 const CompletionCallback& completion_callback, |
92 base::WeakPtr<SimpleEntryImpl> entry, | 94 base::WeakPtr<SimpleEntryImpl> entry, |
93 int result); | 95 int result); |
94 | 96 |
| 97 // Called on construction and also after the completion of asynchronous IO to |
| 98 // initialize the IO thread copies of data returned by synchronous accessor |
| 99 // functions. Copies data from |synchronous_entry_| into |this|, so that |
| 100 // values can be returned during our next IO operation. |
| 101 void SetSynchronousData(); |
| 102 |
95 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_; | 103 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_; |
96 std::string key_; | 104 |
| 105 // |path_| and |key_| are copied from the synchronous entry on construction, |
| 106 // and never updated as they are const. |
| 107 const base::FilePath path_; |
| 108 const std::string key_; |
| 109 |
| 110 // |last_used_|, |last_modified_| and |data_size_| are copied from the |
| 111 // synchronous entry at the completion of each item of asynchronous IO. |
| 112 base::Time last_used_; |
| 113 base::Time last_modified_; |
| 114 int32 data_size_[kSimpleEntryFileCount]; |
97 | 115 |
98 // The |synchronous_entry_| is the worker thread object that performs IO on | 116 // The |synchronous_entry_| is the worker thread object that performs IO on |
99 // entries. | 117 // entries. |
100 SimpleSynchronousEntry* synchronous_entry_; | 118 SimpleSynchronousEntry* synchronous_entry_; |
101 | 119 |
102 // Set to true when a worker operation is posted on the |synchronous_entry_|, | 120 // 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 | 121 // and false after. Used to insure thread safety by not allowing multiple |
104 // threads to access the |synchronous_entry_| simultaneously. | 122 // threads to access the |synchronous_entry_| simultaneously. |
105 bool synchronous_entry_in_use_by_worker_; | 123 bool synchronous_entry_in_use_by_worker_; |
106 | 124 |
107 bool has_been_doomed_; | 125 bool has_been_doomed_; |
108 }; | 126 }; |
109 | 127 |
110 } // namespace disk_cache | 128 } // namespace disk_cache |
111 | 129 |
112 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ | 130 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ |
OLD | NEW |