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

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/MediaSource.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #include "core/html/HTMLMediaElement.h" 39 #include "core/html/HTMLMediaElement.h"
40 #include "core/html/TimeRanges.h" 40 #include "core/html/TimeRanges.h"
41 #include "modules/mediasource/MediaSourceRegistry.h" 41 #include "modules/mediasource/MediaSourceRegistry.h"
42 #include "platform/ContentType.h" 42 #include "platform/ContentType.h"
43 #include "platform/Logging.h" 43 #include "platform/Logging.h"
44 #include "platform/MIMETypeRegistry.h" 44 #include "platform/MIMETypeRegistry.h"
45 #include "platform/RuntimeEnabledFeatures.h" 45 #include "platform/RuntimeEnabledFeatures.h"
46 #include "platform/TraceEvent.h" 46 #include "platform/TraceEvent.h"
47 #include "public/platform/WebMediaSource.h" 47 #include "public/platform/WebMediaSource.h"
48 #include "public/platform/WebSourceBuffer.h" 48 #include "public/platform/WebSourceBuffer.h"
49 #include "wtf/PtrUtil.h"
50 #include "wtf/text/CString.h" 49 #include "wtf/text/CString.h"
51 #include <memory>
52 50
53 using blink::WebMediaSource; 51 using blink::WebMediaSource;
54 using blink::WebSourceBuffer; 52 using blink::WebSourceBuffer;
55 53
56 #define MSLOG DVLOG(3) 54 #define MSLOG DVLOG(3)
57 55
58 namespace blink { 56 namespace blink {
59 57
60 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState) 58 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep tionState& exceptionState)
61 { 59 {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // 4. If the readyState attribute is not in the "open" state then throw an 141 // 4. If the readyState attribute is not in the "open" state then throw an
144 // InvalidStateError exception and abort these steps. 142 // InvalidStateError exception and abort these steps.
145 if (!isOpen()) { 143 if (!isOpen()) {
146 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou rce's readyState is not 'open'."); 144 logAndThrowDOMException(exceptionState, InvalidStateError, "The MediaSou rce's readyState is not 'open'.");
147 return 0; 145 return 0;
148 } 146 }
149 147
150 // 5. Create a new SourceBuffer object and associated resources. 148 // 5. Create a new SourceBuffer object and associated resources.
151 ContentType contentType(type); 149 ContentType contentType(type);
152 String codecs = contentType.parameter("codecs"); 150 String codecs = contentType.parameter("codecs");
153 std::unique_ptr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(con tentType.type(), codecs, exceptionState); 151 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType. type(), codecs, exceptionState);
154 152
155 if (!webSourceBuffer) { 153 if (!webSourceBuffer) {
156 DCHECK(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError); 154 DCHECK(exceptionState.code() == NotSupportedError || exceptionState.code () == QuotaExceededError);
157 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps. 155 // 2. If type contains a MIME type that is not supported ..., then throw a NotSupportedError exception and abort these steps.
158 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps 156 // 3. If the user agent can't handle any more SourceBuffer objects then throw a QuotaExceededError exception and abort these steps
159 return 0; 157 return 0;
160 } 158 }
161 159
162 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this , m_asyncEventQueue.get()); 160 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this , m_asyncEventQueue.get());
163 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object. 161 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 DEFINE_TRACE(MediaSource) 278 DEFINE_TRACE(MediaSource)
281 { 279 {
282 visitor->trace(m_asyncEventQueue); 280 visitor->trace(m_asyncEventQueue);
283 visitor->trace(m_attachedElement); 281 visitor->trace(m_attachedElement);
284 visitor->trace(m_sourceBuffers); 282 visitor->trace(m_sourceBuffers);
285 visitor->trace(m_activeSourceBuffers); 283 visitor->trace(m_activeSourceBuffers);
286 EventTargetWithInlineData::trace(visitor); 284 EventTargetWithInlineData::trace(visitor);
287 ActiveDOMObject::trace(visitor); 285 ActiveDOMObject::trace(visitor);
288 } 286 }
289 287
290 void MediaSource::setWebMediaSourceAndOpen(std::unique_ptr<WebMediaSource> webMe diaSource) 288 void MediaSource::setWebMediaSourceAndOpen(PassOwnPtr<WebMediaSource> webMediaSo urce)
291 { 289 {
292 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this); 290 TRACE_EVENT_ASYNC_END0("media", "MediaSource::attachToElement", this);
293 DCHECK(webMediaSource); 291 DCHECK(webMediaSource);
294 DCHECK(!m_webMediaSource); 292 DCHECK(!m_webMediaSource);
295 DCHECK(m_attachedElement); 293 DCHECK(m_attachedElement);
296 m_webMediaSource = std::move(webMediaSource); 294 m_webMediaSource = std::move(webMediaSource);
297 setReadyState(openKeyword()); 295 setReadyState(openKeyword());
298 } 296 }
299 297
300 void MediaSource::addedToRegistry() 298 void MediaSource::addedToRegistry()
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 570 }
573 571
574 void MediaSource::stop() 572 void MediaSource::stop()
575 { 573 {
576 m_asyncEventQueue->close(); 574 m_asyncEventQueue->close();
577 if (!isClosed()) 575 if (!isClosed())
578 setReadyState(closedKeyword()); 576 setReadyState(closedKeyword());
579 m_webMediaSource.reset(); 577 m_webMediaSource.reset();
580 } 578 }
581 579
582 std::unique_ptr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String & type, const String& codecs, ExceptionState& exceptionState) 580 PassOwnPtr<WebSourceBuffer> MediaSource::createWebSourceBuffer(const String& typ e, const String& codecs, ExceptionState& exceptionState)
583 { 581 {
584 WebSourceBuffer* webSourceBuffer = 0; 582 WebSourceBuffer* webSourceBuffer = 0;
585 583
586 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { 584 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) {
587 case WebMediaSource::AddStatusOk: 585 case WebMediaSource::AddStatusOk:
588 return wrapUnique(webSourceBuffer); 586 return adoptPtr(webSourceBuffer);
589 case WebMediaSource::AddStatusNotSupported: 587 case WebMediaSource::AddStatusNotSupported:
590 DCHECK(!webSourceBuffer); 588 DCHECK(!webSourceBuffer);
591 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 589 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
592 // Step 2: If type contains a MIME type ... that is not supported with t he types 590 // Step 2: If type contains a MIME type ... that is not supported with t he types
593 // specified for the other SourceBuffer objects in sourceBuffers, then t hrow 591 // specified for the other SourceBuffer objects in sourceBuffers, then t hrow
594 // a NotSupportedError exception and abort these steps. 592 // a NotSupportedError exception and abort these steps.
595 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is not supported."); 593 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is not supported.");
596 return nullptr; 594 return nullptr;
597 case WebMediaSource::AddStatusReachedIdLimit: 595 case WebMediaSource::AddStatusReachedIdLimit:
598 DCHECK(!webSourceBuffer); 596 DCHECK(!webSourceBuffer);
(...skipping 17 matching lines...) Expand all
616 614
617 m_asyncEventQueue->enqueueEvent(event); 615 m_asyncEventQueue->enqueueEvent(event);
618 } 616 }
619 617
620 URLRegistry& MediaSource::registry() const 618 URLRegistry& MediaSource::registry() const
621 { 619 {
622 return MediaSourceRegistry::registry(); 620 return MediaSourceRegistry::registry();
623 } 621 }
624 622
625 } // namespace blink 623 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698