diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 19:26:37 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 19:26:37 +0000 |
commit | f45c5f3d74273e913c62598fcbde35e20924ab50 (patch) | |
tree | 6364e206042679e527802f2214132138a731e826 /webkit/extensions | |
parent | 55410d7379f605f828d9845ee1ae8f62c0b0b145 (diff) | |
download | chromium_src-f45c5f3d74273e913c62598fcbde35e20924ab50.zip chromium_src-f45c5f3d74273e913c62598fcbde35e20924ab50.tar.gz chromium_src-f45c5f3d74273e913c62598fcbde35e20924ab50.tar.bz2 |
Cleanup of v8 extension stuff. Playback extension is only used in chrome, so move it to chrome\renderer and all of its associated switches to chrome. GC extension is only used by webkit\support, so move it there. The other two profiler extensions aren't used, so remove them.
Review URL: https://chromiumcodereview.appspot.com/10117022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/extensions')
-rw-r--r-- | webkit/extensions/v8/OWNERS | 1 | ||||
-rw-r--r-- | webkit/extensions/v8/gc_extension.cc | 27 | ||||
-rw-r--r-- | webkit/extensions/v8/gc_extension.h | 26 | ||||
-rw-r--r-- | webkit/extensions/v8/heap_profiler_extension.cc | 112 | ||||
-rw-r--r-- | webkit/extensions/v8/heap_profiler_extension.h | 26 | ||||
-rw-r--r-- | webkit/extensions/v8/playback_extension.cc | 48 | ||||
-rw-r--r-- | webkit/extensions/v8/playback_extension.h | 35 | ||||
-rw-r--r-- | webkit/extensions/v8/profiler_extension.cc | 104 | ||||
-rw-r--r-- | webkit/extensions/v8/profiler_extension.h | 27 | ||||
-rw-r--r-- | webkit/extensions/webkit_extensions_export.h | 26 |
10 files changed, 0 insertions, 432 deletions
diff --git a/webkit/extensions/v8/OWNERS b/webkit/extensions/v8/OWNERS deleted file mode 100644 index 30288836..0000000 --- a/webkit/extensions/v8/OWNERS +++ /dev/null @@ -1 +0,0 @@ -mbelshe@chromium.org diff --git a/webkit/extensions/v8/gc_extension.cc b/webkit/extensions/v8/gc_extension.cc deleted file mode 100644 index d8aa9f7..0000000 --- a/webkit/extensions/v8/gc_extension.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2011 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 "webkit/extensions/v8/gc_extension.h" - -#include "v8/include/v8.h" - -const char kGCExtensionName[] = "v8/GCController"; - -namespace extensions_v8 { - -// static -v8::Extension* GCExtension::Get() { - v8::Extension* extension = new v8::Extension( - kGCExtensionName, - "(function () {" - " var v8_gc;" - " if (gc) v8_gc = gc;" - " GCController = new Object();" - " GCController.collect =" - " function() {if (v8_gc) v8_gc(); };" - " })();"); - return extension; -} - -} // namespace extensions_v8 diff --git a/webkit/extensions/v8/gc_extension.h b/webkit/extensions/v8/gc_extension.h deleted file mode 100644 index ea5003b..0000000 --- a/webkit/extensions/v8/gc_extension.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_ -#define WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_ -#pragma once - -#include "webkit/extensions/webkit_extensions_export.h" - -namespace v8 { -class Extension; -} - -namespace extensions_v8 { - -// GCExtension is a v8 extension to expose a method into JS for triggering -// garbage collection. This should only be used for debugging. -class GCExtension { - public: - WEBKIT_EXTENSIONS_EXPORT static v8::Extension* Get(); -}; - -} // namespace extensions_v8 - -#endif // WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_ diff --git a/webkit/extensions/v8/heap_profiler_extension.cc b/webkit/extensions/v8/heap_profiler_extension.cc deleted file mode 100644 index 17f9110..0000000 --- a/webkit/extensions/v8/heap_profiler_extension.cc +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2011 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 "webkit/extensions/v8/heap_profiler_extension.h" - -#include "base/basictypes.h" -#include "v8/include/v8.h" - -#if defined(USE_TCMALLOC) && !defined(OS_WIN) -#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" -#endif - -namespace extensions_v8 { - -namespace { - -const char kHeapProfilerExtensionName[] = "v8/HeapProfiler"; - -class HeapProfilerWrapper : public v8::Extension { - public: - HeapProfilerWrapper() - : v8::Extension(kHeapProfilerExtensionName, - "if (typeof(chromium) == 'undefined') {" - " chromium = {};" - "}" - "(function() {" - " native function HeapProfilerStart();" - " native function HeapProfilerStop();" - " native function HeapProfilerDump();" - " chromium.HeapProfiler = {};" - " chromium.HeapProfiler.start = function(opt_prefix) {" - " var prefix = opt_prefix;" - " if (!prefix) {" - " var d = new Date();" - " prefix = \"chromium-\" + " - " (1900 + d.getYear()) + " - " \"-\" + d.getMonth() + " - " \"-\" + d.getDay() + " - " \"-\" + d.getTime();" - " }" - " HeapProfilerStart(prefix);" - " };" - " chromium.HeapProfiler.stop = function() {" - " HeapProfilerStop();" - " };" - " chromium.HeapProfiler.dump = function(opt_reason) {" - " HeapProfilerDump(opt_reason || \"\");" - " };" - "})();") {} - - virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( - v8::Handle<v8::String> name) { - if (name->Equals(v8::String::New("HeapProfilerStart"))) { - return v8::FunctionTemplate::New(HeapProfilerStart); - } else if (name->Equals(v8::String::New("HeapProfilerStop"))) { - return v8::FunctionTemplate::New(HeapProfilerStop); - } else if (name->Equals(v8::String::New("HeapProfilerDump"))) { - return v8::FunctionTemplate::New(HeapProfilerDump); - } - return v8::Handle<v8::FunctionTemplate>(); - } - -#if defined(USE_TCMALLOC) && !defined(OS_WIN) - static v8::Handle<v8::Value> HeapProfilerStart(const v8::Arguments& args) { - if (args.Length() >= 1 && args[0]->IsString()) { - v8::Local<v8::String> js_prefix = args[0]->ToString(); - char prefix[256]; - js_prefix->WriteAscii(prefix, 0, arraysize(prefix) - 1); - ::HeapProfilerStart(prefix); - } - return v8::Undefined(); - } - - static v8::Handle<v8::Value> HeapProfilerStop(const v8::Arguments& args) { - ::HeapProfilerStop(); - return v8::Undefined(); - } - - static v8::Handle<v8::Value> HeapProfilerDump(const v8::Arguments& args) { - if (args.Length() >= 1 && args[0]->IsString()) { - v8::Local<v8::String> js_reason = args[0]->ToString(); - char reason[256]; - js_reason->WriteAscii(reason, 0, arraysize(reason) - 1); - ::HeapProfilerDump(reason); - } - return v8::Undefined(); - } - -#else - - static v8::Handle<v8::Value> HeapProfilerStart(const v8::Arguments& args) { - return v8::Undefined(); - } - - static v8::Handle<v8::Value> HeapProfilerStop(const v8::Arguments& args) { - return v8::Undefined(); - } - - static v8::Handle<v8::Value> HeapProfilerDump(const v8::Arguments& args) { - return v8::Undefined(); - } -#endif -}; - -} // namespace - -v8::Extension* HeapProfilerExtension::Get() { - return new HeapProfilerWrapper; -} - -} // namespace extensions_v8 diff --git a/webkit/extensions/v8/heap_profiler_extension.h b/webkit/extensions/v8/heap_profiler_extension.h deleted file mode 100644 index 6e28b20..0000000 --- a/webkit/extensions/v8/heap_profiler_extension.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef WEBKIT_EXTENSIONS_V8_HEAP_PROFILER_EXTENSION_H_ -#define WEBKIT_EXTENSIONS_V8_HEAP_PROFILER_EXTENSION_H_ -#pragma once - -#include "webkit/extensions/webkit_extensions_export.h" - -namespace v8 { -class Extension; -} - -namespace extensions_v8 { - -// HeapProfilerExtension is a V8 extension to expose a JS function for -// dumping native heap profiles. This should only be used for debugging. -class HeapProfilerExtension { - public: - WEBKIT_EXTENSIONS_EXPORT static v8::Extension* Get(); -}; - -} // namespace extensions_v8 - -#endif // WEBKIT_EXTENSIONS_V8_HEAP_PROFILER_EXTENSION_H_ diff --git a/webkit/extensions/v8/playback_extension.cc b/webkit/extensions/v8/playback_extension.cc deleted file mode 100644 index c106c84..0000000 --- a/webkit/extensions/v8/playback_extension.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2011 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 "webkit/extensions/v8/playback_extension.h" - -#include "v8/include/v8.h" - -const char kPlaybackExtensionName[] = "v8/PlaybackMode"; - -namespace extensions_v8 { - -v8::Extension* PlaybackExtension::Get() { - v8::Extension* extension = new v8::Extension( - kPlaybackExtensionName, - "(function () {" - " var orig_date = Date;" - " var x = 0;" - " var time_seed = 1204251968254;" - " Math.random = function() {" - " x += .1;" - " return (x % 1);" - " };" - " Date = function() {" - " if (this instanceof Date) {" - " switch (arguments.length) {" - " case 0: return new orig_date(time_seed += 50);" - " case 1: return new orig_date(arguments[0]);" - " default: return new orig_date(arguments[0], arguments[1]," - " arguments.length >= 3 ? arguments[2] : 1," - " arguments.length >= 4 ? arguments[3] : 0," - " arguments.length >= 5 ? arguments[4] : 0," - " arguments.length >= 6 ? arguments[5] : 0," - " arguments.length >= 7 ? arguments[6] : 0);" - " }" - " }" - " return new Date().toString();" - " };" - " Date.__proto__ = orig_date;" - " Date.prototype.constructor = Date;" - " orig_date.now = function() {" - " return new Date().getTime();" - " };" - "})()"); - return extension; -} - -} // namespace extensions_v8 diff --git a/webkit/extensions/v8/playback_extension.h b/webkit/extensions/v8/playback_extension.h deleted file mode 100644 index c425ea0..0000000 --- a/webkit/extensions/v8/playback_extension.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_ -#define WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_ -#pragma once - -#include "webkit/extensions/webkit_extensions_export.h" - -namespace v8 { -class Extension; -} - -namespace extensions_v8 { - -// Inject code which overrides a few common JS functions for implementing -// randomness. In order to implement effective record & playback of -// websites, it is important that the URLs not change. Many popular web -// based apps use randomness in URLs to unique-ify urls for proxies. -// Unfortunately, this breaks playback. -// To work around this, we take the two most common client-side randomness -// generators and make them constant. They really need to be constant -// (rather than a constant seed followed by constant change) -// because the playback mode wants flexibility in how it plays them back -// and cannot always guarantee that requests for randomness are played back -// in exactly the same order in which they were recorded. -class PlaybackExtension { - public: - WEBKIT_EXTENSIONS_EXPORT static v8::Extension* Get(); -}; - -} // namespace extensions_v8 - -#endif // WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_ diff --git a/webkit/extensions/v8/profiler_extension.cc b/webkit/extensions/v8/profiler_extension.cc deleted file mode 100644 index 3ffc205..0000000 --- a/webkit/extensions/v8/profiler_extension.cc +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2011 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 "webkit/extensions/v8/profiler_extension.h" - -#include "build/build_config.h" -#include "v8/include/v8.h" - -#if defined(USE_TCMALLOC) && defined(OS_POSIX) && !defined(OS_MACOSX) -#include "third_party/tcmalloc/chromium/src/gperftools/profiler.h" -#endif - -const char kProfilerExtensionName[] = "v8/Profiler"; - -namespace extensions_v8 { - -class ProfilerWrapper : public v8::Extension { - public: - ProfilerWrapper() : - v8::Extension(kProfilerExtensionName, - "if (typeof(chromium) == 'undefined') {" - " chromium = {};" - "}" - "chromium.Profiler = function() {" - " native function ProfilerStart();" - " native function ProfilerStop();" - " native function ProfilerFlush();" - " native function ProfilerClearData();" - " native function ProfilerSetThreadName();" - " this.start = function() {" - " ProfilerStart();" - " };" - " this.stop = function() {" - " ProfilerStop();" - " };" - " this.clear = function() {" - " ProfilerClearData();" - " };" - " this.flush = function() {" - " ProfilerFlush();" - " };" - " this.setThreadName = function(name) {" - " ProfilerSetThreadName(name);" - " };" - "};") {} - - virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( - v8::Handle<v8::String> name) { - if (name->Equals(v8::String::New("ProfilerStart"))) - return v8::FunctionTemplate::New(ProfilerStart); - else if (name->Equals(v8::String::New("ProfilerStop"))) - return v8::FunctionTemplate::New(ProfilerStop); - else if (name->Equals(v8::String::New("ProfilerClearData"))) - return v8::FunctionTemplate::New(ProfilerClearData); - else if (name->Equals(v8::String::New("ProfilerFlush"))) - return v8::FunctionTemplate::New(ProfilerFlush); - else if (name->Equals(v8::String::New("ProfilerSetThreadName"))) - return v8::FunctionTemplate::New(ProfilerSetThreadName); - - return v8::Handle<v8::FunctionTemplate>(); - } - - static v8::Handle<v8::Value> ProfilerStart(const v8::Arguments& args) { -#if defined(USE_TCMALLOC) && defined(OS_POSIX) && !defined(OS_MACOSX) - ::ProfilerStart("chrome-profile"); -#endif - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ProfilerStop(const v8::Arguments& args) { -#if defined(USE_TCMALLOC) && defined(OS_POSIX) && !defined(OS_MACOSX) - ::ProfilerStop(); -#endif - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ProfilerClearData(const v8::Arguments& args) { - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ProfilerFlush(const v8::Arguments& args) { -#if defined(USE_TCMALLOC) && defined(OS_POSIX) && !defined(OS_MACOSX) - ::ProfilerFlush(); -#endif - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ProfilerSetThreadName( - const v8::Arguments& args) { - if (args.Length() >= 1 && args[0]->IsString()) { - v8::Local<v8::String> inputString = args[0]->ToString(); - char nameBuffer[256]; - inputString->WriteAscii(nameBuffer, 0, sizeof(nameBuffer)-1); - } - return v8::Undefined(); - } -}; - -v8::Extension* ProfilerExtension::Get() { - return new ProfilerWrapper(); -} - -} // namespace extensions_v8 diff --git a/webkit/extensions/v8/profiler_extension.h b/webkit/extensions/v8/profiler_extension.h deleted file mode 100644 index 8098cb7..0000000 --- a/webkit/extensions/v8/profiler_extension.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2011 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. - -#ifndef WEBKIT_EXTENSIONS_V8_PROFILER_EXTENSION_H_ -#define WEBKIT_EXTENSIONS_V8_PROFILER_EXTENSION_H_ -#pragma once - -#include "webkit/extensions/webkit_extensions_export.h" - -namespace v8 { -class Extension; -} - -namespace extensions_v8 { - -// Profiler is an extension to allow javascript access to the API for -// an external profiler program (such as Quantify). The "External" part of the -// name is to distinguish it from the built-in V8 Profiler. -class ProfilerExtension { - public: - WEBKIT_EXTENSIONS_EXPORT static v8::Extension* Get(); -}; - -} // namespace extensions_v8 - -#endif // WEBKIT_EXTENSIONS_V8_PROFILER_EXTENSION_H_ diff --git a/webkit/extensions/webkit_extensions_export.h b/webkit/extensions/webkit_extensions_export.h deleted file mode 100644 index f1fff8e..0000000 --- a/webkit/extensions/webkit_extensions_export.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef WEBKIT_EXTENSIONS_WEBKIT_EXTENSIONS_EXPORT_H_ -#define WEBKIT_EXTENSIONS_WEBKIT_EXTENSIONS_EXPORT_H_ -#pragma once - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(WEBKIT_EXTENSIONS_IMPLEMENTATION) -#define WEBKIT_EXTENSIONS_EXPORT __declspec(dllexport) -#else -#define WEBKIT_EXTENSIONS_EXPORT __declspec(dllimport) -#endif // defined(WEBKIT_EXTENSIONS_IMPLEMENTATION) - -#else // defined(WIN32) -#define WEBKIT_EXTENSIONS_EXPORT __attribute__((visibility("default"))) -#endif - -#else // defined(COMPONENT_BUILD) -#define WEBKIT_EXTENSIONS_EXPORT -#endif - -#endif // WEBKIT_EXTENSIONS_WEBKIT_EXTENSIONS_EXPORT_H_ |