Home | History | Annotate | Download | only in disk_cache
      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
      3 // found in the LICENSE file.
      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__
     11 
     12 #include <string>
     13 #include <vector>
     14 
     15 #include "base/basictypes.h"
     16 #include "base/ref_counted.h"
     17 
     18 namespace disk_cache {
     19 
     20 // Create and destroy the tracing buffer.
     21 void InitTrace(void);
     22 void DestroyTrace(void);
     23 
     24 // Simple class to handle the trace buffer lifetime. Any object interested in
     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>;
     28  public:
     29   static TraceObject* GetTraceObject();
     30 
     31  private:
     32   TraceObject() {
     33     InitTrace();
     34   }
     35 
     36   ~TraceObject() {
     37     DestroyTrace();
     38   }
     39   DISALLOW_EVIL_CONSTRUCTORS(TraceObject);
     40 };
     41 
     42 // Traces to the internal buffer.
     43 void Trace(const char* format, ...);
     44 
     45 }  // namespace disk_cache
     46 
     47 #endif  // NET_DISK_CACHE_TRACE_H__
     48