Skip to content

Commit a90879b

Browse files
kthelgasonCommit bot
authored andcommitted
Reland of move all reference to carbon api (patchset #1 id:1 of https://codereview.webrtc.org/2316563002/ )
Reason for revert: Chromium build issues have been resolved. Original issue's description: > Revert of Remove all reference to carbon api (patchset #2 id:20001 of https://codereview.webrtc.org/2299633002/ ) > > Reason for revert: > Breaks chromium build > > Original issue's description: > > Remove all reference to carbon api > > > > BUG=webrtc:6282 > > > > Committed: https://crrev.com/dbd8b6bec4143c940b2f2ca8cd85c25d17327964 > > Cr-Commit-Position: refs/heads/master@{#14080} > > [email protected],[email protected] > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6282 > > Committed: https://crrev.com/b096aa7fd375a980daab3a986596548ca5de2a1c > Cr-Commit-Position: refs/heads/master@{#14081} [email protected],[email protected] # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6282 Review-Url: https://codereview.webrtc.org/2321493002 Cr-Commit-Position: refs/heads/master@{#14125}
1 parent 71eb61c commit a90879b

21 files changed

+27
-842
lines changed

webrtc/BUILD.gn

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,6 @@ if (rtc_include_tests) {
559559
"base/sslstreamadapter_unittest.cc",
560560
]
561561
}
562-
if (is_ios || (is_mac && target_cpu != "x86")) {
563-
defines = [ "CARBON_DEPRECATED=YES" ]
564-
}
565-
566562
if (rtc_use_quic) {
567563
sources += [
568564
"p2p/quic/quicconnectionhelper_unittest.cc",
@@ -825,9 +821,6 @@ if (rtc_include_tests) {
825821
if (is_mac) {
826822
sources += [ "base/macsocketserver_unittest.cc" ]
827823
}
828-
if (is_ios || (is_mac && target_cpu != "x86")) {
829-
defines = [ "CARBON_DEPRECATED=YES" ]
830-
}
831824
if (is_clang) {
832825
# Suppress warnings from the Chromium Clang plugin.
833826
# See http://code.google.com/p/webrtc/issues/detail?id=163 for details.

webrtc/base/BUILD.gn

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ config("rtc_base_all_dependent_config") {
6363
"Security.framework",
6464
"SystemConfiguration.framework",
6565
]
66-
if (current_cpu == "x86") {
67-
libs += [ "Carbon.framework" ]
68-
}
6966
}
7067
}
7168

@@ -289,6 +286,7 @@ rtc_static_library("rtc_base") {
289286
defines = [ "LOGGING=1" ]
290287

291288
sources = [
289+
"applefilesystem.mm",
292290
"arraysize.h",
293291
"asyncfile.cc",
294292
"asyncfile.h",
@@ -337,7 +335,6 @@ rtc_static_library("rtc_base") {
337335
"httpcommon.h",
338336
"httprequest.cc",
339337
"httprequest.h",
340-
"iosfilesystem.mm",
341338
"ipaddress.cc",
342339
"ipaddress.h",
343340
"linked_ptr.h",
@@ -667,10 +664,6 @@ rtc_static_library("rtc_base") {
667664
}
668665
}
669666

670-
if (is_ios || (is_mac && current_cpu != "x86")) {
671-
defines += [ "CARBON_DEPRECATED=YES" ]
672-
}
673-
674667
if (is_linux || is_android) {
675668
sources += [
676669
"linux.cc",

webrtc/base/iosfilesystem.mm renamed to webrtc/base/applefilesystem.mm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* be found in the AUTHORS file in the root of the source tree.
99
*/
1010

11-
// This file only exists because various iOS system APIs are only
12-
// available from Objective-C. See unixfilesystem.cc for the only use
11+
// This file only exists because various iOS and macOS system APIs are only
12+
// available from Objective-C. See unixfilesystem.cc for the only use
1313
// (enforced by a lack of a header file).
1414

1515
#import <Foundation/NSPathUtilities.h>
@@ -33,21 +33,21 @@
3333
}
3434

3535
// Return a (leaked) copy of a directory name suitable for application data.
36-
char* IOSDataDirectory() {
36+
char* AppleDataDirectory() {
3737
NSArray* paths = NSSearchPathForDirectoriesInDomains(
3838
NSApplicationSupportDirectory, NSUserDomainMask, YES);
3939
ASSERT([paths count] == 1);
4040
return copyString([paths objectAtIndex:0]);
4141
}
4242

4343
// Return a (leaked) copy of a directory name suitable for use as a $TEMP.
44-
char* IOSTempDirectory() {
44+
char* AppleTempDirectory() {
4545
return copyString(NSTemporaryDirectory());
4646
}
4747

4848
// Return the binary's path.
49-
void IOSAppName(rtc::Pathname* path) {
50-
NSProcessInfo *pInfo = [NSProcessInfo processInfo];
49+
void AppleAppName(rtc::Pathname* path) {
50+
NSProcessInfo* pInfo = [NSProcessInfo processInfo];
5151
NSString* argv0 = [[pInfo arguments] objectAtIndex:0];
5252
path->SetPathname([argv0 UTF8String]);
5353
}

webrtc/base/base.gyp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
'LOGGING=1',
230230
],
231231
'sources': [
232+
'applefilesystem.mm',
232233
'arraysize.h',
233234
'asyncfile.cc',
234235
'asyncfile.h',
@@ -277,7 +278,6 @@
277278
'httpcommon.h',
278279
'httprequest.cc',
279280
'httprequest.h',
280-
'iosfilesystem.mm',
281281
'ipaddress.cc',
282282
'ipaddress.h',
283283
'linked_ptr.h',
@@ -603,19 +603,6 @@
603603
},
604604
},
605605
},
606-
'conditions': [
607-
['target_arch=="ia32"', {
608-
'all_dependent_settings': {
609-
'link_settings': {
610-
'xcode_settings': {
611-
'OTHER_LDFLAGS': [
612-
'-framework Carbon',
613-
],
614-
},
615-
},
616-
},
617-
}],
618-
],
619606
}],
620607
['OS=="win" and nacl_untrusted_build==0', {
621608
'sources': [
@@ -664,11 +651,6 @@
664651
},
665652
}
666653
}],
667-
['OS=="ios" or (OS=="mac" and target_arch!="ia32")', {
668-
'defines': [
669-
'CARBON_DEPRECATED=YES',
670-
],
671-
}],
672654
['OS=="linux" or OS=="android"', {
673655
'sources': [
674656
'linux.cc',

webrtc/base/macsocketserver.cc

Lines changed: 0 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -212,175 +212,4 @@ void MacCFSocketServer::OnWakeUpCallback() {
212212
ASSERT(run_loop_ == CFRunLoopGetCurrent());
213213
CFRunLoopStop(run_loop_);
214214
}
215-
216-
///////////////////////////////////////////////////////////////////////////////
217-
// MacCarbonSocketServer
218-
///////////////////////////////////////////////////////////////////////////////
219-
#ifndef CARBON_DEPRECATED
220-
221-
const UInt32 kEventClassSocketServer = 'MCSS';
222-
const UInt32 kEventWakeUp = 'WAKE';
223-
const EventTypeSpec kEventWakeUpSpec[] = {
224-
{ kEventClassSocketServer, kEventWakeUp }
225-
};
226-
227-
std::string DecodeEvent(EventRef event) {
228-
std::string str;
229-
DecodeFourChar(::GetEventClass(event), &str);
230-
str.push_back(':');
231-
DecodeFourChar(::GetEventKind(event), &str);
232-
return str;
233-
}
234-
235-
MacCarbonSocketServer::MacCarbonSocketServer()
236-
: event_queue_(GetCurrentEventQueue()), wake_up_(NULL) {
237-
VERIFY(noErr == CreateEvent(NULL, kEventClassSocketServer, kEventWakeUp, 0,
238-
kEventAttributeUserEvent, &wake_up_));
239-
}
240-
241-
MacCarbonSocketServer::~MacCarbonSocketServer() {
242-
if (wake_up_) {
243-
ReleaseEvent(wake_up_);
244-
}
245-
}
246-
247-
bool MacCarbonSocketServer::Wait(int cms, bool process_io) {
248-
ASSERT(GetCurrentEventQueue() == event_queue_);
249-
250-
// Listen to all events if we're processing I/O.
251-
// Only listen for our wakeup event if we're not.
252-
UInt32 num_types = 0;
253-
const EventTypeSpec* events = NULL;
254-
if (!process_io) {
255-
num_types = GetEventTypeCount(kEventWakeUpSpec);
256-
events = kEventWakeUpSpec;
257-
}
258-
259-
EventTargetRef target = GetEventDispatcherTarget();
260-
EventTimeout timeout =
261-
(kForever == cms) ? kEventDurationForever : cms / 1000.0;
262-
EventTimeout end_time = GetCurrentEventTime() + timeout;
263-
264-
bool done = false;
265-
while (!done) {
266-
EventRef event;
267-
OSStatus result = ReceiveNextEvent(num_types, events, timeout, true,
268-
&event);
269-
if (noErr == result) {
270-
if (wake_up_ != event) {
271-
LOG_F(LS_VERBOSE) << "Dispatching event: " << DecodeEvent(event);
272-
result = SendEventToEventTarget(event, target);
273-
if ((noErr != result) && (eventNotHandledErr != result)) {
274-
LOG_E(LS_ERROR, OS, result) << "SendEventToEventTarget";
275-
}
276-
} else {
277-
done = true;
278-
}
279-
ReleaseEvent(event);
280-
} else if (eventLoopTimedOutErr == result) {
281-
ASSERT(cms != kForever);
282-
done = true;
283-
} else if (eventLoopQuitErr == result) {
284-
// Ignore this... we get spurious quits for a variety of reasons.
285-
LOG_E(LS_VERBOSE, OS, result) << "ReceiveNextEvent";
286-
} else {
287-
// Some strange error occurred. Log it.
288-
LOG_E(LS_WARNING, OS, result) << "ReceiveNextEvent";
289-
return false;
290-
}
291-
if (kForever != cms) {
292-
timeout = end_time - GetCurrentEventTime();
293-
}
294-
}
295-
return true;
296-
}
297-
298-
void MacCarbonSocketServer::WakeUp() {
299-
if (!IsEventInQueue(event_queue_, wake_up_)) {
300-
RetainEvent(wake_up_);
301-
OSStatus result = PostEventToQueue(event_queue_, wake_up_,
302-
kEventPriorityStandard);
303-
if (noErr != result) {
304-
LOG_E(LS_ERROR, OS, result) << "PostEventToQueue";
305-
}
306-
}
307-
}
308-
309-
///////////////////////////////////////////////////////////////////////////////
310-
// MacCarbonAppSocketServer
311-
///////////////////////////////////////////////////////////////////////////////
312-
313-
MacCarbonAppSocketServer::MacCarbonAppSocketServer()
314-
: event_queue_(GetCurrentEventQueue()) {
315-
// Install event handler
316-
VERIFY(noErr == InstallApplicationEventHandler(
317-
NewEventHandlerUPP(WakeUpEventHandler), 1, kEventWakeUpSpec, this,
318-
&event_handler_));
319-
320-
// Install a timer and set it idle to begin with.
321-
VERIFY(noErr == InstallEventLoopTimer(GetMainEventLoop(),
322-
kEventDurationForever,
323-
kEventDurationForever,
324-
NewEventLoopTimerUPP(TimerHandler),
325-
this,
326-
&timer_));
327-
}
328-
329-
MacCarbonAppSocketServer::~MacCarbonAppSocketServer() {
330-
RemoveEventLoopTimer(timer_);
331-
RemoveEventHandler(event_handler_);
332-
}
333-
334-
OSStatus MacCarbonAppSocketServer::WakeUpEventHandler(
335-
EventHandlerCallRef next, EventRef event, void *data) {
336-
QuitApplicationEventLoop();
337-
return noErr;
338-
}
339-
340-
void MacCarbonAppSocketServer::TimerHandler(
341-
EventLoopTimerRef timer, void *data) {
342-
QuitApplicationEventLoop();
343-
}
344-
345-
bool MacCarbonAppSocketServer::Wait(int cms, bool process_io) {
346-
if (!process_io && cms == 0) {
347-
// No op.
348-
return true;
349-
}
350-
if (kForever != cms) {
351-
// Start a timer.
352-
OSStatus error =
353-
SetEventLoopTimerNextFireTime(timer_, cms / 1000.0);
354-
if (error != noErr) {
355-
LOG(LS_ERROR) << "Failed setting next fire time.";
356-
}
357-
}
358-
if (!process_io) {
359-
// No way to listen to common modes and not get socket events, unless
360-
// we disable each one's callbacks.
361-
EnableSocketCallbacks(false);
362-
}
363-
RunApplicationEventLoop();
364-
if (!process_io) {
365-
// Reenable them. Hopefully this won't cause spurious callbacks or
366-
// missing ones while they were disabled.
367-
EnableSocketCallbacks(true);
368-
}
369-
return true;
370-
}
371-
372-
void MacCarbonAppSocketServer::WakeUp() {
373-
// TODO: No-op if there's already a WakeUp in flight.
374-
EventRef wake_up;
375-
VERIFY(noErr == CreateEvent(NULL, kEventClassSocketServer, kEventWakeUp, 0,
376-
kEventAttributeUserEvent, &wake_up));
377-
OSStatus result = PostEventToQueue(event_queue_, wake_up,
378-
kEventPriorityStandard);
379-
if (noErr != result) {
380-
LOG_E(LS_ERROR, OS, result) << "PostEventToQueue";
381-
}
382-
ReleaseEvent(wake_up);
383-
}
384-
385-
#endif
386215
} // namespace rtc

webrtc/base/macsocketserver.h

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#define WEBRTC_BASE_MACSOCKETSERVER_H__
1212

1313
#include <set>
14-
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) // Invalid on IOS
15-
#include <Carbon/Carbon.h>
16-
#endif
14+
#include <CoreFoundation/CoreFoundation.h>
1715
#include "webrtc/base/physicalsocketserver.h"
1816

1917
namespace rtc {
@@ -76,61 +74,6 @@ class MacCFSocketServer : public MacBaseSocketServer {
7674
CFRunLoopRef run_loop_;
7775
CFRunLoopSourceRef wake_up_;
7876
};
79-
80-
#ifndef CARBON_DEPRECATED
81-
82-
///////////////////////////////////////////////////////////////////////////////
83-
// MacCarbonSocketServer
84-
///////////////////////////////////////////////////////////////////////////////
85-
86-
// Interacts with the Carbon event queue. While idle it will block,
87-
// waiting for events. When the socket server has work to do, it will
88-
// post a 'wake up' event to the queue, causing the thread to exit the
89-
// event loop until the next call to Wait. Other events are dispatched
90-
// to their target. Supports Carbon and Cocoa UI interaction.
91-
class MacCarbonSocketServer : public MacBaseSocketServer {
92-
public:
93-
MacCarbonSocketServer();
94-
virtual ~MacCarbonSocketServer();
95-
96-
// SocketServer Interface
97-
virtual bool Wait(int cms, bool process_io);
98-
virtual void WakeUp();
99-
100-
private:
101-
EventQueueRef event_queue_;
102-
EventRef wake_up_;
103-
};
104-
105-
///////////////////////////////////////////////////////////////////////////////
106-
// MacCarbonAppSocketServer
107-
///////////////////////////////////////////////////////////////////////////////
108-
109-
// Runs the Carbon application event loop on the current thread while
110-
// idle. When the socket server has work to do, it will post an event
111-
// to the queue, causing the thread to exit the event loop until the
112-
// next call to Wait. Other events are automatically dispatched to
113-
// their target.
114-
class MacCarbonAppSocketServer : public MacBaseSocketServer {
115-
public:
116-
MacCarbonAppSocketServer();
117-
virtual ~MacCarbonAppSocketServer();
118-
119-
// SocketServer Interface
120-
virtual bool Wait(int cms, bool process_io);
121-
virtual void WakeUp();
122-
123-
private:
124-
static OSStatus WakeUpEventHandler(EventHandlerCallRef next, EventRef event,
125-
void *data);
126-
static void TimerHandler(EventLoopTimerRef timer, void *data);
127-
128-
EventQueueRef event_queue_;
129-
EventHandlerRef event_handler_;
130-
EventLoopTimerRef timer_;
131-
};
132-
133-
#endif
13477
} // namespace rtc
13578

13679
#endif // WEBRTC_BASE_MACSOCKETSERVER_H__

0 commit comments

Comments
 (0)