summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base.gyp8
-rw-r--r--base/base.gypi8
-rw-r--r--base/profiler.cc60
-rw-r--r--base/profiler.h42
-rw-r--r--webkit/extensions/v8/profiler_extension.cc42
5 files changed, 43 insertions, 117 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 5145404..8e0b1e9 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -191,6 +191,14 @@
'sources': [
'nix/xdg_util_unittest.cc',
],
+ 'conditions': [
+ [ 'linux_use_tcmalloc==1', {
+ 'dependencies': [
+ 'allocator/allocator.gyp:allocator',
+ ],
+ },
+ ],
+ ],
'dependencies': [
'../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:nss',
diff --git a/base/base.gypi b/base/base.gypi
index 992cdcc..2adb528 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -179,8 +179,6 @@
'process_util_posix.cc',
'process_util_win.cc',
'process_win.cc',
- 'profiler.cc',
- 'profiler.h',
'rand_util.cc',
'rand_util.h',
'rand_util_posix.cc',
@@ -550,12 +548,6 @@
},
},
],
- [ 'linux_use_tcmalloc==1', {
- 'dependencies': [
- 'allocator/allocator.gyp:allocator',
- ],
- },
- ],
],
'dependencies': [
'symbolize',
diff --git a/base/profiler.cc b/base/profiler.cc
deleted file mode 100644
index b66664b..0000000
--- a/base/profiler.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/profiler.h"
-
-#if defined(USE_TCMALLOC) && defined(OS_LINUX)
-#include "third_party/tcmalloc/chromium/src/google/profiler.h"
-#endif
-
-// When actually using quantify, uncomment the following line.
-// #define QUANTIFY
-
-#ifdef QUANTIFY
-// this #define is used to prevent people from directly using pure.h
-// instead of profiler.h
-#define PURIFY_PRIVATE_INCLUDE
-#include "base/third_party/purify/pure.h"
-#endif // QUANTIFY
-
-namespace base {
-
-void Profiler::StartRecording() {
-#ifdef QUANTIFY
- QuantifyStartRecordingData();
-#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
- ProfilerStart("chrome-profile");
-#endif
-}
-
-void Profiler::StopRecording() {
-#ifdef QUANTIFY
- QuantifyStopRecordingData();
-#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
- ProfilerStop();
-#endif
-}
-
-void Profiler::Flush() {
-#if defined(USE_TCMALLOC) && defined(OS_LINUX)
- ProfilerFlush();
-#endif
-}
-
-void Profiler::ClearData() {
-#ifdef QUANTIFY
- QuantifyClearData();
-#endif
-}
-
-void Profiler::SetThreadName(const char *name) {
-#ifdef QUANTIFY
- // make a copy since the Quantify function takes a char*, not const char*
- char buffer[512];
- base::snprintf(buffer, sizeof(buffer)-1, "%s", name);
- QuantifySetThreadName(buffer);
-#endif
-}
-
-} // namespace base
diff --git a/base/profiler.h b/base/profiler.h
deleted file mode 100644
index ea8867a..0000000
--- a/base/profiler.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// An abstraction for functions used to control execution time profiling.
-// All methods are effectively no-ops unless this program is being run through
-// a supported tool (currently only Quantify, a companion tool to Purify)
-
-#ifndef BASE_PROFILER_H__
-#define BASE_PROFILER_H__
-#pragma once
-
-#include "base/basictypes.h"
-
-namespace base {
-
-class Profiler {
- public:
- // Starts or resumes recording.
- static void StartRecording();
-
- // Stops recording until StartRecording is called or the program exits.
- static void StopRecording();
-
- // Throw away data collected so far. This can be useful to call before
- // your first call to StartRecording, for instance to avoid counting any
- // time in application startup.
- static void ClearData();
-
- // Flushes all recorded data to disk. No-op until recording is started.
- static void Flush();
-
- // Sets the name of the current thread for display in the profiler's UI.
- static void SetThreadName(const char *name);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(Profiler);
-};
-
-} // namespace base
-
-#endif // BASE_PROFILER_H__
diff --git a/webkit/extensions/v8/profiler_extension.cc b/webkit/extensions/v8/profiler_extension.cc
index 8f393d4..487649a 100644
--- a/webkit/extensions/v8/profiler_extension.cc
+++ b/webkit/extensions/v8/profiler_extension.cc
@@ -4,11 +4,22 @@
#include "webkit/extensions/v8/profiler_extension.h"
-#include "base/profiler.h"
+#include "build/build_config.h"
+
+#if defined(QUANTIFY)
+// this #define is used to prevent people from directly using pure.h
+// instead of profiler.h
+#define PURIFY_PRIVATE_INCLUDE
+#include "base/third_party/purify/pure.h"
+#endif // QUANTIFY
+
+#if defined(USE_TCMALLOC) && defined(OS_LINUX)
+#include "third_party/tcmalloc/chromium/src/google/profiler.h"
+#endif
namespace extensions_v8 {
-const char* kProfilerExtensionName = "v8/Profiler";
+const char kProfilerExtensionName[] = "v8/Profiler";
class ProfilerWrapper : public v8::Extension {
public:
@@ -58,25 +69,37 @@ class ProfilerWrapper : public v8::Extension {
static v8::Handle<v8::Value> ProfilerStart(
const v8::Arguments& args) {
- base::Profiler::StartRecording();
+#if defined(QUANTIFY)
+ QuantifyStartRecordingData();
+#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
+ ::ProfilerStart("chrome-profile");
+#endif
return v8::Undefined();
}
static v8::Handle<v8::Value> ProfilerStop(
const v8::Arguments& args) {
- base::Profiler::StopRecording();
+#if defined(QUANTIFY)
+ QuantifyStopRecordingData();
+#elif defined(USE_TCMALLOC) && defined(OS_LINUX)
+ ::ProfilerStop();
+#endif
return v8::Undefined();
}
static v8::Handle<v8::Value> ProfilerClearData(
const v8::Arguments& args) {
- base::Profiler::ClearData();
+#if defined(QUANTIFY)
+ QuantifyClearData();
+#endif
return v8::Undefined();
}
static v8::Handle<v8::Value> ProfilerFlush(
const v8::Arguments& args) {
- base::Profiler::Flush();
+#if defined(USE_TCMALLOC) && defined(OS_LINUX)
+ ::ProfilerFlush();
+#endif
return v8::Undefined();
}
@@ -87,7 +110,12 @@ class ProfilerWrapper : public v8::Extension {
v8::Local<v8::String> inputString = args[0]->ToString();
char nameBuffer[256];
inputString->WriteAscii(nameBuffer, 0, sizeof(nameBuffer)-1);
- base::Profiler::SetThreadName(nameBuffer);
+#if defined(QUANTIFY)
+ // make a copy since the Quantify function takes a char*, not const char*
+ char buffer[512];
+ base::snprintf(buffer, arraysize(buffer)-1, "%s", name);
+ QuantifySetThreadName(buffer);
+#endif
}
return v8::Undefined();
}