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

Side by Side Diff: chrome/browser/chromeos/arc/gpu_arc_video_service_host.cc

Issue 2015843002: [mojo-edk] Remove ChildProcessLaunched that returns a pipe handle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another fix. Created 4 years, 7 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 | « no previous file | components/arc/arc_bridge_bootstrap.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h" 5 #include "chrome/browser/chromeos/arc/gpu_arc_video_service_host.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "components/arc/common/video_accelerator.mojom.h" 11 #include "components/arc/common/video_accelerator.mojom.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/gpu_service_registry.h" 13 #include "content/public/browser/gpu_service_registry.h"
14 #include "content/public/common/service_registry.h" 14 #include "content/public/common/service_registry.h"
15 #include "mojo/edk/embedder/embedder.h" 15 #include "mojo/edk/embedder/embedder.h"
16 #include "mojo/edk/embedder/platform_channel_pair.h"
16 17
17 namespace { 18 namespace {
18 19
19 void ConnectToVideoAcceleratorServiceOnIOThread( 20 void ConnectToVideoAcceleratorServiceOnIOThread(
20 arc::mojom::VideoAcceleratorServiceClientRequest request) { 21 arc::mojom::VideoAcceleratorServiceClientRequest request) {
21 content::ServiceRegistry* registry = content::GetGpuServiceRegistry(); 22 content::ServiceRegistry* registry = content::GetGpuServiceRegistry();
22 23
23 // Note |request| is not a ServiceRequest. It is a ClientRequest but doesn't 24 // Note |request| is not a ServiceRequest. It is a ClientRequest but doesn't
24 // request for a Client. Instead, it requests for a Service while specified 25 // request for a Client. Instead, it requests for a Service while specified
25 // the client. It works this odd way because the interfaces were modeled as 26 // the client. It works this odd way because the interfaces were modeled as
(...skipping 25 matching lines...) Expand all
51 video_instance->Init(binding_.CreateInterfacePtrAndBind()); 52 video_instance->Init(binding_.CreateInterfacePtrAndBind());
52 } 53 }
53 54
54 void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel( 55 void GpuArcVideoServiceHost::OnRequestArcVideoAcceleratorChannel(
55 const OnRequestArcVideoAcceleratorChannelCallback& callback) { 56 const OnRequestArcVideoAcceleratorChannelCallback& callback) {
56 DCHECK(thread_checker_.CalledOnValidThread()); 57 DCHECK(thread_checker_.CalledOnValidThread());
57 58
58 // Hardcode pid 0 since it is unused in mojo. 59 // Hardcode pid 0 since it is unused in mojo.
59 const base::ProcessHandle kUnusedChildProcessHandle = 60 const base::ProcessHandle kUnusedChildProcessHandle =
60 base::kNullProcessHandle; 61 base::kNullProcessHandle;
61 mojo::edk::ScopedPlatformHandle child_platform_handle = 62 mojo::edk::PlatformChannelPair channel_pair;
62 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle); 63 mojo::edk::ChildProcessLaunched(kUnusedChildProcessHandle,
64 channel_pair.PassServerHandle());
63 65
64 MojoHandle wrapped_handle; 66 MojoHandle wrapped_handle;
65 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( 67 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper(
66 std::move(child_platform_handle), &wrapped_handle); 68 channel_pair.PassClientHandle(), &wrapped_handle);
67 if (wrap_result != MOJO_RESULT_OK) { 69 if (wrap_result != MOJO_RESULT_OK) {
68 LOG(ERROR) << "Pipe failed to wrap handles. Closing: " << wrap_result; 70 LOG(ERROR) << "Pipe failed to wrap handles. Closing: " << wrap_result;
69 callback.Run(mojo::ScopedHandle(), std::string()); 71 callback.Run(mojo::ScopedHandle(), std::string());
70 return; 72 return;
71 } 73 }
72 mojo::ScopedHandle child_handle{mojo::Handle(wrapped_handle)}; 74 mojo::ScopedHandle child_handle{mojo::Handle(wrapped_handle)};
73 75
74 std::string token = mojo::edk::GenerateRandomToken(); 76 std::string token = mojo::edk::GenerateRandomToken();
75 mojo::ScopedMessagePipeHandle server_pipe = 77 mojo::ScopedMessagePipeHandle server_pipe =
76 mojo::edk::CreateParentMessagePipe(token); 78 mojo::edk::CreateParentMessagePipe(token);
77 if (!server_pipe.is_valid()) { 79 if (!server_pipe.is_valid()) {
78 LOG(ERROR) << "Invalid pipe"; 80 LOG(ERROR) << "Invalid pipe";
79 callback.Run(mojo::ScopedHandle(), std::string()); 81 callback.Run(mojo::ScopedHandle(), std::string());
80 return; 82 return;
81 } 83 }
82 callback.Run(std::move(child_handle), token); 84 callback.Run(std::move(child_handle), token);
83 85
84 content::BrowserThread::PostTask( 86 content::BrowserThread::PostTask(
85 content::BrowserThread::IO, FROM_HERE, 87 content::BrowserThread::IO, FROM_HERE,
86 base::Bind( 88 base::Bind(
87 &ConnectToVideoAcceleratorServiceOnIOThread, 89 &ConnectToVideoAcceleratorServiceOnIOThread,
88 base::Passed( 90 base::Passed(
89 mojo::MakeRequest<::arc::mojom::VideoAcceleratorServiceClient>( 91 mojo::MakeRequest<::arc::mojom::VideoAcceleratorServiceClient>(
90 std::move(server_pipe))))); 92 std::move(server_pipe)))));
91 } 93 }
92 94
93 } // namespace arc 95 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | components/arc/arc_bridge_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698