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

Unified Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 10536080: Plumb rendering statistics to benchmarking extension. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge. Created 8 years, 6 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: content/renderer/gpu/gpu_benchmarking_extension.cc
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index 06bf1938a799b9a018da1edfee39e79355ddbdb3..e9128404795a11dc35693afa364413fea6dd5d04 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -4,8 +4,15 @@
#include "content/renderer/gpu/gpu_benchmarking_extension.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "v8/include/v8.h"
+using WebKit::WebFrame;
+using WebKit::WebRenderingStats;
+using WebKit::WebView;
+
const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking";
namespace content {
@@ -19,12 +26,43 @@ class GpuBenchmarkingWrapper : public v8::Extension {
"};"
"if (typeof(chrome.gpuBenchmarking) == 'undefined') {"
" chrome.gpuBenchmarking = {};"
+ "};"
+ "chrome.gpuBenchmarking.renderingStats = function() {"
+ " native function GetRenderingStats();"
+ " return GetRenderingStats();"
"};") {}
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::New("GetRenderingStats")))
+ return v8::FunctionTemplate::New(GetRenderingStats);
+
return v8::Handle<v8::FunctionTemplate>();
}
+
+ static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) {
+ WebFrame* web_frame = WebFrame::frameForEnteredContext();
+ if (!web_frame)
+ return v8::Undefined();
+
+ WebView* web_view = web_frame->view();
+ if (!web_view)
+ return v8::Undefined();
+
+ WebRenderingStats stats;
+ web_view->renderingStats(stats);
+
+ v8::Handle<v8::Object> stats_object = v8::Object::New();
+ if (stats.numAnimationFrames)
+ stats_object->Set(v8::String::New("numAnimationFrames"),
+ v8::Integer::New(stats.numAnimationFrames),
+ v8::ReadOnly);
+ if (stats.numFramesSentToScreen)
+ stats_object->Set(v8::String::New("numFramesSentToScreen"),
+ v8::Integer::New(stats.numFramesSentToScreen),
+ v8::ReadOnly);
+ return stats_object;
+ }
};
v8::Extension* GpuBenchmarkingExtension::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