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

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

Issue 12277004: Make SimpleEntryImpl::Close asynchronous. (Closed) Base URL: http://git.chromium.org/git/chromium.git@3-doomdoom
Patch Set: remediation to randy's review Created 7 years, 9 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 | « no previous file | 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
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/files/file_path.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // OpenEntry(). Constructs the new SimpleEntryImpl (if |result| is net::OK) 82 // OpenEntry(). Constructs the new SimpleEntryImpl (if |result| is net::OK)
83 // and passes it back to the caller via |out_entry|. Also runs 83 // and passes it back to the caller via |out_entry|. Also runs
84 // |completion_callback|. 84 // |completion_callback|.
85 static void CreationOperationComplete( 85 static void CreationOperationComplete(
86 const CompletionCallback& completion_callback, 86 const CompletionCallback& completion_callback,
87 Entry** out_entry, 87 Entry** out_entry,
88 SimpleSynchronousEntry* sync_entry); 88 SimpleSynchronousEntry* sync_entry);
89 89
90 // Called after a SimpleSynchronousEntry has completed an asynchronous IO 90 // Called after a SimpleSynchronousEntry has completed an asynchronous IO
91 // operation, such as ReadData() or WriteData(). Calls |completion_callback|. 91 // operation, such as ReadData() or WriteData(). Calls |completion_callback|.
92 // If |entry| no longer exists, then it ensures |sync_entry| is closed.
92 static void EntryOperationComplete( 93 static void EntryOperationComplete(
93 const CompletionCallback& completion_callback, 94 const CompletionCallback& completion_callback,
94 base::WeakPtr<SimpleEntryImpl> entry, 95 base::WeakPtr<SimpleEntryImpl> entry,
96 SimpleSynchronousEntry* sync_entry,
95 int result); 97 int result);
96 98
97 // Called on construction and also after the completion of asynchronous IO to 99 // Called on construction and also after the completion of asynchronous IO to
98 // initialize the IO thread copies of data returned by synchronous accessor 100 // initialize the IO thread copies of data returned by synchronous accessor
99 // functions. Copies data from |synchronous_entry_| into |this|, so that 101 // functions. Copies data from |synchronous_entry_| into |this|, so that
100 // values can be returned during our next IO operation. 102 // values can be returned during our next IO operation.
101 void SetSynchronousData(); 103 void SetSynchronousData();
102 104
103 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_; 105 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_;
104 106
105 // |path_| and |key_| are copied from the synchronous entry on construction, 107 // |path_| and |key_| are copied from the synchronous entry on construction,
106 // and never updated as they are const. 108 // and never updated as they are const.
107 const base::FilePath path_; 109 const base::FilePath path_;
108 const std::string key_; 110 const std::string key_;
109 111
110 // |last_used_|, |last_modified_| and |data_size_| are copied from the 112 // |last_used_|, |last_modified_| and |data_size_| are copied from the
111 // synchronous entry at the completion of each item of asynchronous IO. 113 // synchronous entry at the completion of each item of asynchronous IO.
112 base::Time last_used_; 114 base::Time last_used_;
113 base::Time last_modified_; 115 base::Time last_modified_;
114 int32 data_size_[kSimpleEntryFileCount]; 116 int32 data_size_[kSimpleEntryFileCount];
115 117
116 // The |synchronous_entry_| is the worker thread object that performs IO on 118 // The |synchronous_entry_| is the worker thread object that performs IO on
117 // entries. 119 // entries. It's owned by this SimpleEntryImpl whenever
120 // |synchronous_entry_in_use_by_worker_| is false (i.e. when an operation
121 // is not pending on the worker pool). When an operation is pending on the
122 // worker pool, the |synchronous_entry_| is owned by itself.
118 SimpleSynchronousEntry* synchronous_entry_; 123 SimpleSynchronousEntry* synchronous_entry_;
119 124
120 // Set to true when a worker operation is posted on the |synchronous_entry_|, 125 // Set to true when a worker operation is posted on the |synchronous_entry_|,
121 // and false after. Used to insure thread safety by not allowing multiple 126 // and false after. Used to insure thread safety by not allowing multiple
122 // threads to access the |synchronous_entry_| simultaneously. 127 // threads to access the |synchronous_entry_| simultaneously.
123 bool synchronous_entry_in_use_by_worker_; 128 bool synchronous_entry_in_use_by_worker_;
124 }; 129 };
125 130
126 } // namespace disk_cache 131 } // namespace disk_cache
127 132
128 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 133 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698