| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file provides support for basic in-memory tracing of short events. We | 5 // This file provides support for basic in-memory tracing of short events. We |
| 6 // keep a static circular buffer where we store the last traced events, so we | 6 // keep a static circular buffer where we store the last traced events, so we |
| 7 // can review the cache recent behavior should we need it. | 7 // can review the cache recent behavior should we need it. |
| 8 | 8 |
| 9 #ifndef NET_DISK_CACHE_TRACE_H__ | 9 #ifndef NET_DISK_CACHE_TRACE_H__ |
| 10 #define NET_DISK_CACHE_TRACE_H__ | 10 #define NET_DISK_CACHE_TRACE_H__ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/ref_counted.h" |
| 16 | 17 |
| 17 namespace disk_cache { | 18 namespace disk_cache { |
| 18 | 19 |
| 19 // Create and destroy the tracing buffer. | 20 // Create and destroy the tracing buffer. |
| 20 bool InitTrace(void); | 21 void InitTrace(void); |
| 21 void DestroyTrace(void); | 22 void DestroyTrace(void); |
| 22 | 23 |
| 23 // Simple class to handle the trace buffer lifetime. | 24 // Simple class to handle the trace buffer lifetime. Any object interested in |
| 24 class TraceObject { | 25 // tracing should keep a reference to the object returned by GetTraceObject(). |
| 26 class TraceObject : public base::RefCounted<TraceObject> { |
| 27 friend class base::RefCounted<TraceObject>; |
| 25 public: | 28 public: |
| 29 static TraceObject* GetTraceObject(); |
| 30 |
| 31 private: |
| 26 TraceObject() { | 32 TraceObject() { |
| 27 InitTrace(); | 33 InitTrace(); |
| 28 } | 34 } |
| 35 |
| 29 ~TraceObject() { | 36 ~TraceObject() { |
| 30 DestroyTrace(); | 37 DestroyTrace(); |
| 31 } | 38 } |
| 32 | |
| 33 private: | |
| 34 DISALLOW_EVIL_CONSTRUCTORS(TraceObject); | 39 DISALLOW_EVIL_CONSTRUCTORS(TraceObject); |
| 35 }; | 40 }; |
| 36 | 41 |
| 37 // Traces to the internal buffer. | 42 // Traces to the internal buffer. |
| 38 void Trace(const char* format, ...); | 43 void Trace(const char* format, ...); |
| 39 | 44 |
| 40 } // namespace disk_cache | 45 } // namespace disk_cache |
| 41 | 46 |
| 42 #endif // NET_DISK_CACHE_TRACE_H__ | 47 #endif // NET_DISK_CACHE_TRACE_H__ |
| OLD | NEW |