OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 MOJO_EDK_SYSTEM_MACH_PORT_RELAY_H_ |
| 6 #define MOJO_EDK_SYSTEM_MACH_PORT_RELAY_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/process/port_provider_mac.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 14 #include "mojo/edk/system/channel.h" |
| 15 |
| 16 namespace mojo { |
| 17 namespace edk { |
| 18 |
| 19 class MachPortRelay : public base::PortProvider::Observer { |
| 20 public: |
| 21 class Observer { |
| 22 public: |
| 23 virtual void OnProcessReady(base::ProcessHandle process) = 0; |
| 24 }; |
| 25 |
| 26 static bool ReceivePorts(PlatformHandleVector* handles); |
| 27 |
| 28 explicit MachPortRelay(base::PortProvider* port_provider); |
| 29 ~MachPortRelay() override; |
| 30 |
| 31 bool SendPortsToProcess(Channel::Message* message, |
| 32 base::ProcessHandle process); |
| 33 |
| 34 bool ExtractPortRights(Channel::Message* message, |
| 35 base::ProcessHandle process); |
| 36 |
| 37 void AddObserver(Observer* observer); |
| 38 void RemoveObserver(Observer* observer); |
| 39 |
| 40 base::PortProvider* port_provider() const { return port_provider_; } |
| 41 |
| 42 private: |
| 43 // base::PortProvider::Observer implementation. |
| 44 void OnReceivedTaskPort(base::ProcessHandle process) override; |
| 45 |
| 46 base::PortProvider* const port_provider_; |
| 47 |
| 48 base::Lock observers_lock_; |
| 49 std::set<Observer*> observers_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(MachPortRelay); |
| 52 }; |
| 53 |
| 54 } // namespace edk |
| 55 } // namespace mojo |
| 56 |
| 57 #endif // MOJO_EDK_SYSTEM_MACH_PORT_RELAY_H_ |
OLD | NEW |