OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" | 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" |
6 #include "content/renderer/render_view_impl.h" | 6 #include "content/renderer/render_view_impl.h" |
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" | 7 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" |
8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | |
11 #include "v8/include/v8.h" | 9 #include "v8/include/v8.h" |
12 | 10 |
13 using WebKit::WebFrame; | 11 using WebKit::WebFrame; |
14 using WebKit::WebRenderingStats; | 12 using WebKit::WebRenderingStats; |
15 using WebKit::WebView; | 13 using WebKit::WebView; |
16 | 14 |
17 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; | 15 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; |
18 | 16 |
19 using WebKit::WebFrame; | 17 using WebKit::WebFrame; |
20 using WebKit::WebView; | 18 using WebKit::WebView; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 57 |
60 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) { | 58 static v8::Handle<v8::Value> GetRenderingStats(const v8::Arguments& args) { |
61 WebFrame* web_frame = WebFrame::frameForEnteredContext(); | 59 WebFrame* web_frame = WebFrame::frameForEnteredContext(); |
62 if (!web_frame) | 60 if (!web_frame) |
63 return v8::Undefined(); | 61 return v8::Undefined(); |
64 | 62 |
65 WebView* web_view = web_frame->view(); | 63 WebView* web_view = web_frame->view(); |
66 if (!web_view) | 64 if (!web_view) |
67 return v8::Undefined(); | 65 return v8::Undefined(); |
68 | 66 |
| 67 RenderViewImpl* render_view_impl = RenderViewImpl::FromWebView(web_view); |
| 68 if (!render_view_impl) |
| 69 return v8::Undefined(); |
| 70 |
69 WebRenderingStats stats; | 71 WebRenderingStats stats; |
70 web_view->renderingStats(stats); | 72 render_view_impl->GetRenderingStats(stats); |
71 | 73 |
72 v8::Handle<v8::Object> stats_object = v8::Object::New(); | 74 v8::Handle<v8::Object> stats_object = v8::Object::New(); |
73 if (stats.numAnimationFrames) | 75 if (stats.numAnimationFrames) |
74 stats_object->Set(v8::String::New("numAnimationFrames"), | 76 stats_object->Set(v8::String::New("numAnimationFrames"), |
75 v8::Integer::New(stats.numAnimationFrames), | 77 v8::Integer::New(stats.numAnimationFrames), |
76 v8::ReadOnly); | 78 v8::ReadOnly); |
77 if (stats.numFramesSentToScreen) | 79 if (stats.numFramesSentToScreen) |
78 stats_object->Set(v8::String::New("numFramesSentToScreen"), | 80 stats_object->Set(v8::String::New("numFramesSentToScreen"), |
79 v8::Integer::New(stats.numFramesSentToScreen), | 81 v8::Integer::New(stats.numFramesSentToScreen), |
80 v8::ReadOnly); | 82 v8::ReadOnly); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 render_view_impl->BeginSmoothScroll(scroll_down, scroll_far); | 117 render_view_impl->BeginSmoothScroll(scroll_down, scroll_far); |
116 return v8::True(); | 118 return v8::True(); |
117 } | 119 } |
118 }; | 120 }; |
119 | 121 |
120 v8::Extension* GpuBenchmarkingExtension::Get() { | 122 v8::Extension* GpuBenchmarkingExtension::Get() { |
121 return new GpuBenchmarkingWrapper(); | 123 return new GpuBenchmarkingWrapper(); |
122 } | 124 } |
123 | 125 |
124 } // namespace content | 126 } // namespace content |
OLD | NEW |