Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / net / disk_cache / simple / simple_entry_impl.h
index 2d78d8b..2dfb757 100644 (file)
@@ -11,7 +11,6 @@
 #include "base/files/file_path.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
 #include "base/threading/thread_checker.h"
 #include "net/base/cache_type.h"
 #include "net/base/net_export.h"
@@ -40,8 +39,7 @@ struct SimpleEntryCreationResults;
 // disk cache. It proxies for the SimpleSynchronousEntry, which performs IO
 // on the worker thread.
 class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry,
-    public base::RefCounted<SimpleEntryImpl>,
-    public base::SupportsWeakPtr<SimpleEntryImpl> {
+    public base::RefCounted<SimpleEntryImpl> {
   friend class base::RefCounted<SimpleEntryImpl>;
  public:
   enum OperationsMode {
@@ -49,6 +47,14 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry,
     OPTIMISTIC_OPERATIONS,
   };
 
+  // The Backend provides an |ActiveEntryProxy| instance to this entry when it
+  // is active, meaning it's the canonical entry for this |entry_hash_|. The
+  // entry can make itself inactive by deleting its proxy.
+  class ActiveEntryProxy {
+   public:
+    virtual ~ActiveEntryProxy() = 0;
+  };
+
   SimpleEntryImpl(net::CacheType cache_type,
                   const base::FilePath& path,
                   uint64 entry_hash,
@@ -56,6 +62,9 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry,
                   SimpleBackendImpl* backend,
                   net::NetLog* net_log);
 
+  void SetActiveEntryProxy(
+      scoped_ptr<ActiveEntryProxy> active_entry_proxy);
+
   // Adds another reader/writer to this entry, if possible, returning |this| to
   // |entry|.
   int OpenEntry(Entry** entry, const CompletionCallback& callback);
@@ -150,10 +159,6 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry,
   // count.
   void ReturnEntryToCaller(Entry** out_entry);
 
-  // Ensures that |this| is no longer referenced by our |backend_|, this
-  // guarantees that this entry cannot have OpenEntry/CreateEntry called again.
-  void RemoveSelfFromBackend();
-
   // An error occured, and the SimpleSynchronousEntry should have Doomed
   // us at this point. We need to remove |this| from the Backend and the
   // index.
@@ -297,6 +302,8 @@ class NET_EXPORT_PRIVATE SimpleEntryImpl : public Entry,
                   int length,
                   int stream_index);
 
+  scoped_ptr<ActiveEntryProxy> active_entry_proxy_;
+
   // All nonstatic SimpleEntryImpl methods should always be called on the IO
   // thread, in all cases. |io_thread_checker_| documents and enforces this.
   base::ThreadChecker io_thread_checker_;