Bug 1562021 - part1 : modify debug log for WebVTTListener. r=jya

Refactor these log by using the `WebVTT` log module and adding address info in the log.

Differential Revision: https://phabricator.services.mozilla.com/D36405

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alastor Wu 2019-07-03 23:07:43 +00:00
Родитель 726678d4e7
Коммит ad11f4deea
1 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -14,6 +14,13 @@
#include "nsIInputStream.h"
#include "nsIWebVTTParserWrapper.h"
extern mozilla::LazyLogModule gTextTrackLog;
#define LOG(msg, ...) \
MOZ_LOG(gTextTrackLog, LogLevel::Debug, \
("WebVTTListener=%p, " msg, this, ##__VA_ARGS__))
#define LOG_WIHTOUT_ADDRESS(msg, ...) \
MOZ_LOG(gTextTrackLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
namespace mozilla {
namespace dom {
@ -30,13 +37,10 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(WebVTTListener)
NS_IMPL_CYCLE_COLLECTING_RELEASE(WebVTTListener)
LazyLogModule gTextTrackLog("TextTrack");
#define VTT_LOG(...) MOZ_LOG(gTextTrackLog, LogLevel::Debug, (__VA_ARGS__))
WebVTTListener::WebVTTListener(HTMLTrackElement* aElement)
: mElement(aElement), mParserWrapperError(NS_OK) {
MOZ_ASSERT(mElement, "Must pass an element to the callback");
VTT_LOG("WebVTTListener created.");
LOG("Created listener for track element %p", aElement);
MOZ_DIAGNOSTIC_ASSERT(
CycleCollectedJSContext::Get() &&
!CycleCollectedJSContext::Get()->IsInStableOrMetaStableState());
@ -51,7 +55,7 @@ WebVTTListener::WebVTTListener(HTMLTrackElement* aElement)
}
}
WebVTTListener::~WebVTTListener() { VTT_LOG("WebVTTListener destroyed."); }
WebVTTListener::~WebVTTListener() { LOG("destroyed."); }
NS_IMETHODIMP
WebVTTListener::GetInterface(const nsIID& aIID, void** aResult) {
@ -79,14 +83,15 @@ WebVTTListener::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
NS_IMETHODIMP
WebVTTListener::OnStartRequest(nsIRequest* aRequest) {
VTT_LOG("WebVTTListener::OnStartRequest\n");
LOG("OnStartRequest");
return NS_OK;
}
NS_IMETHODIMP
WebVTTListener::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
VTT_LOG("WebVTTListener::OnStopRequest\n");
LOG("OnStopRequest");
if (NS_FAILED(aStatus)) {
LOG("Got error status");
mElement->SetReadyState(TextTrackReadyState::FailedToLoad);
}
// Attempt to parse any final data the parser might still have.
@ -108,7 +113,9 @@ nsresult WebVTTListener::ParseChunk(nsIInputStream* aInStream, void* aClosure,
WebVTTListener* listener = static_cast<WebVTTListener*>(aClosure);
if (NS_FAILED(listener->mParserWrapper->Parse(buffer))) {
VTT_LOG("Unable to parse chunk of WEBVTT text. Aborting.");
LOG_WIHTOUT_ADDRESS(
"WebVTTListener=%p, Unable to parse chunk of WEBVTT text. Aborting.",
listener);
*aWriteCount = 0;
return NS_ERROR_FAILURE;
}
@ -120,7 +127,7 @@ nsresult WebVTTListener::ParseChunk(nsIInputStream* aInStream, void* aClosure,
NS_IMETHODIMP
WebVTTListener::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aStream,
uint64_t aOffset, uint32_t aCount) {
VTT_LOG("WebVTTListener::OnDataAvailable\n");
LOG("OnDataAvailable");
uint32_t count = aCount;
while (count > 0) {
uint32_t read;
@ -163,6 +170,7 @@ WebVTTListener::OnParsingError(int32_t errorCode, JSContext* cx) {
// We only care about files that have a bad WebVTT file signature right now
// as that means the file failed to load.
if (errorCode == ErrorCodes::BadSignature) {
LOG("parsing error");
mElement->SetReadyState(TextTrackReadyState::FailedToLoad);
}
return NS_OK;