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

Unified Diff: content/browser/browser_io_surface_manager_mac.h

Issue 1137453002: content: Pass IOSurface references using Mach IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_io_surface_manager_mac.h
diff --git a/content/browser/browser_io_surface_manager_mac.h b/content/browser/browser_io_surface_manager_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..58b17b415d02621478b26637704e594427099f9a
--- /dev/null
+++ b/content/browser/browser_io_surface_manager_mac.h
@@ -0,0 +1,104 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_
+#define CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_
+
+#include <mach/mach.h>
+
+#include <map>
+#include <set>
+#include <utility>
+
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/mac/dispatch_source_mach.h"
+#include "base/mac/scoped_mach_port.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/singleton.h"
+#include "base/synchronization/lock.h"
+#include "content/common/mac/io_surface_manager.h"
+#include "gpu/command_buffer/common/mailbox.h"
+
+namespace content {
+
+// Implementation of IOSurfaceManager that provides a mechanism for child
+// processes to register and acquire IOSurfaces through Mach IPC.
+class CONTENT_EXPORT BrowserIOSurfaceManager : public IOSurfaceManager {
+ public:
+ // Returns the global BrowserIOSurfaceManager.
+ static BrowserIOSurfaceManager* GetInstance();
+
+ // Overridden from IOSurfaceManager:
+ bool RegisterIOSurface(int io_surface_id,
+ int client_id,
+ IOSurfaceRef io_surface) override;
+ void UnregisterIOSurface(int io_surface_id, int client_id) override;
+ IOSurfaceRef AcquireIOSurface(int io_surface_id) override;
+
+ // Generate a unique unguessable mailbox name that a child process can use to
+ // acquire IOSurface references.
Robert Sesek 2015/05/15 21:45:05 |client_id| is the ___.
reveman 2015/05/18 18:15:38 Done.
+ gpu::Mailbox GenerateChildProcessMailbox(int client_id);
+
+ // Invalidate a previously generated mailbox name.
+ void InvalidateChildProcessMailbox(const gpu::Mailbox& mailbox);
+
+ // Get a unique unguessable mailbox name that each GPU process can
Robert Sesek 2015/05/15 21:45:05 a -> the, otherwise it's hard to understand why th
reveman 2015/05/18 18:15:38 Done. Also changed the language to say "the" inste
+ // use to register/unregister IOSurface for use by clients.
+ gpu::Mailbox GetGpuProcessMailbox() const;
+
+ private:
+ friend struct DefaultSingletonTraits<BrowserIOSurfaceManager>;
+
+ BrowserIOSurfaceManager();
+ ~BrowserIOSurfaceManager() override;
+
+ // Message handler that is invoked on |dispatch_source_| when an
+ // incoming message needs to be received.
+ void HandleRequest();
+
+ // Mach message handlers.
+ void OnRegisterIOSurface(const mach_msg_header_t& header,
+ int io_surface_id,
+ int client_id,
+ mach_port_t io_surface_port,
+ const gpu::Mailbox& gpu_process_mailbox);
+ void OnUnregisterIOSurface(const mach_msg_header_t& header,
+ int io_surface_id,
+ int client_id,
+ const gpu::Mailbox& gpu_process_mailbox);
+ void OnAcquireIOSurface(const mach_msg_header_t& header,
+ int io_surface_id,
+ const gpu::Mailbox& gpu_process_mailbox);
+
+ // The Mach port on which the server listens.
+ base::mac::ScopedMachReceiveRight server_port_;
+
+ // The dispatch source and queue on which Mach messages will be received.
+ scoped_ptr<base::DispatchSourceMach> dispatch_source_;
+
+ // Stores the IOSurfces for all GPU clients.
+ typedef std::pair<int, int> IOSurfaceMapKey;
Robert Sesek 2015/05/15 21:45:05 using IOSurfaceMapKey = std::pair<int, int>;
reveman 2015/05/18 18:15:38 Done.
+ typedef base::ScopedPtrHashMap<IOSurfaceMapKey,
Robert Sesek 2015/05/15 21:45:05 using IOSurfaceMap = ...;
reveman 2015/05/18 18:15:38 Done.
+ scoped_ptr<base::mac::ScopedMachSendRight>>
+ IOSurfaceMap;
+ IOSurfaceMap io_surfaces_;
+
+ // Stores the Child process unique id (RenderProcessHost ID) for every
+ // mailbox.
+ typedef std::map<gpu::Mailbox, int> ChildProcessIdMap;
+ ChildProcessIdMap child_process_ids_;
+
+ // Stores the GPU process mailbox.
+ gpu::Mailbox gpu_process_mailbox_;
+
+ // Mutex that guards |io_surfaces_|, |child_process_ids_| and
+ // |gpu_process_mailbox_|.
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserIOSurfaceManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698