OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | 5 #ifndef CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ |
6 #define CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | 6 #define CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ |
7 | 7 |
8 #include "base/mac/scoped_mach_port.h" | 8 #include "base/mac/scoped_mach_port.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/synchronization/waitable_event.h" | |
12 #include "base/threading/platform_thread.h" | |
13 #include "content/common/mac/io_surface_manager.h" | 11 #include "content/common/mac/io_surface_manager.h" |
14 #include "content/common/mac/io_surface_manager_token.h" | 12 #include "content/common/mac/io_surface_manager_token.h" |
15 | 13 |
16 namespace content { | 14 namespace content { |
17 | 15 |
18 // Implementation of IOSurfaceManager that registers and acquires IOSurfaces | 16 // Implementation of IOSurfaceManager that registers and acquires IOSurfaces |
19 // through a Mach service. | 17 // through a Mach service. |
20 class CONTENT_EXPORT ChildIOSurfaceManager : public IOSurfaceManager { | 18 class CONTENT_EXPORT ChildIOSurfaceManager : public IOSurfaceManager { |
21 public: | 19 public: |
22 // Returns the global ChildIOSurfaceManager. | 20 // Returns the global ChildIOSurfaceManager. |
23 static ChildIOSurfaceManager* GetInstance(); | 21 static ChildIOSurfaceManager* GetInstance(); |
24 | 22 |
25 // Overridden from IOSurfaceManager: | 23 // Overridden from IOSurfaceManager: |
26 bool RegisterIOSurface(IOSurfaceId io_surface_id, | 24 bool RegisterIOSurface(IOSurfaceId io_surface_id, |
27 int client_id, | 25 int client_id, |
28 IOSurfaceRef io_surface) override; | 26 IOSurfaceRef io_surface) override; |
29 void UnregisterIOSurface(IOSurfaceId io_surface_id, int client_id) override; | 27 void UnregisterIOSurface(IOSurfaceId io_surface_id, int client_id) override; |
30 IOSurfaceRef AcquireIOSurface(IOSurfaceId io_surface_id) override; | 28 IOSurfaceRef AcquireIOSurface(IOSurfaceId io_surface_id) override; |
31 | 29 |
32 // Set the service Mach port. Ownership of |service_port| is passed to the | 30 // Set the service Mach port. Ownership of |service_port| is passed to the |
33 // manager. | 31 // manager. |
34 void set_service_port(mach_port_t service_port) { | 32 void set_service_port(mach_port_t service_port) { |
35 service_port_.reset(service_port); | 33 service_port_.reset(service_port); |
36 } | 34 } |
37 | 35 |
38 // Set the token used when communicating with the Mach service. | 36 // Set the token used when communicating with the Mach service. |
39 void set_token(const IOSurfaceManagerToken& token) { | 37 void set_token(const IOSurfaceManagerToken& token) { |
40 token_ = token; | 38 token_ = token; |
dshwang
2015/08/26 13:07:18
Don't we need lock? IO thread set it and any threa
reveman
2015/08/26 14:38:21
A mutex here would be sad as all other code is thr
Robert Sesek
2015/08/26 17:51:26
Can you DCHECK that this is supposed to be called
reveman
2015/08/26 19:40:33
As discussed, we can't add a DCHECK for this but I
| |
41 #if !defined(NDEBUG) | |
42 set_token_thread_id_ = base::PlatformThread::CurrentRef(); | |
43 #endif | |
44 set_token_event_.Signal(); | |
45 } | 39 } |
46 | 40 |
47 private: | 41 private: |
48 friend struct DefaultSingletonTraits<ChildIOSurfaceManager>; | 42 friend struct DefaultSingletonTraits<ChildIOSurfaceManager>; |
49 | 43 |
50 ChildIOSurfaceManager(); | 44 ChildIOSurfaceManager(); |
51 ~ChildIOSurfaceManager() override; | 45 ~ChildIOSurfaceManager() override; |
52 | 46 |
53 base::mac::ScopedMachSendRight service_port_; | 47 base::mac::ScopedMachSendRight service_port_; |
54 IOSurfaceManagerToken token_; | 48 IOSurfaceManagerToken token_; |
55 #if !defined(NDEBUG) | |
56 base::PlatformThreadRef set_token_thread_id_; | |
57 #endif | |
58 base::WaitableEvent set_token_event_; | |
59 | 49 |
60 DISALLOW_COPY_AND_ASSIGN(ChildIOSurfaceManager); | 50 DISALLOW_COPY_AND_ASSIGN(ChildIOSurfaceManager); |
61 }; | 51 }; |
62 | 52 |
63 } // namespace content | 53 } // namespace content |
64 | 54 |
65 #endif // CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ | 55 #endif // CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ |
OLD | NEW |