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

Side by Side Diff: content/renderer/skia_benchmarking_extension.cc

Issue 611483002: Fix for crash when attaching a frame in WebUI renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: As suggested, factored out the solution and used in other extensions. Created 6 years, 2 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/memory_benchmarking_extension.cc ('k') | content/renderer/web_ui_extension.cc » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/skia_benchmarking_extension.h" 5 #include "content/renderer/skia_benchmarking_extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
11 #include "cc/resources/picture.h" 11 #include "cc/resources/picture.h"
12 #include "content/public/renderer/v8_value_converter.h" 12 #include "content/public/renderer/v8_value_converter.h"
13 #include "content/renderer/chrome_object_extensions_utils.h"
13 #include "content/renderer/render_thread_impl.h" 14 #include "content/renderer/render_thread_impl.h"
14 #include "gin/arguments.h" 15 #include "gin/arguments.h"
15 #include "gin/handle.h" 16 #include "gin/handle.h"
16 #include "gin/object_template_builder.h" 17 #include "gin/object_template_builder.h"
17 #include "skia/ext/benchmarking_canvas.h" 18 #include "skia/ext/benchmarking_canvas.h"
18 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 19 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
19 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" 20 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h"
20 #include "third_party/WebKit/public/web/WebFrame.h" 21 #include "third_party/WebKit/public/web/WebFrame.h"
21 #include "third_party/WebKit/public/web/WebKit.h" 22 #include "third_party/WebKit/public/web/WebKit.h"
22 #include "third_party/skia/include/core/SkCanvas.h" 23 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (context.IsEmpty()) 71 if (context.IsEmpty())
71 return; 72 return;
72 73
73 v8::Context::Scope context_scope(context); 74 v8::Context::Scope context_scope(context);
74 75
75 gin::Handle<SkiaBenchmarking> controller = 76 gin::Handle<SkiaBenchmarking> controller =
76 gin::CreateHandle(isolate, new SkiaBenchmarking()); 77 gin::CreateHandle(isolate, new SkiaBenchmarking());
77 if (controller.IsEmpty()) 78 if (controller.IsEmpty())
78 return; 79 return;
79 80
80 v8::Handle<v8::Object> global = context->Global(); 81 v8::Handle<v8::Object> chrome = GetOrCreateChromeObject(isolate,
81 v8::Handle<v8::Object> chrome = 82 context->Global());
82 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject();
83 if (chrome.IsEmpty()) {
84 chrome = v8::Object::New(isolate);
85 global->Set(gin::StringToV8(isolate, "chrome"), chrome);
86 }
87 chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8()); 83 chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8());
88 } 84 }
89 85
90 // static 86 // static
91 void SkiaBenchmarking::Initialize() { 87 void SkiaBenchmarking::Initialize() {
92 DCHECK(RenderThreadImpl::current()); 88 DCHECK(RenderThreadImpl::current());
93 // FIXME: remove this after Skia updates SkGraphics::Init() to be 89 // FIXME: remove this after Skia updates SkGraphics::Init() to be
94 // thread-safe and idempotent. 90 // thread-safe and idempotent.
95 static bool skia_initialized = false; 91 static bool skia_initialized = false;
96 if (!skia_initialized) { 92 if (!skia_initialized) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 v8::Handle<v8::Object> result = v8::Object::New(isolate); 299 v8::Handle<v8::Object> result = v8::Object::New(isolate);
304 result->Set(v8::String::NewFromUtf8(isolate, "width"), 300 result->Set(v8::String::NewFromUtf8(isolate, "width"),
305 v8::Number::New(isolate, picture->LayerRect().width())); 301 v8::Number::New(isolate, picture->LayerRect().width()));
306 result->Set(v8::String::NewFromUtf8(isolate, "height"), 302 result->Set(v8::String::NewFromUtf8(isolate, "height"),
307 v8::Number::New(isolate, picture->LayerRect().height())); 303 v8::Number::New(isolate, picture->LayerRect().height()));
308 304
309 args->Return(result); 305 args->Return(result);
310 } 306 }
311 307
312 } // namespace content 308 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/memory_benchmarking_extension.cc ('k') | content/renderer/web_ui_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698