Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: webkit/extensions/v8/benchmarking_extension.cc

Issue 149788: Expose access for reading stats counters via the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/extensions/v8/benchmarking_extension.cc
===================================================================
--- webkit/extensions/v8/benchmarking_extension.cc (revision 20745)
+++ webkit/extensions/v8/benchmarking_extension.cc (working copy)
@@ -4,6 +4,7 @@
#include "config.h"
#include "Cache.h"
+#include "base/stats_table.h"
#include "webkit/extensions/v8/benchmarking_extension.h"
#include "webkit/glue/webkit_glue.h"
@@ -28,7 +29,12 @@
"chromium.benchmarking.closeConnections = function() {"
" native function CloseConnections();"
" CloseConnections();"
- "};") {}
+ "};"
+ "chromium.benchmarking.counter = function(name) {"
+ " native function GetCounter();"
+ " return GetCounter(name);"
+ "};"
+ ) {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name) {
@@ -36,6 +42,8 @@
return v8::FunctionTemplate::New(CloseConnections);
} else if (name->Equals(v8::String::New("ClearCache"))) {
return v8::FunctionTemplate::New(ClearCache);
+ } else if (name->Equals(v8::String::New("GetCounter"))) {
+ return v8::FunctionTemplate::New(GetCounter);
}
return v8::Handle<v8::FunctionTemplate>();
}
@@ -54,6 +62,20 @@
WebCore::cache()->setDisabled(false);
return v8::Undefined();
}
+
+ static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) {
+ if (!args.Length() || !args[0]->IsString())
+ return v8::Undefined();
+
+ // Extract the name argument
+ char name[256];
+ name[0] = 'c';
+ name[1] = ':';
+ args[0]->ToString()->WriteAscii(&name[2], 0, sizeof(name) - 3);
+
+ int counter = StatsTable::current()->GetCounterValue(name);
+ return v8::Integer::New(counter);
+ }
};
v8::Extension* BenchmarkingExtension::Get() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698