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

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

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

Powered by Google App Engine
This is Rietveld 408576698