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

Side by Side Diff: chrome/common/mach_message_source_mac.cc

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/mach_message_source_mac.h ('k') | chrome/common/sandbox_mac.mm » ('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 (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 #include "chrome/common/mach_message_source_mac.h" 5 #include "chrome/common/mach_message_source_mac.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/scoped_cftyperef.h"
8 9
9 MachMessageSource::MachMessageSource(mach_port_t port, 10 MachMessageSource::MachMessageSource(mach_port_t port,
10 MachPortListener* msg_listener, 11 MachPortListener* msg_listener,
11 bool* success) { 12 bool* success) {
12 DCHECK(msg_listener); 13 DCHECK(msg_listener);
13 DCHECK(success); 14 DCHECK(success);
14 DCHECK(port != MACH_PORT_NULL); 15 DCHECK(port != MACH_PORT_NULL);
15 16
16 CFMachPortContext port_context = {0}; 17 CFMachPortContext port_context = {0};
17 port_context.info = msg_listener; 18 port_context.info = msg_listener;
18 19
19 scoped_cftyperef<CFMachPortRef> cf_mach_port_ref( 20 base::mac::ScopedCFTypeRef<CFMachPortRef> cf_mach_port_ref(
20 CFMachPortCreateWithPort(kCFAllocatorDefault, 21 CFMachPortCreateWithPort(kCFAllocatorDefault,
21 port, 22 port,
22 MachMessageSource::OnReceiveMachMessage, 23 MachMessageSource::OnReceiveMachMessage,
23 &port_context, 24 &port_context,
24 NULL)); 25 NULL));
25 26
26 if (cf_mach_port_ref.get() == NULL) { 27 if (cf_mach_port_ref.get() == NULL) {
27 LOG(WARNING) << "CFMachPortCreate failed"; 28 LOG(WARNING) << "CFMachPortCreate failed";
28 *success = false; 29 *success = false;
29 return; 30 return;
(...skipping 27 matching lines...) Expand all
57 void MachMessageSource::OnReceiveMachMessage(CFMachPortRef port, void* msg, 58 void MachMessageSource::OnReceiveMachMessage(CFMachPortRef port, void* msg,
58 CFIndex size, void* closure) { 59 CFIndex size, void* closure) {
59 MachPortListener *msg_listener = static_cast<MachPortListener*>(closure); 60 MachPortListener *msg_listener = static_cast<MachPortListener*>(closure);
60 size_t msg_size = (size < 0) ? 0 : static_cast<size_t>(size); 61 size_t msg_size = (size < 0) ? 0 : static_cast<size_t>(size);
61 DCHECK(msg && msg_size > 0); // this should never happen! 62 DCHECK(msg && msg_size > 0); // this should never happen!
62 63
63 if (msg_listener && msg && msg_size > 0) { 64 if (msg_listener && msg && msg_size > 0) {
64 msg_listener->OnMachMessageReceived(msg, msg_size); 65 msg_listener->OnMachMessageReceived(msg, msg_size);
65 } 66 }
66 } 67 }
OLDNEW
« no previous file with comments | « chrome/common/mach_message_source_mac.h ('k') | chrome/common/sandbox_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698