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

Unified Diff: content/browser/gpu/browser_client_native_pixmap_manager_ozone.cc

Issue 1248713002: ozone: ClientPixmapManager passes VGEM fd from browser to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to latest crrev.com/1128113011 Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/gpu/browser_client_native_pixmap_manager_ozone.cc
diff --git a/content/browser/gpu/browser_client_native_pixmap_manager_ozone.cc b/content/browser/gpu/browser_client_native_pixmap_manager_ozone.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eaf5290de2c2e75202730b269b66c6b2e59776c6
--- /dev/null
+++ b/content/browser/gpu/browser_client_native_pixmap_manager_ozone.cc
@@ -0,0 +1,84 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/gpu/browser_client_native_pixmap_manager_ozone.h"
+
+#include "base/memory/singleton.h"
+#include "base/posix/eintr_wrapper.h"
+#include "content/common/gpu/client_native_pixmap_manager_ozone_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "ui/ozone/public/ozone_platform.h"
+
+namespace content {
+
+namespace {
+
+base::FileDescriptor DupVirtualDeviceFd(int virtual_device) {
+ int duped_fd = -1;
+ base::ThreadRestrictions::AssertIOAllowed();
+ duped_fd = HANDLE_EINTR(dup(virtual_device));
+ if (duped_fd < 0) {
+ PLOG(ERROR) << "dup() failed.";
+ return base::FileDescriptor();
+ }
+ return base::FileDescriptor(duped_fd, true);
+}
+
+void OnSendVirtualDevice(IPC::Sender* sender,
+ const base::FileDescriptor& virtual_device) {
+ sender->Send(
+ new ChildClientNativePixmapManagerMsg_SetVirtualDevice(virtual_device));
+}
+
+} // namespace
+
+struct BrowserClientNativePixmapManagerTrait
+ : public DefaultSingletonTraits<BrowserClientNativePixmapManager> {
+ static BrowserClientNativePixmapManager* New() {
+ BrowserClientNativePixmapManager* manager =
+ new BrowserClientNativePixmapManager();
+ manager->Initialize(ui::OzonePlatform::GetInstance()->GetVirtualDeviceFd());
+ return manager;
+ }
+};
+
+// static
+BrowserClientNativePixmapManager*
+BrowserClientNativePixmapManager::GetInstance() {
+ return Singleton<BrowserClientNativePixmapManager,
+ BrowserClientNativePixmapManagerTrait>::get();
+}
+
+BrowserClientNativePixmapManager::BrowserClientNativePixmapManager() {}
+
+BrowserClientNativePixmapManager::~BrowserClientNativePixmapManager() {}
+
+void BrowserClientNativePixmapManager::Initialize(
+ const base::FileDescriptor& virtual_device) {
+ pixmap_manager_ = ui::ClientNativePixmapManager::Create(virtual_device);
+ virtual_device_ = virtual_device;
+}
+
+void BrowserClientNativePixmapManager::SendVirtualDevice(IPC::Sender* sender) {
+ base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
+ base::PostTaskAndReplyWithResult(
+ pool, FROM_HERE, base::Bind(&DupVirtualDeviceFd, virtual_device_.fd),
spang 2015/08/04 17:47:31 I'm pretty sure that passing access to vgem by dup
dshwang 2015/08/05 09:44:26 I don't fully catch up which point is vulnerable f
+ base::Bind(&OnSendVirtualDevice, sender));
+}
+
+std::vector<ui::ClientNativePixmapManager::Configuration>
+BrowserClientNativePixmapManager::GetSupportedConfigurations() const {
+ return pixmap_manager_->GetSupportedConfigurations();
+}
+
+scoped_ptr<ui::ClientNativePixmap>
+BrowserClientNativePixmapManager::ImportClientNativePixmap(
+ base::FileDescriptor handle,
+ gfx::Size size,
+ ui::NativePixmapFormat format,
+ ui::NativePixmapUsage usage) {
+ return pixmap_manager_->ImportClientNativePixmap(handle, size, format, usage);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698