| Index: net/disk_cache/very_simple/very_simple_entry_impl.h
|
| diff --git a/net/disk_cache/very_simple/very_simple_entry_impl.h b/net/disk_cache/very_simple/very_simple_entry_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6f279d201e6ee69f47b072d048d6157539dac8cd
|
| --- /dev/null
|
| +++ b/net/disk_cache/very_simple/very_simple_entry_impl.h
|
| @@ -0,0 +1,106 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_DISK_CACHE_VERY_SIMPLE_VERY_SIMPLE_ENTRY_IMPL_H_
|
| +#define NET_DISK_CACHE_VERY_SIMPLE_VERY_SIMPLE_ENTRY_IMPL_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "net/disk_cache/disk_cache.h"
|
| +
|
| +namespace net {
|
| +class IOBuffer;
|
| +}
|
| +
|
| +namespace disk_cache {
|
| +
|
| +class VerySimpleSynchronousEntry;
|
| +
|
| +// VerySimpleEntryImpl is the IO thread interface to an entry in the very simple
|
| +// disk cache. It proxies for the VerySimpleSynchronousEntry, which performs IO
|
| +// on the worker thread.
|
| +class VerySimpleEntryImpl : public Entry {
|
| + public:
|
| + static int OpenEntry(const base::FilePath& path,
|
| + const std::string& key,
|
| + Entry** entry,
|
| + const CompletionCallback& callback);
|
| +
|
| + static int CreateEntry(const base::FilePath& path,
|
| + const std::string& key,
|
| + Entry** entry,
|
| + const CompletionCallback& callback);
|
| +
|
| + static int DoomEntry(const base::FilePath& path,
|
| + const std::string& key,
|
| + const CompletionCallback& callback);
|
| +
|
| + // From Entry:
|
| + virtual void Doom() OVERRIDE;
|
| + virtual void Close() OVERRIDE;
|
| + virtual std::string GetKey() const OVERRIDE;
|
| + virtual base::Time GetLastUsed() const OVERRIDE;
|
| + virtual base::Time GetLastModified() const OVERRIDE;
|
| + virtual int32 GetDataSize(int index) const OVERRIDE;
|
| + virtual int ReadData(int index,
|
| + int offset,
|
| + net::IOBuffer* buf,
|
| + int buf_len,
|
| + const CompletionCallback& callback) OVERRIDE;
|
| + virtual int WriteData(int index,
|
| + int offset,
|
| + net::IOBuffer* buf,
|
| + int buf_len,
|
| + const CompletionCallback& callback,
|
| + bool truncate) OVERRIDE;
|
| + virtual int ReadSparseData(int64 offset,
|
| + net::IOBuffer* buf,
|
| + int buf_len,
|
| + const CompletionCallback& callback) OVERRIDE;
|
| + virtual int WriteSparseData(int64 offset,
|
| + net::IOBuffer* buf,
|
| + int buf_len,
|
| + const CompletionCallback& callback) OVERRIDE;
|
| + virtual int GetAvailableRange(int64 offset,
|
| + int len,
|
| + int64* start,
|
| + const CompletionCallback& callback) OVERRIDE;
|
| + virtual bool CouldBeSparse() const OVERRIDE;
|
| + virtual void CancelSparseIO() OVERRIDE;
|
| + virtual int ReadyForSparseIO(const CompletionCallback& callback) OVERRIDE;
|
| +
|
| + private:
|
| + explicit VerySimpleEntryImpl(VerySimpleSynchronousEntry* synchronous_entry);
|
| +
|
| + virtual ~VerySimpleEntryImpl();
|
| +
|
| + static VerySimpleEntryImpl* Create(
|
| + VerySimpleSynchronousEntry* synchronous_entry);
|
| +
|
| + // Clears the current |synchronous_entry_| and returns it. Used when posting
|
| + // operations on the |synchronous_entry_| to the worker pool, to guard against
|
| + // multiple operations in flight.
|
| + VerySimpleSynchronousEntry* ReleaseSynchronousEntry();
|
| +
|
| + // Sets the current |synchronous_entry_|. Called on completion of worker pool
|
| + // IO to permit new operations to be launched.
|
| + void SetSynchronousEntry(VerySimpleSynchronousEntry* synchronous_entry);
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| + base::WeakPtrFactory<VerySimpleEntryImpl> weak_ptr_factory_;
|
| + std::string key_;
|
| +
|
| + // The |synchronous_entry_| is the worker thread object that performs IO on
|
| + // entries. It is set to NULL while operations are pending to prevent unsafe
|
| + // access from multiple threads.
|
| + VerySimpleSynchronousEntry* synchronous_entry_;
|
| +
|
| + bool has_been_doomed_;
|
| +};
|
| +
|
| +} // namespace disk_cache
|
| +
|
| +#endif // NET_DISK_CACHE_VERY_SIMPLE_VERY_SIMPLE_ENTRY_IMPL_H_
|
|
|