| 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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 903 |
| 904 scoped_refptr<CallbackAndContext> callback_and_context = | 904 scoped_refptr<CallbackAndContext> callback_and_context = |
| 905 new CallbackAndContext(args->isolate(), | 905 new CallbackAndContext(args->isolate(), |
| 906 callback, | 906 callback, |
| 907 context.web_frame()->mainWorldScriptContext()); | 907 context.web_frame()->mainWorldScriptContext()); |
| 908 | 908 |
| 909 std::unique_ptr<V8ValueConverter> converter = | 909 std::unique_ptr<V8ValueConverter> converter = |
| 910 base::WrapUnique(V8ValueConverter::create()); | 910 base::WrapUnique(V8ValueConverter::create()); |
| 911 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); | 911 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); |
| 912 std::unique_ptr<base::Value> value = | 912 std::unique_ptr<base::Value> value = |
| 913 base::WrapUnique(converter->FromV8Value(arguments, v8_context)); | 913 converter->FromV8Value(arguments, v8_context); |
| 914 | 914 |
| 915 return context.compositor()->ScheduleMicroBenchmark( | 915 return context.compositor()->ScheduleMicroBenchmark( |
| 916 name, std::move(value), | 916 name, std::move(value), |
| 917 base::Bind(&OnMicroBenchmarkCompleted, | 917 base::Bind(&OnMicroBenchmarkCompleted, |
| 918 base::RetainedRef(callback_and_context))); | 918 base::RetainedRef(callback_and_context))); |
| 919 } | 919 } |
| 920 | 920 |
| 921 bool GpuBenchmarking::SendMessageToMicroBenchmark( | 921 bool GpuBenchmarking::SendMessageToMicroBenchmark( |
| 922 int id, | 922 int id, |
| 923 v8::Local<v8::Object> message) { | 923 v8::Local<v8::Object> message) { |
| 924 GpuBenchmarkingContext context; | 924 GpuBenchmarkingContext context; |
| 925 if (!context.Init(true)) | 925 if (!context.Init(true)) |
| 926 return false; | 926 return false; |
| 927 | 927 |
| 928 std::unique_ptr<V8ValueConverter> converter = | 928 std::unique_ptr<V8ValueConverter> converter = |
| 929 base::WrapUnique(V8ValueConverter::create()); | 929 base::WrapUnique(V8ValueConverter::create()); |
| 930 v8::Local<v8::Context> v8_context = | 930 v8::Local<v8::Context> v8_context = |
| 931 context.web_frame()->mainWorldScriptContext(); | 931 context.web_frame()->mainWorldScriptContext(); |
| 932 std::unique_ptr<base::Value> value = | 932 std::unique_ptr<base::Value> value = |
| 933 base::WrapUnique(converter->FromV8Value(message, v8_context)); | 933 converter->FromV8Value(message, v8_context); |
| 934 | 934 |
| 935 return context.compositor()->SendMessageToMicroBenchmark(id, | 935 return context.compositor()->SendMessageToMicroBenchmark(id, |
| 936 std::move(value)); | 936 std::move(value)); |
| 937 } | 937 } |
| 938 | 938 |
| 939 bool GpuBenchmarking::HasGpuChannel() { | 939 bool GpuBenchmarking::HasGpuChannel() { |
| 940 gpu::GpuChannelHost* gpu_channel = | 940 gpu::GpuChannelHost* gpu_channel = |
| 941 RenderThreadImpl::current()->GetGpuChannel(); | 941 RenderThreadImpl::current()->GetGpuChannel(); |
| 942 return !!gpu_channel; | 942 return !!gpu_channel; |
| 943 } | 943 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 959 &gpu_driver_bug_workarounds))) { | 959 &gpu_driver_bug_workarounds))) { |
| 960 return; | 960 return; |
| 961 } | 961 } |
| 962 | 962 |
| 963 v8::Local<v8::Value> result; | 963 v8::Local<v8::Value> result; |
| 964 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 964 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
| 965 args->Return(result); | 965 args->Return(result); |
| 966 } | 966 } |
| 967 | 967 |
| 968 } // namespace content | 968 } // namespace content |
| OLD | NEW |