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

Side by Side Diff: components/mus/common/gpu_service.cc

Issue 2084993002: Mojo: add support for disallowing sync calls for a process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 | « base/threading/thread_restrictions.h ('k') | content/browser/browser_main_loop.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 "components/mus/common/gpu_service.h" 5 #include "components/mus/common/gpu_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/threading/thread_restrictions.h"
10 #include "components/mus/common/gpu_type_converters.h" 9 #include "components/mus/common/gpu_type_converters.h"
11 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" 10 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
12 #include "components/mus/common/switches.h" 11 #include "components/mus/common/switches.h"
13 #include "components/mus/public/interfaces/gpu_service.mojom.h" 12 #include "components/mus/public/interfaces/gpu_service.mojom.h"
13 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
14 #include "mojo/public/cpp/system/platform_handle.h" 14 #include "mojo/public/cpp/system/platform_handle.h"
15 #include "services/shell/public/cpp/connector.h" 15 #include "services/shell/public/cpp/connector.h"
16 16
17 namespace mus { 17 namespace mus {
18 18
19 GpuService::GpuService() 19 GpuService::GpuService()
20 : main_message_loop_(base::MessageLoop::current()), 20 : main_message_loop_(base::MessageLoop::current()),
21 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 21 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
22 base::WaitableEvent::InitialState::NOT_SIGNALED), 22 base::WaitableEvent::InitialState::NOT_SIGNALED),
23 io_thread_("GPUIOThread"), 23 io_thread_("GPUIOThread"),
(...skipping 28 matching lines...) Expand all
52 if (gpu_channel_) 52 if (gpu_channel_)
53 return gpu_channel_; 53 return gpu_channel_;
54 54
55 mus::mojom::GpuServicePtr gpu_service; 55 mus::mojom::GpuServicePtr gpu_service;
56 connector->ConnectToInterface("mojo:mus", &gpu_service); 56 connector->ConnectToInterface("mojo:mus", &gpu_service);
57 57
58 int client_id = 0; 58 int client_id = 0;
59 mojom::ChannelHandlePtr channel_handle; 59 mojom::ChannelHandlePtr channel_handle;
60 mojom::GpuInfoPtr gpu_info; 60 mojom::GpuInfoPtr gpu_info;
61 { 61 {
62 // TODO(penghuang): Remove the ScopedAllowWait when HW rendering is enabled 62 // TODO(penghuang): Remove the ScopedAllowSyncCall when HW rendering is
63 // in mus chrome. 63 // enabled in mus chrome.
64 base::ThreadRestrictions::ScopedAllowWait allow_wait; 64 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
65 if (!gpu_service->EstablishGpuChannel(&client_id, &channel_handle, 65 if (!gpu_service->EstablishGpuChannel(&client_id, &channel_handle,
66 &gpu_info)) { 66 &gpu_info)) {
67 DLOG(WARNING) 67 DLOG(WARNING)
68 << "Channel encountered error while establishing gpu channel."; 68 << "Channel encountered error while establishing gpu channel.";
69 return nullptr; 69 return nullptr;
70 } 70 }
71 } 71 }
72 72
73 // TODO(penghuang): Get the real gpu info from mus. 73 // TODO(penghuang): Get the real gpu info from mus.
74 gpu_channel_ = gpu::GpuChannelHost::Create( 74 gpu_channel_ = gpu::GpuChannelHost::Create(
(...skipping 25 matching lines...) Expand all
100 result = mojo::UnwrapSharedMemoryHandle(std::move(handle), &platform_handle, 100 result = mojo::UnwrapSharedMemoryHandle(std::move(handle), &platform_handle,
101 &shared_memory_size, &readonly); 101 &shared_memory_size, &readonly);
102 if (result != MOJO_RESULT_OK) 102 if (result != MOJO_RESULT_OK)
103 return nullptr; 103 return nullptr;
104 DCHECK_EQ(shared_memory_size, size); 104 DCHECK_EQ(shared_memory_size, size);
105 105
106 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); 106 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
107 } 107 }
108 108
109 } // namespace mus 109 } // namespace mus
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698