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

Side by Side Diff: net/disk_cache/tracing/tracing_cache_backend.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_ 5 #ifndef NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_
6 #define NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_ 6 #define NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "net/disk_cache/blockfile/stats.h" 12 #include "net/disk_cache/blockfile/stats.h"
13 #include "net/disk_cache/disk_cache.h" 13 #include "net/disk_cache/disk_cache.h"
14 14
15 namespace disk_cache { 15 namespace disk_cache {
16 16
17 class EntryProxy; 17 class EntryProxy;
18 18
19 // The TracingCacheBackend implements the Cache Backend interface. It intercepts 19 // The TracingCacheBackend implements the Cache Backend interface. It intercepts
20 // all backend operations from the IO thread and records the time from the start 20 // all backend operations from the IO thread and records the time from the start
21 // of the operation until the result is delivered. 21 // of the operation until the result is delivered.
22 class NET_EXPORT TracingCacheBackend : public Backend, 22 class NET_EXPORT TracingCacheBackend
23 public base::SupportsWeakPtr<TracingCacheBackend> { 23 : public Backend,
24 public base::SupportsWeakPtr<TracingCacheBackend> {
24 public: 25 public:
25 explicit TracingCacheBackend(scoped_ptr<Backend> backend); 26 explicit TracingCacheBackend(scoped_ptr<Backend> backend);
26 27
27 virtual net::CacheType GetCacheType() const OVERRIDE; 28 virtual net::CacheType GetCacheType() const OVERRIDE;
28 virtual int32 GetEntryCount() const OVERRIDE; 29 virtual int32 GetEntryCount() const OVERRIDE;
29 virtual int OpenEntry(const std::string& key, Entry** entry, 30 virtual int OpenEntry(const std::string& key,
31 Entry** entry,
30 const CompletionCallback& callback) OVERRIDE; 32 const CompletionCallback& callback) OVERRIDE;
31 virtual int CreateEntry(const std::string& key, Entry** entry, 33 virtual int CreateEntry(const std::string& key,
34 Entry** entry,
32 const CompletionCallback& callback) OVERRIDE; 35 const CompletionCallback& callback) OVERRIDE;
33 virtual int DoomEntry(const std::string& key, 36 virtual int DoomEntry(const std::string& key,
34 const CompletionCallback& callback) OVERRIDE; 37 const CompletionCallback& callback) OVERRIDE;
35 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE; 38 virtual int DoomAllEntries(const CompletionCallback& callback) OVERRIDE;
36 virtual int DoomEntriesBetween(base::Time initial_time, 39 virtual int DoomEntriesBetween(base::Time initial_time,
37 base::Time end_time, 40 base::Time end_time,
38 const CompletionCallback& callback) OVERRIDE; 41 const CompletionCallback& callback) OVERRIDE;
39 virtual int DoomEntriesSince(base::Time initial_time, 42 virtual int DoomEntriesSince(base::Time initial_time,
40 const CompletionCallback& callback) OVERRIDE; 43 const CompletionCallback& callback) OVERRIDE;
41 virtual int OpenNextEntry(void** iter, Entry** next_entry, 44 virtual int OpenNextEntry(void** iter,
45 Entry** next_entry,
42 const CompletionCallback& callback) OVERRIDE; 46 const CompletionCallback& callback) OVERRIDE;
43 virtual void EndEnumeration(void** iter) OVERRIDE; 47 virtual void EndEnumeration(void** iter) OVERRIDE;
44 virtual void GetStats(StatsItems* stats) OVERRIDE; 48 virtual void GetStats(StatsItems* stats) OVERRIDE;
45 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 49 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
46 50
47 private: 51 private:
48 friend class EntryProxy; 52 friend class EntryProxy;
49 enum Operation { 53 enum Operation { OP_OPEN, OP_CREATE, OP_DOOM_ENTRY, OP_READ, OP_WRITE };
50 OP_OPEN,
51 OP_CREATE,
52 OP_DOOM_ENTRY,
53 OP_READ,
54 OP_WRITE
55 };
56 54
57 virtual ~TracingCacheBackend(); 55 virtual ~TracingCacheBackend();
58 56
59 EntryProxy* FindOrCreateEntryProxy(Entry* entry); 57 EntryProxy* FindOrCreateEntryProxy(Entry* entry);
60 58
61 void OnDeleteEntry(Entry* e); 59 void OnDeleteEntry(Entry* e);
62 60
63 void RecordEvent(base::TimeTicks start_time, Operation op, std::string key, 61 void RecordEvent(base::TimeTicks start_time,
64 Entry* entry, int result); 62 Operation op,
63 std::string key,
64 Entry* entry,
65 int result);
65 66
66 void BackendOpComplete(base::TimeTicks start_time, Operation op, 67 void BackendOpComplete(base::TimeTicks start_time,
67 std::string key, Entry** entry, 68 Operation op,
68 const CompletionCallback& callback, int result); 69 std::string key,
70 Entry** entry,
71 const CompletionCallback& callback,
72 int result);
69 73
70 net::CompletionCallback BindCompletion(Operation op, 74 net::CompletionCallback BindCompletion(Operation op,
71 base::TimeTicks start_time, 75 base::TimeTicks start_time,
72 const std::string& key, Entry **entry, 76 const std::string& key,
77 Entry** entry,
73 const net::CompletionCallback& cb); 78 const net::CompletionCallback& cb);
74 79
75 scoped_ptr<Backend> backend_; 80 scoped_ptr<Backend> backend_;
76 typedef std::map<Entry*, EntryProxy*> EntryToProxyMap; 81 typedef std::map<Entry*, EntryProxy*> EntryToProxyMap;
77 EntryToProxyMap open_entries_; 82 EntryToProxyMap open_entries_;
78 83
79 DISALLOW_COPY_AND_ASSIGN(TracingCacheBackend); 84 DISALLOW_COPY_AND_ASSIGN(TracingCacheBackend);
80 }; 85 };
81 86
82 } // namespace disk_cache 87 } // namespace disk_cache
83 88
84 #endif // NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_ 89 #endif // NET_DISK_CACHE_TRACING_TRACING_CACHE_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698