Define DevTools content API
[chromium-blink-merge.git] / base / profiler / scoped_profile.h
blob2754f5e6268f3b6c63009d10e25fb5d05ba7f109
1 // Copyright (c) 2011 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.
6 #ifndef BASE_PROFILER_SCOPED_PROFILE_H_
7 #define BASE_PROFILER_SCOPED_PROFILE_H_
9 //------------------------------------------------------------------------------
10 // ScopedProfile provides basic helper functions for profiling a short
11 // region of code within a scope. It is separate from the related ThreadData
12 // class so that it can be included without much other cruft, and provide the
13 // macros listed below.
15 #include "base/base_export.h"
16 #include "base/location.h"
17 #include "base/profiler/tracked_time.h"
19 #define TRACK_RUN_IN_THIS_SCOPED_REGION_FOR_OFFICIAL_BUILDS(variable_name) \
20 ::tracked_objects::ScopedProfile variable_name(FROM_HERE)
22 #define TRACK_RUN_IN_IPC_HANDLER(dispatch_function_name) \
23 ::tracked_objects::ScopedProfile some_tracking_variable_name( \
24 FROM_HERE_WITH_EXPLICIT_FUNCTION(#dispatch_function_name))
27 namespace tracked_objects {
28 class Births;
30 class BASE_EXPORT ScopedProfile {
31 public:
32 explicit ScopedProfile(const Location& location);
33 ~ScopedProfile();
35 // Stop tracing prior to the end destruction of the instance.
36 void StopClockAndTally();
38 private:
39 Births* birth_; // Place in code where tracking started.
40 const TrackedTime start_of_run_;
42 DISALLOW_COPY_AND_ASSIGN(ScopedProfile);
45 } // namespace tracked_objects
47 #endif // BASE_PROFILER_SCOPED_PROFILE_H_