Home | History | Annotate | Download | only in common
      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 #ifndef CHROME_COMMON_PROFILING_H_
      6 #define CHROME_COMMON_PROFILING_H_
      7 #pragma once
      8 
      9 #include "build/build_config.h"
     10 
     11 #include "base/basictypes.h"
     12 #include "base/debug/profiler.h"
     13 
     14 // The Profiling class manages the interaction with a sampling based profiler.
     15 // Its function is controlled by the kProfilingAtStart, kProfilingFile, and
     16 // kProfilingFlush command line values.
     17 // All of the API should only be called from the main thread of the process.
     18 class Profiling {
     19  public:
     20   // Called early in a process' life to allow profiling of startup time.
     21   // the presence of kProfilingAtStart is checked.
     22   static void ProcessStarted();
     23 
     24   // Start profiling.
     25   static void Start();
     26 
     27   // Stop profiling and write out profiling file.
     28   static void Stop();
     29 
     30   // Returns true if the process is being profiled.
     31   static bool BeingProfiled();
     32 
     33   // Called when the main message loop is started, so that automatic flushing
     34   // of the profile data file can be done.
     35   static void MainMessageLoopStarted();
     36 
     37   // Toggle profiling on/off.
     38   static void Toggle();
     39 
     40  private:
     41   // Do not instantiate this class.
     42   Profiling();
     43 
     44   DISALLOW_COPY_AND_ASSIGN(Profiling);
     45 };
     46 
     47 #endif  // CHROME_COMMON_PROFILING_H_
     48 
     49