Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / disk_cache / tracing_cache_backend.h
blob304a7334d8340d5ab84861aed1412397b2349d38
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_
6 #define NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_
8 #include "base/memory/weak_ptr.h"
9 #include "net/disk_cache/disk_cache.h"
10 #include "net/disk_cache/stats.h"
12 namespace disk_cache {
14 class EntryProxy;
16 // The TracingCacheBackend implements the Cache Backend interface. It intercepts
17 // all backend operations from the IO thread and records the time from the start
18 // of the operation until the result is delivered.
19 class NET_EXPORT TracingCacheBackend : public Backend,
20 public base::SupportsWeakPtr<TracingCacheBackend> {
21 public:
22 explicit TracingCacheBackend(scoped_ptr<Backend> backend);
24 virtual net::CacheType GetCacheType() const OVERRIDE;
25 virtual int32 GetEntryCount() const OVERRIDE;
26 virtual int OpenEntry(const std::string& key, Entry** entry,
27 const CompletionCallback& callback) OVERRIDE;
28 virtual int CreateEntry(const std::string& key, Entry** entry,
29 const CompletionCallback& callback) OVERRIDE;
30 virtual int DoomEntry(const std::string& key,
31 const CompletionCallback& callback) OVERRIDE;
32 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE;
33 virtual int DoomEntriesBetween(base::Time initial_time,
34 base::Time end_time,
35 const CompletionCallback& callback) OVERRIDE;
36 virtual int DoomEntriesSince(base::Time initial_time,
37 const CompletionCallback& callback) OVERRIDE;
38 virtual int OpenNextEntry(void** iter, Entry** next_entry,
39 const CompletionCallback& callback) OVERRIDE;
40 virtual void EndEnumeration(void** iter) OVERRIDE;
41 virtual void GetStats(StatsItems* stats) OVERRIDE;
42 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
44 private:
45 friend class EntryProxy;
46 enum Operation {
47 OP_OPEN,
48 OP_CREATE,
49 OP_DOOM_ENTRY,
50 OP_READ,
51 OP_WRITE
54 virtual ~TracingCacheBackend();
56 EntryProxy* FindOrCreateEntryProxy(Entry* entry);
58 void OnDeleteEntry(Entry* e);
60 void RecordEvent(base::TimeTicks start_time, Operation op, std::string key,
61 Entry* entry, int result);
63 void BackendOpComplete(base::TimeTicks start_time, Operation op,
64 std::string key, Entry** entry,
65 const CompletionCallback& callback, int result);
67 net::CompletionCallback BindCompletion(Operation op,
68 base::TimeTicks start_time,
69 const std::string& key, Entry **entry,
70 const net::CompletionCallback& cb);
72 scoped_ptr<Backend> backend_;
73 typedef std::map<Entry*, EntryProxy*> EntryToProxyMap;
74 EntryToProxyMap open_entries_;
76 DISALLOW_COPY_AND_ASSIGN(TracingCacheBackend);
79 } // namespace disk_cache
81 #endif // NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_