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

Unified Diff: net/disk_cache/tracing_cache_backend.h

Issue 13731002: Cache Backend Proxy to intercept all cache events from the IO thread. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: trivial net.gyp merge Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.cc ('k') | net/disk_cache/tracing_cache_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..60fb9c208be3e05124302e0e0d06bf71e9a64687
--- /dev/null
+++ b/net/disk_cache/tracing_cache_backend.h
@@ -0,0 +1,81 @@
+// 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_OPEN,
+ OP_CREATE,
+ OP_DOOM_ENTRY,
+ OP_READ,
+ OP_WRITE
+ };
+
+ virtual ~TracingCacheBackend();
+
+ EntryProxy* FindOrCreateEntryProxy(Entry* entry);
+
+ void OnDeleteEntry(Entry* e);
+
+ void RecordEvent(base::TimeTicks start_time, Operation op, std::string key,
+ Entry* entry, int result);
+
+ void BackendOpComplete(base::TimeTicks start_time, Operation op,
+ std::string key, Entry** entry,
+ const CompletionCallback& callback, int result);
+
+ net::CompletionCallback BindCompletion(Operation op,
+ base::TimeTicks 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_
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.cc ('k') | net/disk_cache/tracing_cache_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698