Chromium Code Reviews| Index: net/disk_cache/tracing_cache_backend.h |
| diff --git a/net/disk_cache/tracing_cache_backend.h b/net/disk_cache/tracing_cache_backend.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4bbb0e152cea870481460cf8bd4060bbdec35cc9 |
| --- /dev/null |
| +++ b/net/disk_cache/tracing_cache_backend.h |
| @@ -0,0 +1,99 @@ |
| +// 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_TRACING_CACHE_BACKEND_H_ |
| +#define NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_ |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "net/disk_cache/disk_cache.h" |
| +#include "net/disk_cache/stats.h" |
| + |
| +namespace disk_cache { |
| + |
| +class EntryProxy; |
| + |
| +// The TracingCacheBackend implements the Cache Backend interface. It intercepts |
| +// all backend operations from the IO thread and records the time from the start |
| +// of the operation until the result is delivered. |
| +class NET_EXPORT TracingCacheBackend : public Backend, |
| + public base::SupportsWeakPtr<TracingCacheBackend> { |
| + public: |
| + explicit TracingCacheBackend(Backend* backend); |
| + |
| + virtual net::CacheType GetCacheType() const OVERRIDE; |
| + virtual int32 GetEntryCount() const OVERRIDE; |
| + virtual int OpenEntry(const std::string& key, Entry** entry, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual int CreateEntry(const std::string& key, Entry** entry, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual int DoomEntry(const std::string& key, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE; |
| + virtual int DoomEntriesBetween(base::Time initial_time, |
| + base::Time end_time, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual int DoomEntriesSince(base::Time initial_time, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual int OpenNextEntry(void** iter, Entry** next_entry, |
| + const CompletionCallback& callback) OVERRIDE; |
| + virtual void EndEnumeration(void** iter) OVERRIDE; |
| + virtual void GetStats(StatsItems* stats) OVERRIDE; |
| + virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; |
| + |
| + private: |
| + friend class EntryProxy; |
| + enum Operation { |
| + OP_NONE = 0, |
| + OP_INIT, |
| + OP_OPEN, |
| + OP_CREATE, |
| + OP_DOOM, |
| + OP_DOOM_ALL, |
| + OP_DOOM_BETWEEN, |
| + OP_DOOM_SINCE, |
| + OP_OPEN_NEXT, |
| + OP_OPEN_PREV, |
|
rvargas (doing something else)
2013/04/09 18:54:01
what's this? :)
pasko-google - do not use
2013/04/10 17:06:38
seems like an outdated operation not invoked for t
|
| + OP_END_ENUMERATION, |
| + OP_ON_EXTERNAL_CACHE_HIT, |
| + OP_CLOSE_ENTRY, |
| + OP_DOOM_ENTRY, |
| + OP_FLUSH_QUEUE, |
|
rvargas (doing something else)
2013/04/09 18:54:01
ditto (etc). This is a good place to only have wha
pasko-google - do not use
2013/04/10 17:06:38
I do not like putting the decision about the set o
|
| + OP_RUN_TASK, |
| + OP_MAX_BACKEND, |
| + OP_READ, |
| + OP_WRITE, |
| + OP_READ_SPARSE, |
| + OP_WRITE_SPARSE, |
| + OP_GET_RANGE, |
| + OP_CANCEL_IO, |
| + OP_IS_READY |
| + }; |
| + |
| + virtual ~TracingCacheBackend(); |
| + |
| + EntryProxy* FindOrCreateEntryProxy(Entry* entry); |
| + |
| + void OnDeleteEntry(Entry* e); |
| + |
| + void RecordEvent(int64 start_time, Operation op, std::string key, |
| + Entry* entry, int rv); |
| + |
| + void BackendOpComplete(int64 start_time, Operation op, std::string key, |
| + Entry** entry, const CompletionCallback& callback, |
| + int rv); |
| + |
| + net::CompletionCallback BindCompletion(Operation op, int64 start_time, |
| + const std::string& key, Entry **entry, |
| + const net::CompletionCallback& cb); |
| + |
| + scoped_ptr<Backend> backend_; |
| + typedef std::map<Entry*, EntryProxy*> EntryToProxyMap; |
| + EntryToProxyMap open_entries_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TracingCacheBackend); |
| +}; |
| + |
| +} // namespace disk_cache |
| + |
| +#endif // NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_ |