Skip to content

Commit

Permalink
MediaRecorder: ASSERT-->DCHECK and a tiny cleanup in CanvasCapture
Browse files Browse the repository at this point in the history
Blink now supports DCHECK()s and NOTREACHED(), this CL
uses them instead of ASSERT() and ASSERT_NOT_REACHED(),
respectively.

I was going to do the same HTMLCanvasElementCapture, but
removed the DCHECK instead bc of Chrome StyleGuide [1]:
> you should not handle DCHECK() failures, even if failure would
> result in a crash. Attempting to handle a DCHECK() failure is a
> statement that the DCHECK() can fail, which contradicts the point
> of writing the DCHECK(). In particular, do not write code like
> the following:
>
>  DCHECK(foo);
>  if (!foo) ...  // Can't succeed!

BUG=596760

[1] https://www.chromium.org/developers/coding-style#TOC-CHECK-DCHECK-and-NOTREACHED-

Review URL: https://codereview.chromium.org/1861963004

Cr-Commit-Position: refs/heads/master@{#385515}
  • Loading branch information
yellowdoge authored and Commit bot committed Apr 6, 2016
1 parent c94b50c commit 579ac73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ MediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElement& element,
}

WebMediaStreamTrack track;
WebSize size(element.width(), element.height());
const WebSize size(element.width(), element.height());
OwnPtr<WebCanvasCaptureHandler> handler;
if (givenFrameRate)
handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, frameRate, &track));
else
handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, kDefaultFrameRate, &track));
ASSERT(handler);

if (!handler) {
exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture handler can be created.");
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ String stateToString(MediaRecorder::State state)
return "paused";
}

ASSERT_NOT_REACHED();
NOTREACHED();
return String();
}

Expand Down Expand Up @@ -88,7 +88,7 @@ void AllocateVideoAndAudioBitrates(ExceptionState& exceptionState, ExecutionCont
audioBps = kSmallestPossibleOpusBitRate;
}
} else {
ASSERT(!audioBps);
DCHECK(!audioBps);
}
}

Expand All @@ -103,7 +103,7 @@ void AllocateVideoAndAudioBitrates(ExceptionState& exceptionState, ExecutionCont
videoBps = kSmallestPossibleVpxBitRate;
}
} else {
ASSERT(!videoBps);
DCHECK(!videoBps);
}
}

Expand Down Expand Up @@ -143,10 +143,10 @@ MediaRecorder::MediaRecorder(ExecutionContext* context, MediaStream* stream, con
, m_state(State::Inactive)
, m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(this, &MediaRecorder::dispatchScheduledEvent))
{
ASSERT(m_stream->getTracks().size());
DCHECK(m_stream->getTracks().size());

m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler());
ASSERT(m_recorderHandler);
DCHECK(m_recorderHandler);

if (!m_recorderHandler) {
exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder handler can be created.");
Expand Down Expand Up @@ -323,7 +323,7 @@ void MediaRecorder::createBlobEvent(Blob* blob)

void MediaRecorder::stopRecording()
{
ASSERT(m_state != State::Inactive);
DCHECK(m_state != State::Inactive);
m_state = State::Inactive;

m_recorderHandler->stop();
Expand Down

0 comments on commit 579ac73

Please sign in to comment.