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

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: 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 85
84 virtual ~SimpleEntryImpl(); 86 virtual ~SimpleEntryImpl();
85 87
86 // Clears the current |synchronous_entry_| and returns it. Used when posting 88 // Clears the current |synchronous_entry_| and returns it. Used when posting
87 // operations on the |synchronous_entry_| to the worker pool. This insures 89 // operations on the |synchronous_entry_| to the worker pool. This insures
88 // accesses to |synchronous_entry_| are thread safe from the memory barriers 90 // accesses to |synchronous_entry_| are thread safe from the memory barriers
89 // included in PostTask. 91 // included in PostTask.
90 SimpleSynchronousEntry* ReleaseSynchronousEntry(); 92 SimpleSynchronousEntry* ReleaseSynchronousEntry();
91 93
92 // Sets the current |synchronous_entry_|. Called on completion of worker pool 94 // Sets the current |synchronous_entry_|. Called on completion of worker pool
93 // IO to permit new operations to be launched. 95 // IO to permit new operations to be launched. Must be called on construction.
94 void SetSynchronousEntry(SimpleSynchronousEntry* synchronous_entry); 96 void SetSynchronousEntry(SimpleSynchronousEntry* synchronous_entry);
95 97
96 base::ThreadChecker thread_checker_; 98 base::ThreadChecker thread_checker_;
97 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_; 99 base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_;
98 std::string key_; 100
101 // |path_| and |key_| are copied from the synchronous entry on construction,
102 // and never updated as they are const.
103 const base::FilePath path_;
104 const std::string key_;
105
106 // |last_used_|, |last_modified_| and |data_size_| are copied from the
107 // synchronous entry at the completion of each item of asynchronous IO.
108 base::Time last_used_;
felipeg 2013/02/12 14:47:48 I don't like the fact that we are keeping a copy o
109 base::Time last_modified_;
110 int32 data_size_[kSimpleEntryFileCount];
99 111
100 // The |synchronous_entry_| is the worker thread object that performs IO on 112 // The |synchronous_entry_| is the worker thread object that performs IO on
101 // entries. It is set to NULL while operations are pending to prevent unsafe 113 // entries. It is set to NULL while operations are pending to prevent unsafe
102 // access from multiple threads. 114 // access from multiple threads.
103 SimpleSynchronousEntry* synchronous_entry_; 115 SimpleSynchronousEntry* synchronous_entry_;
104 116
105 bool has_been_doomed_; 117 bool has_been_doomed_;
106 }; 118 };
107 119
108 } // namespace disk_cache 120 } // namespace disk_cache
109 121
110 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_ 122 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_ENTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698