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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_
6 #define CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_
7
8 #include <mach/mach.h>
9
10 #include <map>
11 #include <set>
12 #include <utility>
13
14 #include "base/containers/scoped_ptr_hash_map.h"
15 #include "base/mac/dispatch_source_mach.h"
16 #include "base/mac/scoped_mach_port.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/singleton.h"
19 #include "base/synchronization/lock.h"
20 #include "content/common/mac/io_surface_manager.h"
21 #include "gpu/command_buffer/common/mailbox.h"
22
23 namespace content {
24
25 // Implementation of IOSurfaceManager that provides a mechanism for child
26 // processes to register and acquire IOSurfaces through Mach IPC.
27 class CONTENT_EXPORT BrowserIOSurfaceManager : public IOSurfaceManager {
28 public:
29 // Returns the global BrowserIOSurfaceManager.
30 static BrowserIOSurfaceManager* GetInstance();
31
32 // Overridden from IOSurfaceManager:
33 bool RegisterIOSurface(int io_surface_id,
34 int client_id,
35 IOSurfaceRef io_surface) override;
36 void UnregisterIOSurface(int io_surface_id, int client_id) override;
37 IOSurfaceRef AcquireIOSurface(int io_surface_id) override;
38
39 // Generate a unique unguessable mailbox name that a child process can use to
40 // acquire IOSurface references.
Robert Sesek 2015/05/15 21:45:05 |client_id| is the ___.
reveman 2015/05/18 18:15:38 Done.
41 gpu::Mailbox GenerateChildProcessMailbox(int client_id);
42
43 // Invalidate a previously generated mailbox name.
44 void InvalidateChildProcessMailbox(const gpu::Mailbox& mailbox);
45
46 // 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
47 // use to register/unregister IOSurface for use by clients.
48 gpu::Mailbox GetGpuProcessMailbox() const;
49
50 private:
51 friend struct DefaultSingletonTraits<BrowserIOSurfaceManager>;
52
53 BrowserIOSurfaceManager();
54 ~BrowserIOSurfaceManager() override;
55
56 // Message handler that is invoked on |dispatch_source_| when an
57 // incoming message needs to be received.
58 void HandleRequest();
59
60 // Mach message handlers.
61 void OnRegisterIOSurface(const mach_msg_header_t& header,
62 int io_surface_id,
63 int client_id,
64 mach_port_t io_surface_port,
65 const gpu::Mailbox& gpu_process_mailbox);
66 void OnUnregisterIOSurface(const mach_msg_header_t& header,
67 int io_surface_id,
68 int client_id,
69 const gpu::Mailbox& gpu_process_mailbox);
70 void OnAcquireIOSurface(const mach_msg_header_t& header,
71 int io_surface_id,
72 const gpu::Mailbox& gpu_process_mailbox);
73
74 // The Mach port on which the server listens.
75 base::mac::ScopedMachReceiveRight server_port_;
76
77 // The dispatch source and queue on which Mach messages will be received.
78 scoped_ptr<base::DispatchSourceMach> dispatch_source_;
79
80 // Stores the IOSurfces for all GPU clients.
81 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.
82 typedef base::ScopedPtrHashMap<IOSurfaceMapKey,
Robert Sesek 2015/05/15 21:45:05 using IOSurfaceMap = ...;
reveman 2015/05/18 18:15:38 Done.
83 scoped_ptr<base::mac::ScopedMachSendRight>>
84 IOSurfaceMap;
85 IOSurfaceMap io_surfaces_;
86
87 // Stores the Child process unique id (RenderProcessHost ID) for every
88 // mailbox.
89 typedef std::map<gpu::Mailbox, int> ChildProcessIdMap;
90 ChildProcessIdMap child_process_ids_;
91
92 // Stores the GPU process mailbox.
93 gpu::Mailbox gpu_process_mailbox_;
94
95 // Mutex that guards |io_surfaces_|, |child_process_ids_| and
96 // |gpu_process_mailbox_|.
97 mutable base::Lock lock_;
98
99 DISALLOW_COPY_AND_ASSIGN(BrowserIOSurfaceManager);
100 };
101
102 } // namespace content
103
104 #endif // CONTENT_BROWSER_BROWSER_IO_SURFACE_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698