[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
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 | ||||
7 | // can review the cache recent behavior should we need it. | ||||
8 | |||||
9 | #ifndef NET_DISK_CACHE_TRACE_H__ | ||||
10 | #define NET_DISK_CACHE_TRACE_H__ | ||||
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 11 | #pragma once |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 12 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 13 | #include "base/basictypes.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 14 | #include "base/memory/ref_counted.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame^] | 15 | #include "net/base/net_export.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 16 | |
17 | namespace disk_cache { | ||||
18 | |||||
19 | // Create and destroy the tracing buffer. | ||||
[email protected] | 6192f73 | 2009-03-25 23:44:20 | [diff] [blame] | 20 | void InitTrace(void); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 21 | void DestroyTrace(void); |
22 | |||||
[email protected] | 6192f73 | 2009-03-25 23:44:20 | [diff] [blame] | 23 | // Simple class to handle the trace buffer lifetime. Any object interested in |
24 | // tracing should keep a reference to the object returned by GetTraceObject(). | ||||
25 | class TraceObject : public base::RefCounted<TraceObject> { | ||||
26 | friend class base::RefCounted<TraceObject>; | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 27 | public: |
[email protected] | 6192f73 | 2009-03-25 23:44:20 | [diff] [blame] | 28 | static TraceObject* GetTraceObject(); |
29 | |||||
30 | private: | ||||
[email protected] | d4799a3 | 2010-09-28 22:54:58 | [diff] [blame] | 31 | TraceObject(); |
32 | ~TraceObject(); | ||||
[email protected] | 73a797fb | 2010-06-07 02:10:18 | [diff] [blame] | 33 | DISALLOW_COPY_AND_ASSIGN(TraceObject); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 34 | }; |
35 | |||||
36 | // Traces to the internal buffer. | ||||
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame^] | 37 | NET_EXPORT_PRIVATE void Trace(const char* format, ...); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 38 | |
39 | } // namespace disk_cache | ||||
40 | |||||
41 | #endif // NET_DISK_CACHE_TRACE_H__ |