| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ | 5 #ifndef CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ |
| 6 #define CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ | 6 #define CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <CoreServices/CoreServices.h> | 9 #include <CoreServices/CoreServices.h> |
| 10 | 10 |
| 11 #include "base/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
| 12 | 12 |
| 13 // Handles registering and cleaning up after a CFRunloopSource for a Mach port. | 13 // Handles registering and cleaning up after a CFRunloopSource for a Mach port. |
| 14 // Messages received on the port are piped through to a delegate. | 14 // Messages received on the port are piped through to a delegate. |
| 15 // | 15 // |
| 16 // Example: | 16 // Example: |
| 17 // class MyListener : public MachMessageSource::MachPortListener { | 17 // class MyListener : public MachMessageSource::MachPortListener { |
| 18 // public: | 18 // public: |
| 19 // void OnMachMessageReceived(void* mach_msg, size_t size) { | 19 // void OnMachMessageReceived(void* mach_msg, size_t size) { |
| 20 // printf("received message on Mach port\n"); | 20 // printf("received message on Mach port\n"); |
| 21 // } | 21 // } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 49 MachMessageSource(mach_port_t port, | 49 MachMessageSource(mach_port_t port, |
| 50 MachPortListener* listener, | 50 MachPortListener* listener, |
| 51 bool* success); | 51 bool* success); |
| 52 ~MachMessageSource(); | 52 ~MachMessageSource(); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // Called by CF when a new message arrives on the Mach port. | 55 // Called by CF when a new message arrives on the Mach port. |
| 56 static void OnReceiveMachMessage(CFMachPortRef port, void* msg, CFIndex size, | 56 static void OnReceiveMachMessage(CFMachPortRef port, void* msg, CFIndex size, |
| 57 void* closure); | 57 void* closure); |
| 58 | 58 |
| 59 scoped_cftyperef<CFRunLoopSourceRef> machport_runloop_ref_; | 59 base::mac::ScopedCFTypeRef<CFRunLoopSourceRef> machport_runloop_ref_; |
| 60 DISALLOW_COPY_AND_ASSIGN(MachMessageSource); | 60 DISALLOW_COPY_AND_ASSIGN(MachMessageSource); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 #endif // CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ | 63 #endif // CHROME_COMMON_MACH_MESSAGE_SOURCE_MAC_H_ |
| OLD | NEW |