Index: net/disk_cache/simple/simple_entry_impl.h |
diff --git a/net/disk_cache/simple/simple_entry_impl.h b/net/disk_cache/simple/simple_entry_impl.h |
index 616aaddf7663fadbd28c782a386cd13d436868c6..d24b2de34273a3d136bff01ab83ca3930abd4621 100644 |
--- a/net/disk_cache/simple/simple_entry_impl.h |
+++ b/net/disk_cache/simple/simple_entry_impl.h |
@@ -8,6 +8,7 @@ |
#include <string> |
#include "base/files/file_path.h" |
+#include "base/memory/ref_counted.h" |
#include "base/memory/weak_ptr.h" |
#include "base/threading/thread_checker.h" |
#include "net/disk_cache/disk_cache.h" |
@@ -26,7 +27,8 @@ class SimpleSynchronousEntry; |
// SimpleEntryImpl is the IO thread interface to an entry in the very simple |
// disk cache. It proxies for the SimpleSynchronousEntry, which performs IO |
// on the worker thread. |
-class SimpleEntryImpl : public Entry { |
+class SimpleEntryImpl : public Entry, public base::RefCounted<SimpleEntryImpl> { |
+ friend class base::RefCounted<SimpleEntryImpl>; |
public: |
static int OpenEntry(base::WeakPtr<SimpleIndex> index, |
const base::FilePath& path, |
@@ -80,34 +82,29 @@ class SimpleEntryImpl : public Entry { |
virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE; |
private: |
- SimpleEntryImpl(SimpleSynchronousEntry* synchronous_entry, |
- base::WeakPtr<SimpleIndex> index); |
+ SimpleEntryImpl(base::WeakPtr<SimpleIndex> index, |
+ const base::FilePath& path, |
+ const std::string& key); |
+ |
Philippe
2013/04/17 10:19:22
Nit: extra blank line.
gavinp
2013/04/17 10:56:28
Done.
|
virtual ~SimpleEntryImpl(); |
// Called after a SimpleSynchronousEntry has completed CreateEntry() or |
- // OpenEntry(). Constructs the new SimpleEntryImpl (if |result| is net::OK) |
- // and passes it back to the caller via |out_entry|. Also runs |
- // |completion_callback|. |
- static void CreationOperationComplete( |
- base::WeakPtr<SimpleIndex> index, |
+ // OpenEntry(). If |sync_entry| is non-NULL, creation is successful and we |
+ // can return the SimpleEntryImpl to |entry|. Runs |completion_callback|. |
digit
2013/04/16 10:21:32
I believe the style guide wants us to place all in
gavinp
2013/04/17 10:56:28
You're right about the style guide. The challenge
|
+ void CreationOperationComplete( |
+ Entry** entry, |
const CompletionCallback& completion_callback, |
- const std::string& key, |
- Entry** out_entry, |
SimpleSynchronousEntry* sync_entry); |
// Called after a SimpleSynchronousEntry has completed an asynchronous IO |
// operation, such as ReadData() or WriteData(). Calls |completion_callback|. |
- // If |entry| no longer exists, then it ensures |sync_entry| is closed. |
- static void EntryOperationComplete( |
- base::WeakPtr<SimpleIndex> index, |
+ void EntryOperationComplete( |
const CompletionCallback& completion_callback, |
- base::WeakPtr<SimpleEntryImpl> entry, |
- SimpleSynchronousEntry* sync_entry, |
int result); |
- // Called on construction and also after the completion of asynchronous IO to |
- // initialize the IO thread copies of data returned by synchronous accessor |
+ // Called on initialization and also after the completion of asynchronous IO |
+ // to initialize the IO thread copies of data returned by synchronous accessor |
// functions. Copies data from |synchronous_entry_| into |this|, so that |
// values can be returned during our next IO operation. |
void SetSynchronousData(); |
@@ -116,10 +113,7 @@ class SimpleEntryImpl : public Entry { |
// thread, in all cases. |io_thread_checker_| documents and enforces this. |
base::ThreadChecker io_thread_checker_; |
- base::WeakPtrFactory<SimpleEntryImpl> weak_ptr_factory_; |
- |
- // |path_| and |key_| are copied from the synchronous entry on construction, |
- // and never updated as they are const. |
+ const base::WeakPtr<SimpleIndex> index_; |
const base::FilePath path_; |
const std::string key_; |
@@ -140,8 +134,6 @@ class SimpleEntryImpl : public Entry { |
// and false after. Used to ensure thread safety by not allowing multiple |
// threads to access the |synchronous_entry_| simultaneously. |
bool synchronous_entry_in_use_by_worker_; |
- |
- base::WeakPtr<SimpleIndex> index_; |
}; |
} // namespace disk_cache |