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

Side by Side Diff: content/child/child_io_surface_manager_mac.h

Issue 1312353002: content: Remove base::WaitableEvent from ChildIOSurfaceManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 5 years, 3 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
« no previous file with comments | « no previous file | content/child/child_io_surface_manager_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
32 // Note: This can be called on any thread but must happen before the
33 // thread-safe IOSurfaceManager interface is used. It is the responsibility
34 // of users of this class to ensure there are no races.
34 void set_service_port(mach_port_t service_port) { 35 void set_service_port(mach_port_t service_port) {
35 service_port_.reset(service_port); 36 service_port_.reset(service_port);
36 } 37 }
37 38
38 // Set the token used when communicating with the Mach service. 39 // Set the token used when communicating with the Mach service.
40 // Note: This can be called on any thread but must happen before the
41 // thread-safe IOSurfaceManager interface is used. It is the responsibility
42 // of users of this class to ensure there are no races.
39 void set_token(const IOSurfaceManagerToken& token) { 43 void set_token(const IOSurfaceManagerToken& token) {
40 token_ = token; 44 token_ = token;
41 #if !defined(NDEBUG)
42 set_token_thread_id_ = base::PlatformThread::CurrentRef();
43 #endif
44 set_token_event_.Signal();
45 } 45 }
46 46
47 private: 47 private:
48 friend struct DefaultSingletonTraits<ChildIOSurfaceManager>; 48 friend struct DefaultSingletonTraits<ChildIOSurfaceManager>;
49 49
50 ChildIOSurfaceManager(); 50 ChildIOSurfaceManager();
51 ~ChildIOSurfaceManager() override; 51 ~ChildIOSurfaceManager() override;
52 52
53 base::mac::ScopedMachSendRight service_port_; 53 base::mac::ScopedMachSendRight service_port_;
54 IOSurfaceManagerToken token_; 54 IOSurfaceManagerToken token_;
55 #if !defined(NDEBUG)
56 base::PlatformThreadRef set_token_thread_id_;
57 #endif
58 base::WaitableEvent set_token_event_;
59 55
60 DISALLOW_COPY_AND_ASSIGN(ChildIOSurfaceManager); 56 DISALLOW_COPY_AND_ASSIGN(ChildIOSurfaceManager);
61 }; 57 };
62 58
63 } // namespace content 59 } // namespace content
64 60
65 #endif // CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_ 61 #endif // CONTENT_CHILD_CHILD_IO_SURFACE_MANAGER_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/child_io_surface_manager_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698