OLD | NEW |
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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 v8::Isolate* isolate = blink::mainThreadIsolate(); | 67 v8::Isolate* isolate = blink::mainThreadIsolate(); |
68 v8::HandleScope handle_scope(isolate); | 68 v8::HandleScope handle_scope(isolate); |
69 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 69 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
70 if (context.IsEmpty()) | 70 if (context.IsEmpty()) |
71 return; | 71 return; |
72 | 72 |
73 v8::Context::Scope context_scope(context); | 73 v8::Context::Scope context_scope(context); |
74 | 74 |
75 gin::Handle<SkiaBenchmarking> controller = | 75 gin::Handle<SkiaBenchmarking> controller = |
76 gin::CreateHandle(isolate, new SkiaBenchmarking()); | 76 gin::CreateHandle(isolate, new SkiaBenchmarking()); |
| 77 if (controller.IsEmpty()) |
| 78 return; |
| 79 |
77 v8::Handle<v8::Object> global = context->Global(); | 80 v8::Handle<v8::Object> global = context->Global(); |
78 v8::Handle<v8::Object> chrome = | 81 v8::Handle<v8::Object> chrome = |
79 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); | 82 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); |
80 if (chrome.IsEmpty()) { | 83 if (chrome.IsEmpty()) { |
81 chrome = v8::Object::New(isolate); | 84 chrome = v8::Object::New(isolate); |
82 global->Set(gin::StringToV8(isolate, "chrome"), chrome); | 85 global->Set(gin::StringToV8(isolate, "chrome"), chrome); |
83 } | 86 } |
84 chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8()); | 87 chrome->Set(gin::StringToV8(isolate, "skiaBenchmarking"), controller.ToV8()); |
85 } | 88 } |
86 | 89 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 v8::Handle<v8::Object> result = v8::Object::New(isolate); | 304 v8::Handle<v8::Object> result = v8::Object::New(isolate); |
302 result->Set(v8::String::NewFromUtf8(isolate, "width"), | 305 result->Set(v8::String::NewFromUtf8(isolate, "width"), |
303 v8::Number::New(isolate, picture->LayerRect().width())); | 306 v8::Number::New(isolate, picture->LayerRect().width())); |
304 result->Set(v8::String::NewFromUtf8(isolate, "height"), | 307 result->Set(v8::String::NewFromUtf8(isolate, "height"), |
305 v8::Number::New(isolate, picture->LayerRect().height())); | 308 v8::Number::New(isolate, picture->LayerRect().height())); |
306 | 309 |
307 args->Return(result); | 310 args->Return(result); |
308 } | 311 } |
309 | 312 |
310 } // namespace content | 313 } // namespace content |
OLD | NEW |