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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 914183002: Remove window.chrome.gpuBenchmarking.beginWindowSnapshotPNG (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « content/renderer/gpu/gpu_benchmarking_extension.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 v8::Handle<v8::Value> argv[] = { value }; 257 v8::Handle<v8::Value> argv[] = { value };
258 258
259 frame->callFunctionEvenIfScriptDisabled( 259 frame->callFunctionEvenIfScriptDisabled(
260 callback_and_context->GetCallback(), 260 callback_and_context->GetCallback(),
261 v8::Object::New(isolate), 261 v8::Object::New(isolate),
262 1, 262 1,
263 argv); 263 argv);
264 } 264 }
265 } 265 }
266 266
267 void OnSnapshotCompleted(CallbackAndContext* callback_and_context,
268 const gfx::Size& size,
269 const std::vector<unsigned char>& png) {
270 v8::Isolate* isolate = callback_and_context->isolate();
271 v8::HandleScope scope(isolate);
272 v8::Handle<v8::Context> context = callback_and_context->GetContext();
273 v8::Context::Scope context_scope(context);
274 WebLocalFrame* frame = WebLocalFrame::frameForContext(context);
275 if (frame) {
276 v8::Handle<v8::Value> result;
277
278 if (!size.IsEmpty()) {
279 v8::Handle<v8::Object> result_object;
280 result_object = v8::Object::New(isolate);
281
282 result_object->Set(v8::String::NewFromUtf8(isolate, "width"),
283 v8::Number::New(isolate, size.width()));
284 result_object->Set(v8::String::NewFromUtf8(isolate, "height"),
285 v8::Number::New(isolate, size.height()));
286
287 std::string base64_png;
288 base::Base64Encode(
289 base::StringPiece(reinterpret_cast<const char*>(&*png.begin()),
290 png.size()),
291 &base64_png);
292
293 result_object->Set(v8::String::NewFromUtf8(isolate, "data"),
294 v8::String::NewFromUtf8(isolate,
295 base64_png.c_str(),
296 v8::String::kNormalString,
297 base64_png.size()));
298
299 result = result_object;
300 } else {
301 result = v8::Null(isolate);
302 }
303
304 v8::Handle<v8::Value> argv[] = {result};
305
306 frame->callFunctionEvenIfScriptDisabled(
307 callback_and_context->GetCallback(), v8::Object::New(isolate), 1, argv);
308 }
309 }
310
311 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) { 267 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) {
312 v8::Isolate* isolate = callback_and_context->isolate(); 268 v8::Isolate* isolate = callback_and_context->isolate();
313 v8::HandleScope scope(isolate); 269 v8::HandleScope scope(isolate);
314 v8::Handle<v8::Context> context = callback_and_context->GetContext(); 270 v8::Handle<v8::Context> context = callback_and_context->GetContext();
315 v8::Context::Scope context_scope(context); 271 v8::Context::Scope context_scope(context);
316 WebLocalFrame* frame = WebLocalFrame::frameForContext(context); 272 WebLocalFrame* frame = WebLocalFrame::frameForContext(context);
317 if (frame) { 273 if (frame) {
318 frame->callFunctionEvenIfScriptDisabled( 274 frame->callFunctionEvenIfScriptDisabled(
319 callback_and_context->GetCallback(), v8::Object::New(isolate), 0, NULL); 275 callback_and_context->GetCallback(), v8::Object::New(isolate), 0, NULL);
320 } 276 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 &GpuBenchmarking::GestureSourceTypeSupported) 437 &GpuBenchmarking::GestureSourceTypeSupported)
482 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy) 438 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy)
483 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) 439 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag)
484 .SetMethod("swipe", &GpuBenchmarking::Swipe) 440 .SetMethod("swipe", &GpuBenchmarking::Swipe)
485 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) 441 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce)
486 // TODO(dominikg): Remove once JS interface changes have rolled into 442 // TODO(dominikg): Remove once JS interface changes have rolled into
487 // stable. 443 // stable.
488 .SetValue("newPinchInterface", true) 444 .SetValue("newPinchInterface", true)
489 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) 445 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy)
490 .SetMethod("tap", &GpuBenchmarking::Tap) 446 .SetMethod("tap", &GpuBenchmarking::Tap)
491 .SetMethod("beginWindowSnapshotPNG",
492 &GpuBenchmarking::BeginWindowSnapshotPNG)
493 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) 447 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache)
494 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) 448 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark)
495 .SetMethod("sendMessageToMicroBenchmark", 449 .SetMethod("sendMessageToMicroBenchmark",
496 &GpuBenchmarking::SendMessageToMicroBenchmark) 450 &GpuBenchmarking::SendMessageToMicroBenchmark)
497 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess); 451 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess);
498 } 452 }
499 453
500 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() { 454 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() {
501 GpuBenchmarkingContext context; 455 GpuBenchmarkingContext context;
502 if (!context.Init(true)) 456 if (!context.Init(true))
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in 776 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
823 // progress, we will leak the callback and context. This needs to be fixed, 777 // progress, we will leak the callback and context. This needs to be fixed,
824 // somehow. 778 // somehow.
825 context.render_view_impl()->QueueSyntheticGesture( 779 context.render_view_impl()->QueueSyntheticGesture(
826 gesture_params.Pass(), 780 gesture_params.Pass(),
827 base::Bind(&OnSyntheticGestureCompleted, callback_and_context)); 781 base::Bind(&OnSyntheticGestureCompleted, callback_and_context));
828 782
829 return true; 783 return true;
830 } 784 }
831 785
832 void GpuBenchmarking::BeginWindowSnapshotPNG(
833 v8::Isolate* isolate,
834 v8::Handle<v8::Function> callback) {
835 GpuBenchmarkingContext context;
836 if (!context.Init(false))
837 return;
838
839 scoped_refptr<CallbackAndContext> callback_and_context =
840 new CallbackAndContext(isolate,
841 callback,
842 context.web_frame()->mainWorldScriptContext());
843
844 context.render_view_impl()->GetWindowSnapshot(
845 base::Bind(&OnSnapshotCompleted, callback_and_context));
846 }
847
848 void GpuBenchmarking::ClearImageCache() { 786 void GpuBenchmarking::ClearImageCache() {
849 WebImageCache::clear(); 787 WebImageCache::clear();
850 } 788 }
851 789
852 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { 790 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) {
853 GpuBenchmarkingContext context; 791 GpuBenchmarkingContext context;
854 if (!context.Init(true)) 792 if (!context.Init(true))
855 return 0; 793 return 0;
856 794
857 std::string name; 795 std::string name;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 834
897 return context.compositor()->SendMessageToMicroBenchmark(id, value.Pass()); 835 return context.compositor()->SendMessageToMicroBenchmark(id, value.Pass());
898 } 836 }
899 837
900 bool GpuBenchmarking::HasGpuProcess() { 838 bool GpuBenchmarking::HasGpuProcess() {
901 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 839 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
902 return !!gpu_channel; 840 return !!gpu_channel;
903 } 841 }
904 842
905 } // namespace content 843 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/gpu_benchmarking_extension.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698