107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com// Copyright (c) 2011 The Chromium Authors. All rights reserved. 207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com// Use of this source code is governed by a BSD-style license that can be 307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com// found in the LICENSE file. 407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#ifndef CHROME_COMMON_PROFILING_H_ 607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#define CHROME_COMMON_PROFILING_H_ 707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "build/build_config.h" 907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 10dac1d17027dcaa5596885a9f333979418b35001ccaryclark#include "base/basictypes.h" 1107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "base/debug/profiler.h" 12cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com 13cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com// The Profiling class manages the interaction with a sampling based profiler. 14570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com// Its function is controlled by the kProfilingAtStart, kProfilingFile, and 1507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com// kProfilingFlush command line values. 1607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com// All of the API should only be called from the main thread of the process. 1707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.comclass Profiling { 1807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com public: 1907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com // Called early in a process' life to allow profiling of startup time. 20d892bd8ba676d34d4ce4a73ac7aad88e102fad70caryclark@google.com // the presence of kProfilingAtStart is checked. 21570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com static void ProcessStarted(); 22570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 23570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com // Start profiling. 24570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com static void Start(); 25570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com 26570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com // Stop profiling and write out profiling file. 27d892bd8ba676d34d4ce4a73ac7aad88e102fad70caryclark@google.com static void Stop(); 288cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org 294431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org // Returns true if the process is being profiled. 304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org static bool BeingProfiled(); 3107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 3207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com // Toggle profiling on/off. 334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org static void Toggle(); 3407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 354431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org private: 364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org // Do not instantiate this class. 3707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com Profiling(); 3807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com 394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org DISALLOW_COPY_AND_ASSIGN(Profiling); 40cffbcc3b9665f2c928544b6fc6b8a0e22a4210fbcaryclark@google.com}; 414431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org 428cb1daaa1e4343eb60a7c4f21c12e33de30dad64commit-bot@chromium.org#endif // CHROME_COMMON_PROFILING_H_ 434431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org