| Index: services/ui/gpu/gpu_service_internal.cc
|
| diff --git a/services/ui/gpu/gpu_service_internal.cc b/services/ui/gpu/gpu_service_internal.cc
|
| index 04378656cf5d852be1c1ad9bc6c78136c890afd9..1a567d4879a27cdecb19ffb33151b44ce5d2661c 100644
|
| --- a/services/ui/gpu/gpu_service_internal.cc
|
| +++ b/services/ui/gpu/gpu_service_internal.cc
|
| @@ -46,7 +46,8 @@ void EstablishGpuChannelDone(
|
| const GpuServiceInternal::EstablishGpuChannelCallback& callback) {
|
| callback.Run(client_id, std::move(*channel_handle));
|
| }
|
| -}
|
| +
|
| +} // namespace
|
|
|
| GpuServiceInternal::GpuServiceInternal()
|
| : next_client_id_(kLocalGpuChannelClientId),
|
| @@ -54,8 +55,8 @@ GpuServiceInternal::GpuServiceInternal()
|
| shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
|
| base::WaitableEvent::InitialState::NOT_SIGNALED),
|
| gpu_thread_("GpuThread"),
|
| - io_thread_("GpuIOThread") {
|
| - Initialize();
|
| + io_thread_("GpuIOThread"),
|
| + binding_(this) {
|
| }
|
|
|
| GpuServiceInternal::~GpuServiceInternal() {
|
| @@ -67,7 +68,11 @@ GpuServiceInternal::~GpuServiceInternal() {
|
| io_thread_.Stop();
|
| }
|
|
|
| -void GpuServiceInternal::EstablishGpuChannel(
|
| +void GpuServiceInternal::Add(mojom::GpuServiceInternalRequest request) {
|
| + binding_.Bind(std::move(request));
|
| +}
|
| +
|
| +void GpuServiceInternal::EstablishGpuChannelInternal(
|
| uint64_t client_tracing_id,
|
| bool preempts,
|
| bool allow_view_command_buffers,
|
| @@ -156,37 +161,6 @@ void GpuServiceInternal::SetActiveURL(const GURL& url) {
|
| // TODO(penghuang): implement this function.
|
| }
|
|
|
| -void GpuServiceInternal::Initialize() {
|
| - DCHECK(CalledOnValidThread());
|
| - base::Thread::Options thread_options(base::MessageLoop::TYPE_DEFAULT, 0);
|
| - thread_options.priority = base::ThreadPriority::NORMAL;
|
| - CHECK(gpu_thread_.StartWithOptions(thread_options));
|
| -
|
| - thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
|
| - thread_options.priority = base::ThreadPriority::NORMAL;
|
| -#if defined(OS_ANDROID)
|
| - // TODO(reveman): Remove this in favor of setting it explicitly for each type
|
| - // of process.
|
| - thread_options.priority = base::ThreadPriority::DISPLAY;
|
| -#endif
|
| - CHECK(io_thread_.StartWithOptions(thread_options));
|
| -
|
| - mojo::ScopedMessagePipeHandle channel_handle;
|
| - base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
|
| - base::WaitableEvent::InitialState::NOT_SIGNALED);
|
| - gpu_thread_.task_runner()->PostTask(
|
| - FROM_HERE, base::Bind(&GpuServiceInternal::InitializeOnGpuThread,
|
| - base::Unretained(this), &channel_handle, &event));
|
| - event.Wait();
|
| -
|
| - gpu_memory_buffer_manager_local_.reset(
|
| - new MusGpuMemoryBufferManager(this, kLocalGpuChannelClientId));
|
| - gpu_channel_local_ = gpu::GpuChannelHost::Create(
|
| - this, kLocalGpuChannelClientId, gpu_info_,
|
| - IPC::ChannelHandle(channel_handle.release()), &shutdown_event_,
|
| - gpu_memory_buffer_manager_local_.get());
|
| -}
|
| -
|
| void GpuServiceInternal::InitializeOnGpuThread(
|
| mojo::ScopedMessagePipeHandle* channel_handle,
|
| base::WaitableEvent* event) {
|
| @@ -271,6 +245,55 @@ std::unique_ptr<base::SharedMemory> GpuServiceInternal::AllocateSharedMemory(
|
| return shm;
|
| }
|
|
|
| +void GpuServiceInternal::Initialize(const InitializeCallback& callback) {
|
| + DCHECK(CalledOnValidThread());
|
| + base::Thread::Options thread_options(base::MessageLoop::TYPE_DEFAULT, 0);
|
| + thread_options.priority = base::ThreadPriority::NORMAL;
|
| + CHECK(gpu_thread_.StartWithOptions(thread_options));
|
| +
|
| + thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
|
| + thread_options.priority = base::ThreadPriority::NORMAL;
|
| +#if defined(OS_ANDROID)
|
| + // TODO(reveman): Remove this in favor of setting it explicitly for each type
|
| + // of process.
|
| + thread_options.priority = base::ThreadPriority::DISPLAY;
|
| +#endif
|
| + CHECK(io_thread_.StartWithOptions(thread_options));
|
| +
|
| + mojo::ScopedMessagePipeHandle channel_handle;
|
| + base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
|
| + base::WaitableEvent::InitialState::NOT_SIGNALED);
|
| + gpu_thread_.task_runner()->PostTask(
|
| + FROM_HERE, base::Bind(&GpuServiceInternal::InitializeOnGpuThread,
|
| + base::Unretained(this), &channel_handle, &event));
|
| + event.Wait();
|
| +
|
| + gpu_memory_buffer_manager_local_.reset(
|
| + new MusGpuMemoryBufferManager(this, kLocalGpuChannelClientId));
|
| + gpu_channel_local_ = gpu::GpuChannelHost::Create(
|
| + this, kLocalGpuChannelClientId, gpu_info_,
|
| + IPC::ChannelHandle(channel_handle.release()), &shutdown_event_,
|
| + gpu_memory_buffer_manager_local_.get());
|
| +
|
| + // TODO(sad): Get the real GPUInfo.
|
| + callback.Run(gpu_info_);
|
| +}
|
| +
|
| +void GpuServiceInternal::EstablishGpuChannel(
|
| + const EstablishGpuChannelCallback& callback) {
|
| + // TODO(penghuang): crbug.com/617415 figure out how to generate a meaningful
|
| + // tracing id.
|
| + const uint64_t client_tracing_id = 0;
|
| + // TODO(penghuang): windows server may want to control those flags.
|
| + // Add a private interface for windows server.
|
| + const bool preempts = false;
|
| + const bool allow_view_command_buffers = false;
|
| + const bool allow_real_time_streams = false;
|
| + EstablishGpuChannelInternal(client_tracing_id, preempts,
|
| + allow_view_command_buffers,
|
| + allow_real_time_streams, callback);
|
| +}
|
| +
|
| // static
|
| GpuServiceInternal* GpuServiceInternal::GetInstance() {
|
| return base::Singleton<GpuServiceInternal,
|
|
|