Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_ | |
| 6 #define NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "net/disk_cache/disk_cache.h" | |
| 10 #include "net/disk_cache/stats.h" | |
| 11 | |
| 12 namespace disk_cache { | |
| 13 | |
| 14 class EntryProxy; | |
| 15 | |
| 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(Backend* backend); | |
| 23 | |
| 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; | |
| 43 | |
| 44 private: | |
| 45 friend class EntryProxy; | |
| 46 enum Operation { | |
| 47 OP_NONE = 0, | |
| 48 OP_INIT, | |
| 49 OP_OPEN, | |
| 50 OP_CREATE, | |
| 51 OP_DOOM, | |
| 52 OP_DOOM_ALL, | |
| 53 OP_DOOM_BETWEEN, | |
| 54 OP_DOOM_SINCE, | |
| 55 OP_OPEN_NEXT, | |
| 56 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
| |
| 57 OP_END_ENUMERATION, | |
| 58 OP_ON_EXTERNAL_CACHE_HIT, | |
| 59 OP_CLOSE_ENTRY, | |
| 60 OP_DOOM_ENTRY, | |
| 61 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
| |
| 62 OP_RUN_TASK, | |
| 63 OP_MAX_BACKEND, | |
| 64 OP_READ, | |
| 65 OP_WRITE, | |
| 66 OP_READ_SPARSE, | |
| 67 OP_WRITE_SPARSE, | |
| 68 OP_GET_RANGE, | |
| 69 OP_CANCEL_IO, | |
| 70 OP_IS_READY | |
| 71 }; | |
| 72 | |
| 73 virtual ~TracingCacheBackend(); | |
| 74 | |
| 75 EntryProxy* FindOrCreateEntryProxy(Entry* entry); | |
| 76 | |
| 77 void OnDeleteEntry(Entry* e); | |
| 78 | |
| 79 void RecordEvent(int64 start_time, Operation op, std::string key, | |
| 80 Entry* entry, int rv); | |
| 81 | |
| 82 void BackendOpComplete(int64 start_time, Operation op, std::string key, | |
| 83 Entry** entry, const CompletionCallback& callback, | |
| 84 int rv); | |
| 85 | |
| 86 net::CompletionCallback BindCompletion(Operation op, int64 start_time, | |
| 87 const std::string& key, Entry **entry, | |
| 88 const net::CompletionCallback& cb); | |
| 89 | |
| 90 scoped_ptr<Backend> backend_; | |
| 91 typedef std::map<Entry*, EntryProxy*> EntryToProxyMap; | |
| 92 EntryToProxyMap open_entries_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(TracingCacheBackend); | |
| 95 }; | |
| 96 | |
| 97 } // namespace disk_cache | |
| 98 | |
| 99 #endif // NET_DISK_CACHE_TRACING_CACHE_BACKEND_H_ | |
| OLD | NEW |