| OLD | NEW |
| (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_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | |
| 6 #define CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | |
| 7 | |
| 8 #include "base/mac/scoped_mach_port.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/singleton.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 #include "content/common/mac/io_surface_manager_token.h" | |
| 13 #include "ui/gfx/mac/io_surface_manager.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 // Implementation of IOSurfaceManager that registers and acquires IOSurfaces | |
| 18 // through a Mach service. | |
| 19 class CONTENT_EXPORT ChildIOSurfaceManager : public gfx::IOSurfaceManager { | |
| 20 public: | |
| 21 // Returns the global ChildIOSurfaceManager. | |
| 22 static ChildIOSurfaceManager* GetInstance(); | |
| 23 | |
| 24 // Overridden from IOSurfaceManager: | |
| 25 bool RegisterIOSurface(gfx::IOSurfaceId io_surface_id, | |
| 26 int client_id, | |
| 27 IOSurfaceRef io_surface) override; | |
| 28 void UnregisterIOSurface(gfx::IOSurfaceId io_surface_id, | |
| 29 int client_id) override; | |
| 30 IOSurfaceRef AcquireIOSurface(gfx::IOSurfaceId io_surface_id) override; | |
| 31 | |
| 32 // Set the service Mach port. Ownership of |service_port| is passed to the | |
| 33 // manager. | |
| 34 // Note: This can be called on any thread but must happen before the | |
| 35 // thread-safe IOSurfaceManager interface is used. It is the responsibility | |
| 36 // of users of this class to ensure there are no races. | |
| 37 void set_service_port(mach_port_t service_port) { | |
| 38 service_port_.reset(service_port); | |
| 39 } | |
| 40 | |
| 41 // Set the token used when communicating with the Mach service. | |
| 42 // Note: This can be called on any thread but must happen before the | |
| 43 // thread-safe IOSurfaceManager interface is used. It is the responsibility | |
| 44 // of users of this class to ensure there are no races. | |
| 45 void set_token(const IOSurfaceManagerToken& token) { | |
| 46 token_ = token; | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 friend struct base::DefaultSingletonTraits<ChildIOSurfaceManager>; | |
| 51 | |
| 52 ChildIOSurfaceManager(); | |
| 53 ~ChildIOSurfaceManager() override; | |
| 54 | |
| 55 base::mac::ScopedMachSendRight service_port_; | |
| 56 IOSurfaceManagerToken token_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(ChildIOSurfaceManager); | |
| 59 }; | |
| 60 | |
| 61 } // namespace content | |
| 62 | |
| 63 #endif // CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | |
| OLD | NEW |