| 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 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 }; | 302 }; |
| 303 | 303 |
| 304 void OnMicroBenchmarkCompleted(CallbackAndContext* callback_and_context, | 304 void OnMicroBenchmarkCompleted(CallbackAndContext* callback_and_context, |
| 305 std::unique_ptr<base::Value> result) { | 305 std::unique_ptr<base::Value> result) { |
| 306 v8::Isolate* isolate = callback_and_context->isolate(); | 306 v8::Isolate* isolate = callback_and_context->isolate(); |
| 307 v8::HandleScope scope(isolate); | 307 v8::HandleScope scope(isolate); |
| 308 v8::Local<v8::Context> context = callback_and_context->GetContext(); | 308 v8::Local<v8::Context> context = callback_and_context->GetContext(); |
| 309 v8::Context::Scope context_scope(context); | 309 v8::Context::Scope context_scope(context); |
| 310 WebLocalFrame* frame = WebLocalFrame::FrameForContext(context); | 310 WebLocalFrame* frame = WebLocalFrame::FrameForContext(context); |
| 311 if (frame) { | 311 if (frame) { |
| 312 std::unique_ptr<V8ValueConverter> converter = | 312 v8::Local<v8::Value> value = |
| 313 base::WrapUnique(V8ValueConverter::create()); | 313 V8ValueConverter::Create()->ToV8Value(result.get(), context); |
| 314 v8::Local<v8::Value> value = converter->ToV8Value(result.get(), context); | |
| 315 v8::Local<v8::Value> argv[] = { value }; | 314 v8::Local<v8::Value> argv[] = { value }; |
| 316 | 315 |
| 317 frame->CallFunctionEvenIfScriptDisabled(callback_and_context->GetCallback(), | 316 frame->CallFunctionEvenIfScriptDisabled(callback_and_context->GetCallback(), |
| 318 v8::Object::New(isolate), 1, argv); | 317 v8::Object::New(isolate), 1, argv); |
| 319 } | 318 } |
| 320 } | 319 } |
| 321 | 320 |
| 322 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) { | 321 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) { |
| 323 v8::Isolate* isolate = callback_and_context->isolate(); | 322 v8::Isolate* isolate = callback_and_context->isolate(); |
| 324 v8::HandleScope scope(isolate); | 323 v8::HandleScope scope(isolate); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 return false; | 1015 return false; |
| 1017 | 1016 |
| 1018 v8::Local<v8::Function> callback; | 1017 v8::Local<v8::Function> callback; |
| 1019 | 1018 |
| 1020 v8::Local<v8::Object> obj; | 1019 v8::Local<v8::Object> obj; |
| 1021 if (!args->GetNext(&obj)) { | 1020 if (!args->GetNext(&obj)) { |
| 1022 args->ThrowError(); | 1021 args->ThrowError(); |
| 1023 return false; | 1022 return false; |
| 1024 } | 1023 } |
| 1025 | 1024 |
| 1026 std::unique_ptr<V8ValueConverter> converter = | |
| 1027 base::WrapUnique(V8ValueConverter::create()); | |
| 1028 v8::Local<v8::Context> v8_context = | 1025 v8::Local<v8::Context> v8_context = |
| 1029 context.web_frame()->MainWorldScriptContext(); | 1026 context.web_frame()->MainWorldScriptContext(); |
| 1030 std::unique_ptr<base::Value> value = converter->FromV8Value(obj, v8_context); | 1027 std::unique_ptr<base::Value> value = |
| 1028 V8ValueConverter::Create()->FromV8Value(obj, v8_context); |
| 1031 | 1029 |
| 1032 // Get all the pointer actions from the user input and wrap them into a | 1030 // Get all the pointer actions from the user input and wrap them into a |
| 1033 // SyntheticPointerActionListParams object. | 1031 // SyntheticPointerActionListParams object. |
| 1034 ActionsParser actions_parser(value.get()); | 1032 ActionsParser actions_parser(value.get()); |
| 1035 if (!actions_parser.ParsePointerActionSequence()) | 1033 if (!actions_parser.ParsePointerActionSequence()) |
| 1036 return false; | 1034 return false; |
| 1037 | 1035 |
| 1038 std::unique_ptr<SyntheticPointerActionListParams> gesture_params = | 1036 std::unique_ptr<SyntheticPointerActionListParams> gesture_params = |
| 1039 actions_parser.gesture_params(); | 1037 actions_parser.gesture_params(); |
| 1040 | 1038 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 | 1070 |
| 1073 if (!GetArg(args, &name) || !GetArg(args, &callback) || | 1071 if (!GetArg(args, &name) || !GetArg(args, &callback) || |
| 1074 !GetOptionalArg(args, &arguments)) { | 1072 !GetOptionalArg(args, &arguments)) { |
| 1075 return 0; | 1073 return 0; |
| 1076 } | 1074 } |
| 1077 | 1075 |
| 1078 scoped_refptr<CallbackAndContext> callback_and_context = | 1076 scoped_refptr<CallbackAndContext> callback_and_context = |
| 1079 new CallbackAndContext(args->isolate(), callback, | 1077 new CallbackAndContext(args->isolate(), callback, |
| 1080 context.web_frame()->MainWorldScriptContext()); | 1078 context.web_frame()->MainWorldScriptContext()); |
| 1081 | 1079 |
| 1082 std::unique_ptr<V8ValueConverter> converter = | |
| 1083 base::WrapUnique(V8ValueConverter::create()); | |
| 1084 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); | 1080 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); |
| 1085 std::unique_ptr<base::Value> value = | 1081 std::unique_ptr<base::Value> value = |
| 1086 converter->FromV8Value(arguments, v8_context); | 1082 V8ValueConverter::Create()->FromV8Value(arguments, v8_context); |
| 1087 | 1083 |
| 1088 return context.compositor()->ScheduleMicroBenchmark( | 1084 return context.compositor()->ScheduleMicroBenchmark( |
| 1089 name, std::move(value), | 1085 name, std::move(value), |
| 1090 base::Bind(&OnMicroBenchmarkCompleted, | 1086 base::Bind(&OnMicroBenchmarkCompleted, |
| 1091 base::RetainedRef(callback_and_context))); | 1087 base::RetainedRef(callback_and_context))); |
| 1092 } | 1088 } |
| 1093 | 1089 |
| 1094 bool GpuBenchmarking::SendMessageToMicroBenchmark( | 1090 bool GpuBenchmarking::SendMessageToMicroBenchmark( |
| 1095 int id, | 1091 int id, |
| 1096 v8::Local<v8::Object> message) { | 1092 v8::Local<v8::Object> message) { |
| 1097 GpuBenchmarkingContext context; | 1093 GpuBenchmarkingContext context; |
| 1098 if (!context.Init(true)) | 1094 if (!context.Init(true)) |
| 1099 return false; | 1095 return false; |
| 1100 | 1096 |
| 1101 std::unique_ptr<V8ValueConverter> converter = | |
| 1102 base::WrapUnique(V8ValueConverter::create()); | |
| 1103 v8::Local<v8::Context> v8_context = | 1097 v8::Local<v8::Context> v8_context = |
| 1104 context.web_frame()->MainWorldScriptContext(); | 1098 context.web_frame()->MainWorldScriptContext(); |
| 1105 std::unique_ptr<base::Value> value = | 1099 std::unique_ptr<base::Value> value = |
| 1106 converter->FromV8Value(message, v8_context); | 1100 V8ValueConverter::Create()->FromV8Value(message, v8_context); |
| 1107 | 1101 |
| 1108 return context.compositor()->SendMessageToMicroBenchmark(id, | 1102 return context.compositor()->SendMessageToMicroBenchmark(id, |
| 1109 std::move(value)); | 1103 std::move(value)); |
| 1110 } | 1104 } |
| 1111 | 1105 |
| 1112 bool GpuBenchmarking::HasGpuChannel() { | 1106 bool GpuBenchmarking::HasGpuChannel() { |
| 1113 gpu::GpuChannelHost* gpu_channel = | 1107 gpu::GpuChannelHost* gpu_channel = |
| 1114 RenderThreadImpl::current()->GetGpuChannel(); | 1108 RenderThreadImpl::current()->GetGpuChannel(); |
| 1115 return !!gpu_channel; | 1109 return !!gpu_channel; |
| 1116 } | 1110 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1133 &gpu_driver_bug_workarounds))) { | 1127 &gpu_driver_bug_workarounds))) { |
| 1134 return; | 1128 return; |
| 1135 } | 1129 } |
| 1136 | 1130 |
| 1137 v8::Local<v8::Value> result; | 1131 v8::Local<v8::Value> result; |
| 1138 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1132 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
| 1139 args->Return(result); | 1133 args->Return(result); |
| 1140 } | 1134 } |
| 1141 | 1135 |
| 1142 } // namespace content | 1136 } // namespace content |
| OLD | NEW |