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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/RTCDataChannel.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 26
27 #include "bindings/core/v8/ExceptionState.h" 27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/dom/DOMArrayBuffer.h" 28 #include "core/dom/DOMArrayBuffer.h"
29 #include "core/dom/DOMArrayBufferView.h" 29 #include "core/dom/DOMArrayBufferView.h"
30 #include "core/dom/ExceptionCode.h" 30 #include "core/dom/ExceptionCode.h"
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "core/events/MessageEvent.h" 32 #include "core/events/MessageEvent.h"
33 #include "core/fileapi/Blob.h" 33 #include "core/fileapi/Blob.h"
34 #include "modules/mediastream/RTCPeerConnection.h" 34 #include "modules/mediastream/RTCPeerConnection.h"
35 #include "public/platform/WebRTCPeerConnectionHandler.h" 35 #include "public/platform/WebRTCPeerConnectionHandler.h"
36 #include "wtf/PtrUtil.h"
37 #include <memory>
38 36
39 namespace blink { 37 namespace blink {
40 38
41 static void throwNotOpenException(ExceptionState& exceptionState) 39 static void throwNotOpenException(ExceptionState& exceptionState)
42 { 40 {
43 exceptionState.throwDOMException(InvalidStateError, "RTCDataChannel.readySta te is not 'open'"); 41 exceptionState.throwDOMException(InvalidStateError, "RTCDataChannel.readySta te is not 'open'");
44 } 42 }
45 43
46 static void throwCouldNotSendDataException(ExceptionState& exceptionState) 44 static void throwCouldNotSendDataException(ExceptionState& exceptionState)
47 { 45 {
48 exceptionState.throwDOMException(NetworkError, "Could not send data"); 46 exceptionState.throwDOMException(NetworkError, "Could not send data");
49 } 47 }
50 48
51 static void throwNoBlobSupportException(ExceptionState& exceptionState) 49 static void throwNoBlobSupportException(ExceptionState& exceptionState)
52 { 50 {
53 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem ented yet"); 51 exceptionState.throwDOMException(NotSupportedError, "Blob support not implem ented yet");
54 } 52 }
55 53
56 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, std::unique_pt r<WebRTCDataChannelHandler> handler) 54 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, PassOwnPtr<Web RTCDataChannelHandler> handler)
57 { 55 {
58 DCHECK(handler); 56 DCHECK(handler);
59 RTCDataChannel* channel = new RTCDataChannel(context, std::move(handler)); 57 RTCDataChannel* channel = new RTCDataChannel(context, std::move(handler));
60 channel->suspendIfNeeded(); 58 channel->suspendIfNeeded();
61 59
62 return channel; 60 return channel;
63 } 61 }
64 62
65 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, WebRTCPeerConn ectionHandler* peerConnectionHandler, const String& label, const WebRTCDataChann elInit& init, ExceptionState& exceptionState) 63 RTCDataChannel* RTCDataChannel::create(ExecutionContext* context, WebRTCPeerConn ectionHandler* peerConnectionHandler, const String& label, const WebRTCDataChann elInit& init, ExceptionState& exceptionState)
66 { 64 {
67 std::unique_ptr<WebRTCDataChannelHandler> handler = wrapUnique(peerConnectio nHandler->createDataChannel(label, init)); 65 OwnPtr<WebRTCDataChannelHandler> handler = adoptPtr(peerConnectionHandler->c reateDataChannel(label, init));
68 if (!handler) { 66 if (!handler) {
69 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n ot supported"); 67 exceptionState.throwDOMException(NotSupportedError, "RTCDataChannel is n ot supported");
70 return nullptr; 68 return nullptr;
71 } 69 }
72 RTCDataChannel* channel = new RTCDataChannel(context, std::move(handler)); 70 RTCDataChannel* channel = new RTCDataChannel(context, std::move(handler));
73 channel->suspendIfNeeded(); 71 channel->suspendIfNeeded();
74 72
75 return channel; 73 return channel;
76 } 74 }
77 75
78 RTCDataChannel::RTCDataChannel(ExecutionContext* context, std::unique_ptr<WebRTC DataChannelHandler> handler) 76 RTCDataChannel::RTCDataChannel(ExecutionContext* context, PassOwnPtr<WebRTCDataC hannelHandler> handler)
79 : ActiveScriptWrappable(this) 77 : ActiveScriptWrappable(this)
80 , ActiveDOMObject(context) 78 , ActiveDOMObject(context)
81 , m_handler(std::move(handler)) 79 , m_handler(std::move(handler))
82 , m_readyState(ReadyStateConnecting) 80 , m_readyState(ReadyStateConnecting)
83 , m_binaryType(BinaryTypeArrayBuffer) 81 , m_binaryType(BinaryTypeArrayBuffer)
84 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired) 82 , m_scheduledEventTimer(this, &RTCDataChannel::scheduledEventTimerFired)
85 , m_bufferedAmountLowThreshold(0U) 83 , m_bufferedAmountLowThreshold(0U)
86 , m_stopped(false) 84 , m_stopped(false)
87 { 85 {
88 ThreadState::current()->registerPreFinalizer(this); 86 ThreadState::current()->registerPreFinalizer(this);
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 389 }
392 390
393 DEFINE_TRACE(RTCDataChannel) 391 DEFINE_TRACE(RTCDataChannel)
394 { 392 {
395 visitor->trace(m_scheduledEvents); 393 visitor->trace(m_scheduledEvents);
396 EventTargetWithInlineData::trace(visitor); 394 EventTargetWithInlineData::trace(visitor);
397 ActiveDOMObject::trace(visitor); 395 ActiveDOMObject::trace(visitor);
398 } 396 }
399 397
400 } // namespace blink 398 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698