Telemetry: Remove stubs and related code

This commit is contained in:
adeshkp 2019-01-12 06:20:31 -05:00 • committed by Roy Tam
commit aea50f182f
134 changed files with 68 additions and 3422 deletions

View file

@ -4033,8 +4033,6 @@ nsDOMWindowUtils::ForceUseCounterFlush(nsIDOMNode *aNode)
if (nsCOMPtr<nsIDocument> doc = do_QueryInterface(aNode)) {
mozilla::css::ImageLoader* loader = doc->StyleImageLoader();
loader->FlushUseCounters();
static_cast<nsDocument*>(doc.get())->ReportUseCounters();
return NS_OK;
}

View file

@ -1395,63 +1395,6 @@ nsDocument::~nsDocument()
NS_ASSERTION(!mIsShowing, "Destroying a currently-showing document");
if (IsTopLevelContentDocument()) {
//don't report for about: pages
if (!IsAboutPage()) {
// Record the page load
uint32_t pageLoaded = 1;
Accumulate(Telemetry::MIXED_CONTENT_UNBLOCK_COUNTER, pageLoaded);
// Record the mixed content status of the docshell in Telemetry
enum {
NO_MIXED_CONTENT = 0, // There is no Mixed Content on the page
MIXED_DISPLAY_CONTENT = 1, // The page attempted to load Mixed Display Content
MIXED_ACTIVE_CONTENT = 2, // The page attempted to load Mixed Active Content
MIXED_DISPLAY_AND_ACTIVE_CONTENT = 3 // The page attempted to load Mixed Display & Mixed Active Content
};
bool mixedActiveLoaded = GetHasMixedActiveContentLoaded();
bool mixedActiveBlocked = GetHasMixedActiveContentBlocked();
bool mixedDisplayLoaded = GetHasMixedDisplayContentLoaded();
bool mixedDisplayBlocked = GetHasMixedDisplayContentBlocked();
bool hasMixedDisplay = (mixedDisplayBlocked || mixedDisplayLoaded);
bool hasMixedActive = (mixedActiveBlocked || mixedActiveLoaded);
uint32_t mixedContentLevel = NO_MIXED_CONTENT;
if (hasMixedDisplay && hasMixedActive) {
mixedContentLevel = MIXED_DISPLAY_AND_ACTIVE_CONTENT;
} else if (hasMixedActive){
mixedContentLevel = MIXED_ACTIVE_CONTENT;
} else if (hasMixedDisplay) {
mixedContentLevel = MIXED_DISPLAY_CONTENT;
}
Accumulate(Telemetry::MIXED_CONTENT_PAGE_LOAD, mixedContentLevel);
// record mixed object subrequest telemetry
if (mHasMixedContentObjectSubrequest) {
/* mixed object subrequest loaded on page*/
Accumulate(Telemetry::MIXED_CONTENT_OBJECT_SUBREQUEST, 1);
} else {
/* no mixed object subrequests loaded on page*/
Accumulate(Telemetry::MIXED_CONTENT_OBJECT_SUBREQUEST, 0);
}
// record CSP telemetry on this document
if (mHasCSP) {
Accumulate(Telemetry::CSP_DOCUMENTS_COUNT, 1);
}
if (mHasUnsafeInlineCSP) {
Accumulate(Telemetry::CSP_UNSAFE_INLINE_DOCUMENTS_COUNT, 1);
}
if (mHasUnsafeEvalCSP) {
Accumulate(Telemetry::CSP_UNSAFE_EVAL_DOCUMENTS_COUNT, 1);
}
}
}
ReportUseCounters();
mInDestructor = true;
mInUnlinkOrDeletion = true;
@ -12353,23 +12296,6 @@ nsIDocument::InlineScriptAllowedByCSP()
return allowsInlineScript;
}
static bool
MightBeAboutOrChromeScheme(nsIURI* aURI)
{
MOZ_ASSERT(aURI);
bool isAbout = true;
bool isChrome = true;
aURI->SchemeIs("about", &isAbout);
aURI->SchemeIs("chrome", &isChrome);
return isAbout || isChrome;
}
void
nsDocument::ReportUseCounters()
{
/* STUB */
}
void
nsDocument::AddIntersectionObserver(DOMIntersectionObserver* aObserver)
{

View file

@ -774,8 +774,6 @@ public:
virtual nsViewportInfo GetViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) override;
void ReportUseCounters();
virtual void AddIntersectionObserver(
mozilla::dom::DOMIntersectionObserver* aObserver) override;
virtual void RemoveIntersectionObserver(
@ -1449,14 +1447,6 @@ public:
// 'style-sheet-applicable-state-changed' notification.
bool mSSApplicableStateNotificationPending:1;
// Whether we have reported use counters for this document with Telemetry yet.
// Normally this is only done at document destruction time, but for image
// documents (SVG documents) that are not guaranteed to be destroyed, we
// report use counters when the image cache no longer has any imgRequestProxys
// pointing to them. We track whether we ever reported use counters so
// that we only report them once for the document.
bool mReportedUseCounters:1;
// Whether we have filled our pres shell's style set with the document's
// additional sheets and sheets from the nsStyleSheetService.
bool mStyleSetFilled:1;

View file

@ -706,12 +706,6 @@ nsFrameMessageManager::SendRpcMessage(const nsAString& aMessageName,
static bool
AllowMessage(size_t aDataLength, const nsAString& aMessageName)
{
static const size_t kMinTelemetryMessageSize = 8192;
if (aDataLength < kMinTelemetryMessageSize) {
return true;
}
NS_ConvertUTF16toUTF8 messageName(aMessageName);
messageName.StripChars("0123456789");

View file

@ -288,7 +288,6 @@ static bool gMouseDown = false;
static bool gDragServiceDisabled = false;
static FILE *gDumpFile = nullptr;
static uint32_t gSerialCounter = 0;
static TimeStamp gLastRecordedRecentTimeouts;
#define STATISTICS_INTERVAL (30 * PR_MSEC_PER_SEC)
#ifdef DEBUG_jst
@ -1518,7 +1517,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mIsPopupSpam(false),
mBlockScriptedClosingFlag(false),
mWasOffline(false),
mHasHadSlowScript(false),
mNotifyIdleObserversIdleOnThaw(false),
mNotifyIdleObserversActiveOnThaw(false),
mCreatingInnerWindow(false),
@ -11542,8 +11540,6 @@ nsGlobalWindow::ShowSlowScriptDialog()
unsigned lineno;
bool hasFrame = JS::DescribeScriptedCaller(cx, &filename, &lineno);
mHasHadSlowScript = true;
if (XRE_IsContentProcess() &&
ProcessHangMonitor::Get()) {
ProcessHangMonitor::SlowScriptAction action;
@ -13399,13 +13395,6 @@ nsGlobalWindow::RunTimeout(Timeout* aTimeout)
return;
}
// Record telemetry information about timers set recently.
TimeDuration recordingInterval = TimeDuration::FromMilliseconds(STATISTICS_INTERVAL);
if (gLastRecordedRecentTimeouts.IsNull() ||
now - gLastRecordedRecentTimeouts > recordingInterval) {
gLastRecordedRecentTimeouts = now;
}
// Insert a dummy timeout into the list of timeouts between the
// portion of the list that we are about to process now and those
// timeouts that will be processed in a future call to

View file

@ -1780,11 +1780,6 @@ protected:
// Window offline status. Checked to see if we need to fire offline event
bool mWasOffline : 1;
// Represents whether the inner window's page has had a slow script notice.
// Only used by inner windows; will always be false for outer windows.
// This is used to implement Telemetry measures such as SLOW_SCRIPT_PAGE_COUNT.
bool mHasHadSlowScript : 1;
// Track what sorts of events we need to fire when thawed
bool mNotifyIdleObserversIdleOnThaw : 1;
bool mNotifyIdleObserversActiveOnThaw : 1;

View file

@ -1582,7 +1582,6 @@ nsObjectLoadingContent::MaybeRewriteYoutubeEmbed(nsIURI* aURI, nsIURI* aBaseURI,
}
}
// If we're pref'd off, return after telemetry has been logged.
if (!Preferences::GetBool(kPrefYoutubeRewrite)) {
return;
}

View file

@ -7,7 +7,6 @@
#include "nsXULAppAPI.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/Telemetry.h"
#include "mozilla/UniquePtr.h"
#include "nsGeolocation.h"
@ -70,7 +69,6 @@ class nsGeolocationRequest final
GeoPositionCallback aCallback,
GeoPositionErrorCallback aErrorCallback,
UniquePtr<PositionOptions>&& aOptions,
uint8_t aProtocolType,
bool aWatchPositionRequest = false,
int32_t aWatchId = 0);
@ -119,7 +117,6 @@ class nsGeolocationRequest final
int32_t mWatchId;
bool mShutdown;
nsCOMPtr<nsIContentPermissionRequester> mRequester;
uint8_t mProtocolType;
};
static UniquePtr<PositionOptions>
@ -287,7 +284,6 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
GeoPositionCallback aCallback,
GeoPositionErrorCallback aErrorCallback,
UniquePtr<PositionOptions>&& aOptions,
uint8_t aProtocolType,
bool aWatchPositionRequest,
int32_t aWatchId)
: mIsWatchPositionRequest(aWatchPositionRequest),
@ -296,8 +292,7 @@ nsGeolocationRequest::nsGeolocationRequest(Geolocation* aLocator,
mOptions(Move(aOptions)),
mLocator(aLocator),
mWatchId(aWatchId),
mShutdown(false),
mProtocolType(aProtocolType)
mShutdown(false)
{
if (nsCOMPtr<nsPIDOMWindowInner> win =
do_QueryReferent(mLocator->GetOwner())) {
@ -949,8 +944,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Geolocation,
mPendingRequests)
Geolocation::Geolocation()
: mProtocolType(ProtocolType::OTHER)
, mLastWatchId(0)
: mLastWatchId(0)
{
}
@ -982,23 +976,6 @@ Geolocation::Init(nsPIDOMWindowInner* aContentDom)
nsCOMPtr<nsIURI> uri;
nsresult rv = mPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
if (uri) {
bool isHttp;
rv = uri->SchemeIs("http", &isHttp);
NS_ENSURE_SUCCESS(rv, rv);
bool isHttps;
rv = uri->SchemeIs("https", &isHttps);
NS_ENSURE_SUCCESS(rv, rv);
// Store the protocol to send via telemetry later.
if (isHttp) {
mProtocolType = ProtocolType::HTTP;
} else if (isHttps) {
mProtocolType = ProtocolType::HTTPS;
}
}
}
// If no aContentDom was passed into us, we are being used
@ -1185,7 +1162,7 @@ Geolocation::GetCurrentPosition(GeoPositionCallback callback,
RefPtr<nsGeolocationRequest> request =
new nsGeolocationRequest(this, Move(callback), Move(errorCallback),
Move(options), static_cast<uint8_t>(mProtocolType),
Move(options),
false);
if (!sGeoEnabled) {
@ -1263,7 +1240,7 @@ Geolocation::WatchPosition(GeoPositionCallback aCallback,
RefPtr<nsGeolocationRequest> request =
new nsGeolocationRequest(this, Move(aCallback), Move(aErrorCallback),
Move(aOptions),
static_cast<uint8_t>(mProtocolType), true, *aRv);
true, *aRv);
if (!sGeoEnabled) {
nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);

View file

@ -202,12 +202,6 @@ private:
// where the content was loaded from
nsCOMPtr<nsIPrincipal> mPrincipal;
// the protocols we want to measure
enum class ProtocolType: uint8_t { OTHER, HTTP, HTTPS };
// the protocol used to load the content
ProtocolType mProtocolType;
// owning back pointer.
RefPtr<nsGeolocationService> mService;

View file

@ -51,7 +51,6 @@
#include "nsIWebProgress.h"
#include "nsIDocShell.h"
#include "nsIPrompt.h"
#include "nsISecurityUITelemetry.h"
#include "nsIStringBundle.h"
// radio buttons
@ -954,8 +953,6 @@ HTMLFormElement::DoSecureToInsecureSubmitCheck(nsIURI* aActionURL,
return rv;
}
*aCancelSubmit = (buttonPressed == 1);
uint32_t telemetryBucket =
nsISecurityUITelemetry::WARNING_CONFIRM_POST_TO_INSECURE_FROM_SECURE;
return NS_OK;
}

View file

@ -1345,8 +1345,6 @@ HTMLImageElement::FlushUseCounters()
nsCOMPtr<imgIContainer> container;
request->GetImage(getter_AddRefs(container));
static_cast<image::Image*>(container.get())->ReportUseCounters();
}
} // namespace dom

View file

@ -1037,14 +1037,6 @@ void HTMLMediaElement::ShutdownDecoder()
void HTMLMediaElement::AbortExistingLoads()
{
#ifdef MOZ_EME
// If there is no existing decoder then we don't have anything to
// report. This prevents reporting the initial load from an
// empty video element as a failed EME load.
if (mDecoder) {
ReportEMETelemetry();
}
#endif
// Abort any already-running instance of the resource selection algorithm.
mLoadWaitStatus = NOT_WAITING;
@ -1900,7 +1892,6 @@ NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime)
void
HTMLMediaElement::FastSeek(double aTime, ErrorResult& aRv)
{
LOG(LogLevel::Debug, ("Reporting telemetry VIDEO_FASTSEEK_USED"));
RefPtr<Promise> tobeDropped = Seek(aTime, SeekTarget::PrevSyncPoint, aRv);
}
@ -3648,191 +3639,6 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
return rv;
}
/* static */
void HTMLMediaElement::VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure)
{
MOZ_ASSERT(NS_IsMainThread());
auto element = static_cast<HTMLMediaElement*>(aClosure);
element->mVideoDecodeSuspendTime.Start();
element->mVideoDecodeSuspendTimer = nullptr;
}
void HTMLMediaElement::HiddenVideoStart()
{
MOZ_ASSERT(NS_IsMainThread());
mHiddenPlayTime.Start();
if (mVideoDecodeSuspendTimer) {
// Already started, just keep it running.
return;
}
mVideoDecodeSuspendTimer = do_CreateInstance("@mozilla.org/timer;1");
mVideoDecodeSuspendTimer->InitWithNamedFuncCallback(
VideoDecodeSuspendTimerCallback, this,
MediaPrefs::MDSMSuspendBackgroundVideoDelay(), nsITimer::TYPE_ONE_SHOT,
"HTMLMediaElement::VideoDecodeSuspendTimerCallback");
}
void HTMLMediaElement::HiddenVideoStop()
{
MOZ_ASSERT(NS_IsMainThread());
mHiddenPlayTime.Pause();
mVideoDecodeSuspendTime.Pause();
if (!mVideoDecodeSuspendTimer) {
return;
}
mVideoDecodeSuspendTimer->Cancel();
mVideoDecodeSuspendTimer = nullptr;
}
#ifdef MOZ_EME
void
HTMLMediaElement::ReportEMETelemetry()
{
// Report telemetry for EME videos when a page is unloaded.
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
if (mIsEncrypted && Preferences::GetBool("media.eme.enabled")) {
LOG(LogLevel::Debug, ("%p VIDEO_EME_PLAY_SUCCESS = %s",
this, mLoadedDataFired ? "true" : "false"));
}
}
#endif
void
HTMLMediaElement::ReportTelemetry()
{
// Report telemetry for videos when a page is unloaded. We
// want to know data on what state the video is at when
// the user has exited.
enum UnloadedState {
ENDED = 0,
PAUSED = 1,
STALLED = 2,
SEEKING = 3,
OTHER = 4
};
UnloadedState state = OTHER;
if (Seeking()) {
state = SEEKING;
}
else if (Ended()) {
state = ENDED;
}
else if (Paused()) {
state = PAUSED;
}
else {
// For buffering we check if the current playback position is at the end
// of a buffered range, within a margin of error. We also consider to be
// buffering if the last frame status was buffering and the ready state is
// HAVE_CURRENT_DATA to account for times where we are in a buffering state
// regardless of what actual data we have buffered.
bool stalled = false;
RefPtr<TimeRanges> ranges = Buffered();
const double errorMargin = 0.05;
double t = CurrentTime();
TimeRanges::index_type index = ranges->Find(t, errorMargin);
ErrorResult ignore;
stalled = index != TimeRanges::NoIndex &&
(ranges->End(index, ignore) - t) < errorMargin;
stalled |= mDecoder && NextFrameStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING &&
mReadyState == HTMLMediaElement::HAVE_CURRENT_DATA;
if (stalled) {
state = STALLED;
}
}
LOG(LogLevel::Debug, ("%p VIDEO_UNLOAD_STATE = %d", this, state));
FrameStatisticsData data;
if (HTMLVideoElement* vid = HTMLVideoElement::FromContentOrNull(this)) {
FrameStatistics* stats = vid->GetFrameStatistics();
if (stats) {
data = stats->GetFrameStatisticsData();
if (data.mParsedFrames) {
MOZ_ASSERT(data.mDroppedFrames <= data.mParsedFrames);
// Dropped frames <= total frames, so 'percentage' cannot be higher than
// 100 and therefore can fit in a uint32_t (that Telemetry takes).
uint32_t percentage = 100 * data.mDroppedFrames / data.mParsedFrames;
LOG(LogLevel::Debug,
("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK"));
}
}
}
if (mMediaInfo.HasVideo() &&
mMediaInfo.mVideo.mImage.height > 0) {
// We have a valid video.
double playTime = mPlayTime.Total();
double hiddenPlayTime = mHiddenPlayTime.Total();
double videoDecodeSuspendTime = mVideoDecodeSuspendTime.Total();
LOG(LogLevel::Debug, ("%p VIDEO_PLAY_TIME_MS = %f", this, playTime));
LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_MS = %f", this, hiddenPlayTime));
if (playTime > 0.0) {
// We have actually played something -> Report some valid-video telemetry.
// Keyed by audio+video or video alone, and by a resolution range.
nsCString key(mMediaInfo.HasAudio() ? "AV," : "V,");
static const struct { int32_t mH; const char* mRes; } sResolutions[] = {
{ 240, "0<h<=240" },
{ 480, "240<h<=480" },
{ 576, "480<h<=576" },
{ 720, "576<h<=720" },
{ 1080, "720<h<=1080" },
{ 2160, "1080<h<=2160" }
};
const char* resolution = "h>2160";
int32_t height = mMediaInfo.mVideo.mImage.height;
for (const auto& res : sResolutions) {
if (height <= res.mH) {
resolution = res.mRes;
break;
}
}
key.AppendASCII(resolution);
uint32_t hiddenPercentage = uint32_t(hiddenPlayTime / playTime * 100.0 + 0.5);
LOG(LogLevel::Debug, ("%p VIDEO_HIDDEN_PLAY_TIME_PERCENTAGE = %u, keys: '%s' and 'All'",
this, hiddenPercentage, key.get()));
uint32_t videoDecodeSuspendPercentage =
uint32_t(videoDecodeSuspendTime / playTime * 100.0 + 0.5);
LOG(LogLevel::Debug, ("%p VIDEO_INFERRED_DECODE_SUSPEND_PERCENTAGE = %u, keys: '%s' and 'All'",
this, videoDecodeSuspendPercentage, key.get()));
if (data.mInterKeyframeCount != 0) {
uint32_t average_ms =
uint32_t(std::min<uint64_t>(double(data.mInterKeyframeSum_us)
/ double(data.mInterKeyframeCount)
/ 1000.0
+ 0.5,
UINT32_MAX));
LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_AVERAGE_MS = %u, keys: '%s' and 'All'",
this, average_ms, key.get()));
uint32_t max_ms =
uint32_t(std::min<uint64_t>((data.mInterKeyFrameMax_us + 500) / 1000,
UINT32_MAX));
LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = %u, keys: '%s' and 'All'",
this, max_ms, key.get()));
} else {
// Here, we have played *some* of the video, but didn't get more than 1
// keyframe. Report '0' if we have played for longer than the video-
// decode-suspend delay (showing recovery would be difficult).
uint32_t suspendDelay_ms = MediaPrefs::MDSMSuspendBackgroundVideoDelay();
if (uint32_t(playTime * 1000.0) > suspendDelay_ms) {
LOG(LogLevel::Debug, ("%p VIDEO_INTER_KEYFRAME_MAX_MS = 0 (only 1 keyframe), keys: '%s' and 'All'",
this, key.get()));
}
}
}
}
}
void HTMLMediaElement::UnbindFromTree(bool aDeep,
bool aNullParent)
{
@ -5312,19 +5118,6 @@ nsresult HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName)
nsCOMPtr<nsIRunnable> event = new nsAsyncEventRunner(aName, this);
NS_DispatchToMainThread(event);
if ((aName.EqualsLiteral("play") || aName.EqualsLiteral("playing"))) {
mPlayTime.Start();
if (IsHidden()) {
HiddenVideoStart();
}
} else if (aName.EqualsLiteral("waiting")) {
mPlayTime.Pause();
HiddenVideoStop();
} else if (aName.EqualsLiteral("pause")) {
mPlayTime.Pause();
HiddenVideoStop();
}
return NS_OK;
}
@ -5450,11 +5243,6 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (aPauseElement) {
ReportTelemetry();
#ifdef MOZ_EME
ReportEMETelemetry();
#endif
#ifdef MOZ_EME
// For EME content, we may force destruction of the CDM client (and CDM
// instance if this is the last client for that CDM instance) and
@ -5506,13 +5294,6 @@ bool HTMLMediaElement::IsBeingDestroyed()
void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
{
bool visible = !IsHidden();
if (visible) {
// Visible -> Just pause hidden play time (no-op if already paused).
HiddenVideoStop();
} else if (mPlayTime.IsStarted()) {
// Not visible, play time is running -> Start hidden play time if needed.
HiddenVideoStart();
}
if (mDecoder && !IsBeingDestroyed()) {
mDecoder->NotifyOwnerActivityChanged(visible);
@ -6288,18 +6069,10 @@ HTMLMediaElement::OnVisibilityChange(Visibility aNewVisibility)
break;
}
case Visibility::APPROXIMATELY_NONVISIBLE: {
if (mPlayTime.IsStarted()) {
// Not visible, play time is running -> Start hidden play time if needed.
HiddenVideoStart();
}
mDecoder->NotifyOwnerActivityChanged(false);
break;
}
case Visibility::APPROXIMATELY_VISIBLE: {
// Visible -> Just pause hidden play time (no-op if already paused).
HiddenVideoStop();
mDecoder->NotifyOwnerActivityChanged(true);
break;
}

View file

@ -1195,29 +1195,6 @@ protected:
return isPaused;
}
/**
* Video has been playing while hidden and, if feature was enabled, would
* trigger suspending decoder.
* Used to track hidden-video-decode-suspend telemetry.
*/
static void VideoDecodeSuspendTimerCallback(nsITimer* aTimer, void* aClosure);
/**
* Video is now both: playing and hidden.
* Used to track hidden-video telemetry.
*/
void HiddenVideoStart();
/**
* Video is not playing anymore and/or has become visible.
* Used to track hidden-video telemetry.
*/
void HiddenVideoStop();
#ifdef MOZ_EME
void ReportEMETelemetry();
#endif
void ReportTelemetry();
// Check the permissions for audiochannel.
bool CheckAudioChannelPermissions(const nsAString& aType);
@ -1688,65 +1665,7 @@ protected:
// before attaching to the DOM tree.
bool mUnboundFromTree = false;
public:
// Helper class to measure times for MSE telemetry stats
class TimeDurationAccumulator
{
public:
TimeDurationAccumulator()
: mCount(0)
{}
void Start()
{
if (IsStarted()) {
return;
}
mStartTime = TimeStamp::Now();
}
void Pause()
{
if (!IsStarted()) {
return;
}
mSum += (TimeStamp::Now() - mStartTime);
mCount++;
mStartTime = TimeStamp();
}
bool IsStarted() const
{
return !mStartTime.IsNull();
}
double Total() const
{
if (!IsStarted()) {
return mSum.ToSeconds();
}
// Add current running time until now, but keep it running.
return (mSum + (TimeStamp::Now() - mStartTime)).ToSeconds();
}
uint32_t Count() const
{
if (!IsStarted()) {
return mCount;
}
// Count current run in this report, without increasing the stored count.
return mCount + 1;
}
private:
TimeStamp mStartTime;
TimeDuration mSum;
uint32_t mCount;
};
private:
// Total time a video has spent playing.
TimeDurationAccumulator mPlayTime;
// Total time a video has spent playing while hidden.
TimeDurationAccumulator mHiddenPlayTime;
// Total time a video has (or would have) spent in video-decode-suspend mode.
TimeDurationAccumulator mVideoDecodeSuspendTime;
// Indicates if user has interacted with the element.
// Used to block autoplay when disabled.
bool mHasUserInteraction;

View file

@ -118,7 +118,6 @@ TextTrackManager::TextTrackManager(HTMLMediaElement *aMediaElement)
, mTimeMarchesOnDispatched(false)
, mUpdateCueDisplayDispatched(false)
, performedTrackSelection(false)
, mCueTelemetryReported(false)
, mShutdown(false)
{
nsISupports* parentObject =
@ -170,7 +169,6 @@ TextTrackManager::AddTextTrack(TextTrackKind aKind, const nsAString& aLabel,
mTextTracks->AddTextTrack(aKind, aLabel, aLanguage, aMode, aReadyState,
aTextTrackSource, CompareTextTracks(mMediaElement));
AddCues(track);
ReportTelemetryForTrack(track);
if (aTextTrackSource == TextTrackSource::Track) {
RefPtr<nsIRunnable> task =
@ -190,7 +188,6 @@ TextTrackManager::AddTextTrack(TextTrack* aTextTrack)
WEBVTT_LOG("%p AddTextTrack TextTrack %p",this, aTextTrack);
mTextTracks->AddTextTrack(aTextTrack, CompareTextTracks(mMediaElement));
AddCues(aTextTrack);
ReportTelemetryForTrack(aTextTrack);
if (aTextTrack->GetTextTrackSource() == TextTrackSource::Track) {
RefPtr<nsIRunnable> task =
@ -309,7 +306,6 @@ TextTrackManager::NotifyCueAdded(TextTrackCue& aCue)
mNewCues->AddCue(aCue);
}
DispatchTimeMarchesOn();
ReportTelemetryForCue();
}
void
@ -827,17 +823,5 @@ TextTrackManager::NotifyReset()
mLastTimeMarchesOnCalled = 0.0;
}
void
TextTrackManager::ReportTelemetryForTrack(TextTrack* aTextTrack) const
{
/* STUB */
}
void
TextTrackManager::ReportTelemetryForCue()
{
/* STUB */
}
} // namespace dom
} // namespace mozilla

View file

@ -148,13 +148,6 @@ private:
nsTArray<TextTrack*>& aTextTracks);
bool TrackIsDefault(TextTrack* aTextTrack);
void ReportTelemetryForTrack(TextTrack* aTextTrack) const;
void ReportTelemetryForCue();
// If there is at least one cue has been added to the cue list once, we would
// report the usage of cue to Telemetry.
bool mCueTelemetryReported;
class ShutdownObserverProxy final : public nsIObserver
{
NS_DECL_ISUPPORTS

View file

@ -4129,7 +4129,6 @@ GetDatabaseFileURL(nsIFile* aDatabaseFile,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
nsIFileURL** aResult)
{
MOZ_ASSERT(aDatabaseFile);
@ -4161,18 +4160,10 @@ GetDatabaseFileURL(nsIFile* aDatabaseFile,
nsAutoCString type;
PersistenceTypeToText(aPersistenceType, type);
nsAutoCString telemetryFilenameClause;
if (aTelemetryId) {
telemetryFilenameClause.AssignLiteral("&telemetryFilename=indexedDB-");
telemetryFilenameClause.AppendInt(aTelemetryId);
telemetryFilenameClause.AppendLiteral(".sqlite");
}
rv = fileUrl->SetQuery(NS_LITERAL_CSTRING("persistenceType=") + type +
NS_LITERAL_CSTRING("&group=") + aGroup +
NS_LITERAL_CSTRING("&origin=") + aOrigin +
NS_LITERAL_CSTRING("&cache=private") +
telemetryFilenameClause);
NS_LITERAL_CSTRING("&cache=private"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4422,7 +4413,6 @@ CreateStorageConnection(nsIFile* aDBFile,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
mozIStorageConnection** aConnection)
{
AssertIsOnIOThread();
@ -4454,7 +4444,6 @@ CreateStorageConnection(nsIFile* aDBFile,
aPersistenceType,
aGroup,
aOrigin,
aTelemetryId,
getter_AddRefs(dbFileUrl));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -4890,7 +4879,6 @@ GetStorageConnection(nsIFile* aDatabaseFile,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
mozIStorageConnection** aConnection)
{
MOZ_ASSERT(!NS_IsMainThread());
@ -4918,7 +4906,6 @@ GetStorageConnection(nsIFile* aDatabaseFile,
aPersistenceType,
aGroup,
aOrigin,
aTelemetryId,
getter_AddRefs(dbFileUrl));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -4955,7 +4942,6 @@ GetStorageConnection(const nsAString& aDatabaseFilePath,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
mozIStorageConnection** aConnection)
{
MOZ_ASSERT(!NS_IsMainThread());
@ -4974,7 +4960,6 @@ GetStorageConnection(const nsAString& aDatabaseFilePath,
aPersistenceType,
aGroup,
aOrigin,
aTelemetryId,
aConnection);
}
@ -6296,7 +6281,6 @@ private:
const nsCString mId;
const nsString mFilePath;
uint32_t mActiveMutableFileCount;
const uint32_t mTelemetryId;
const PersistenceType mPersistenceType;
const bool mFileHandleDisabled;
const bool mChromeWriteAccessAllowed;
@ -6313,7 +6297,6 @@ public:
const Maybe<ContentParentId>& aOptionalContentParentId,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
FullDatabaseMetadata* aMetadata,
FileManager* aFileManager,
already_AddRefed<DirectoryLock> aDirectoryLock,
@ -6372,12 +6355,6 @@ public:
return mId;
}
uint32_t
TelemetryId() const
{
return mTelemetryId;
}
PersistenceType
Type() const
{
@ -7673,8 +7650,6 @@ class OpenDatabaseOp final
// cycles.
VersionChangeOp* mVersionChangeOp;
uint32_t mTelemetryId;
public:
OpenDatabaseOp(Factory* aFactory,
already_AddRefed<ContentParent> aContentParent,
@ -10302,13 +10277,6 @@ typedef nsDataHashtable<nsIDHashKey, DatabaseLoggingInfo*>
StaticAutoPtr<DatabaseLoggingInfoHashtable> gLoggingInfoHashtable;
typedef nsDataHashtable<nsUint32HashKey, uint32_t> TelemetryIdHashtable;
StaticAutoPtr<TelemetryIdHashtable> gTelemetryIdHashtable;
// Protects all reads and writes to gTelemetryIdHashtable.
StaticAutoPtr<Mutex> gTelemetryIdMutex;
#ifdef DEBUG
StaticRefPtr<DEBUGThreadSlower> gDEBUGThreadSlower;
@ -10404,88 +10372,6 @@ DecreaseBusyCount()
}
}
uint32_t
TelemetryIdForFile(nsIFile* aFile)
{
// May be called on any thread!
MOZ_ASSERT(aFile);
MOZ_ASSERT(gTelemetryIdMutex);
// The storage directory is structured like this:
//
// <profile>/storage/<persistence>/<origin>/idb/<filename>.sqlite
//
// For the purposes of this function we're only concerned with the
// <persistence>, <origin>, and <filename> pieces.
nsString filename;
MOZ_ALWAYS_SUCCEEDS(aFile->GetLeafName(filename));
// Make sure we were given a database file.
NS_NAMED_LITERAL_STRING(sqliteExtension, ".sqlite");
MOZ_ASSERT(StringEndsWith(filename, sqliteExtension));
filename.Truncate(filename.Length() - sqliteExtension.Length());
// Get the "idb" directory.
nsCOMPtr<nsIFile> idbDirectory;
MOZ_ALWAYS_SUCCEEDS(aFile->GetParent(getter_AddRefs(idbDirectory)));
DebugOnly<nsString> idbLeafName;
MOZ_ASSERT(NS_SUCCEEDED(idbDirectory->GetLeafName(idbLeafName)));
MOZ_ASSERT(static_cast<nsString&>(idbLeafName).EqualsLiteral("idb"));
// Get the <origin> directory.
nsCOMPtr<nsIFile> originDirectory;
MOZ_ALWAYS_SUCCEEDS(
idbDirectory->GetParent(getter_AddRefs(originDirectory)));
nsString origin;
MOZ_ALWAYS_SUCCEEDS(originDirectory->GetLeafName(origin));
// Any databases in these directories are owned by the application and should
// not have their filenames masked. Hopefully they also appear in the
// Telemetry.cpp whitelist.
if (origin.EqualsLiteral("chrome") ||
origin.EqualsLiteral("moz-safe-about+home")) {
return 0;
}
// Get the <persistence> directory.
nsCOMPtr<nsIFile> persistenceDirectory;
MOZ_ALWAYS_SUCCEEDS(
originDirectory->GetParent(getter_AddRefs(persistenceDirectory)));
nsString persistence;
MOZ_ALWAYS_SUCCEEDS(persistenceDirectory->GetLeafName(persistence));
NS_NAMED_LITERAL_STRING(separator, "*");
uint32_t hashValue = HashString(persistence + separator +
origin + separator +
filename);
MutexAutoLock lock(*gTelemetryIdMutex);
if (!gTelemetryIdHashtable) {
gTelemetryIdHashtable = new TelemetryIdHashtable();
}
uint32_t id;
if (!gTelemetryIdHashtable->Get(hashValue, &id)) {
static uint32_t sNextId = 1;
// We're locked, no need for atomics.
id = sNextId++;
gTelemetryIdHashtable->Put(hashValue, id);
}
return id;
}
} // namespace
/*******************************************************************************
@ -12265,7 +12151,6 @@ ConnectionPool::GetOrCreateConnection(const Database* aDatabase,
aDatabase->Type(),
aDatabase->Group(),
aDatabase->Origin(),
aDatabase->TelemetryId(),
getter_AddRefs(storageConnection));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -14134,7 +14019,6 @@ Database::Database(Factory* aFactory,
const Maybe<ContentParentId>& aOptionalContentParentId,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId,
FullDatabaseMetadata* aMetadata,
FileManager* aFileManager,
already_AddRefed<DirectoryLock> aDirectoryLock,
@ -14151,7 +14035,6 @@ Database::Database(Factory* aFactory,
, mId(aMetadata->mDatabaseId)
, mFilePath(aMetadata->mFilePath)
, mActiveMutableFileCount(0)
, mTelemetryId(aTelemetryId)
, mPersistenceType(aMetadata->mCommonMetadata.persistenceType())
, mFileHandleDisabled(aFileHandleDisabled)
, mChromeWriteAccessAllowed(aChromeWriteAccessAllowed)
@ -17391,8 +17274,7 @@ FileManager::InitDirectory(nsIFile* aDirectory,
nsIFile* aDatabaseFile,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId)
const nsACString& aOrigin)
{
AssertIsOnIOThread();
MOZ_ASSERT(aDirectory);
@ -17464,7 +17346,6 @@ FileManager::InitDirectory(nsIFile* aDirectory,
aPersistenceType,
aGroup,
aOrigin,
aTelemetryId,
getter_AddRefs(connection));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -17648,11 +17529,6 @@ QuotaClient::QuotaClient()
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(!sInstance, "We expect this to be a singleton!");
MOZ_ASSERT(!gTelemetryIdMutex);
// Always create this so that later access to gTelemetryIdHashtable can be
// properly synchronized.
gTelemetryIdMutex = new Mutex("IndexedDB gTelemetryIdMutex");
sInstance = this;
}
@ -17661,14 +17537,8 @@ QuotaClient::~QuotaClient()
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(sInstance == this, "We expect this to be a singleton!");
MOZ_ASSERT(gTelemetryIdMutex);
MOZ_ASSERT(!mMaintenanceThreadPool);
// No one else should be able to touch gTelemetryIdHashtable now that the
// QuotaClient has gone away.
gTelemetryIdHashtable = nullptr;
gTelemetryIdMutex = nullptr;
sInstance = nullptr;
}
@ -17942,8 +17812,7 @@ QuotaClient::InitOrigin(PersistenceType aPersistenceType,
initInfo.mDatabaseFile,
aPersistenceType,
aGroup,
aOrigin,
TelemetryIdForFile(initInfo.mDatabaseFile));
aOrigin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -19036,7 +18905,6 @@ DatabaseMaintenance::PerformMaintenanceOnDatabase()
mPersistenceType,
mGroup,
mOrigin,
TelemetryIdForFile(databaseFile),
getter_AddRefs(connection));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
@ -21653,7 +21521,6 @@ OpenDatabaseOp::OpenDatabaseOp(Factory* aFactory,
, mMetadata(new FullDatabaseMetadata(aParams.metadata()))
, mRequestedVersion(aParams.metadata().version())
, mVersionChangeOp(nullptr)
, mTelemetryId(0)
{
if (mContentParent) {
// This is a little scary but it looks safe to call this off the main thread
@ -21762,8 +21629,6 @@ OpenDatabaseOp::DoDatabaseWork()
return rv;
}
mTelemetryId = TelemetryIdForFile(dbFile);
#ifdef DEBUG
nsString databaseFilePath;
rv = dbFile->GetPath(databaseFilePath);
@ -21794,7 +21659,6 @@ OpenDatabaseOp::DoDatabaseWork()
persistenceType,
mGroup,
mOrigin,
mTelemetryId,
getter_AddRefs(connection));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -22677,7 +22541,6 @@ OpenDatabaseOp::EnsureDatabaseActor()
mOptionalContentParentId,
mGroup,
mOrigin,
mTelemetryId,
mMetadata,
mFileManager,
mDirectoryLock.forget(),

View file

@ -58,8 +58,7 @@ public:
nsIFile* aDatabaseFile,
PersistenceType aPersistenceType,
const nsACString& aGroup,
const nsACString& aOrigin,
uint32_t aTelemetryId);
const nsACString& aOrigin);
static nsresult
GetUsage(nsIFile* aDirectory, uint64_t* aUsage);

View file

@ -84,7 +84,6 @@
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/WebBrowserPersistDocumentParent.h"
#include "mozilla/Unused.h"
#include "nsAnonymousTemporaryFile.h"
@ -3363,17 +3362,6 @@ ContentParent::RecvIsSecureURI(const uint32_t& type,
return NS_SUCCEEDED(rv);
}
bool
ContentParent::RecvAccumulateMixedContentHSTS(const URIParams& aURI, const bool& aActive)
{
nsCOMPtr<nsIURI> ourURI = DeserializeURI(aURI);
if (!ourURI) {
return false;
}
nsMixedContentBlocker::AccumulateMixedContentHSTS(ourURI, aActive);
return true;
}
bool
ContentParent::RecvLoadURIExternal(const URIParams& uri,
PBrowserParent* windowContext)
@ -4764,19 +4752,3 @@ ContentParent::ForceTabPaint(TabParent* aTabParent, uint64_t aLayerObserverEpoch
}
ProcessHangMonitor::ForcePaint(mHangMonitorActor, aTabParent, aLayerObserverEpoch);
}
bool
ContentParent::RecvAccumulateChildHistogram(
InfallibleTArray<Accumulation>&& aAccumulations)
{
/* STUB */
return true;
}
bool
ContentParent::RecvAccumulateChildKeyedHistogram(
InfallibleTArray<KeyedAccumulation>&& aAccumulations)
{
/* STUB */
return true;
}

View file

@ -741,9 +741,6 @@ private:
virtual bool RecvIsSecureURI(const uint32_t& aType, const URIParams& aURI,
const uint32_t& aFlags, bool* aIsSecureURI) override;
virtual bool RecvAccumulateMixedContentHSTS(const URIParams& aURI,
const bool& aActive) override;
virtual bool DeallocPHalParent(PHalParent*) override;
virtual bool
@ -1044,10 +1041,6 @@ private:
virtual bool RecvDeleteGetFilesRequest(const nsID& aID) override;
virtual bool RecvAccumulateChildHistogram(
InfallibleTArray<Accumulation>&& aAccumulations) override;
virtual bool RecvAccumulateChildKeyedHistogram(
InfallibleTArray<KeyedAccumulation>&& aAccumulations) override;
public:
void SendGetFilesResponseAndForget(const nsID& aID,
const GetFilesResponseResult& aResult);

View file

@ -89,8 +89,6 @@ using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h";
using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
using struct mozilla::dom::FlyWebPublishOptions from "mozilla/dom/FlyWebPublishOptionsIPCSerializer.h";
using mozilla::Telemetry::Accumulation from "mozilla/TelemetryComms.h";
using mozilla::Telemetry::KeyedAccumulation from "mozilla/TelemetryComms.h";
union ChromeRegistryItem
{
@ -658,8 +656,6 @@ parent:
sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags)
returns (bool isSecureURI);
async AccumulateMixedContentHSTS(URIParams uri, bool active);
sync GetLookAndFeelCache()
returns (LookAndFeelInt[] lookAndFeelIntCache);
@ -1022,12 +1018,6 @@ parent:
async UnstoreAndBroadcastBlobURLUnregistration(nsCString url);
/**
* Messages for communicating child Telemetry to the parent process
*/
async AccumulateChildHistogram(Accumulation[] accumulations);
async AccumulateChildKeyedHistogram(KeyedAccumulation[] accumulations);
sync GetA11yContentId() returns (uint32_t aContentId);
both:

View file

@ -10,7 +10,6 @@
#include "nsCharSeparatedTokenizer.h"
#include "nsMimeTypes.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "OggDecoder.h"
#include "OggDemuxer.h"
@ -85,22 +84,6 @@ DecoderTraits::IsWebMAudioType(const nsACString& aType)
return aType.EqualsASCII("audio/webm");
}
static char const *const gHttpLiveStreamingTypes[] = {
// For m3u8.
// https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10
"application/vnd.apple.mpegurl",
// Some sites serve these as the informal m3u type.
"application/x-mpegurl",
"audio/x-mpegurl",
nullptr
};
static bool
IsHttpLiveStreamingType(const nsACString& aType)
{
return CodecListContains(gHttpLiveStreamingTypes, aType);
}
#ifdef MOZ_FMP4
static bool
IsMP4SupportedType(const MediaContentType& aParsedType,
@ -247,10 +230,6 @@ CanHandleMediaType(const MediaContentType& aType,
{
MOZ_ASSERT(NS_IsMainThread());
if (IsHttpLiveStreamingType(aType.GetMIMEType())) {
/* Telemetry STUB */
}
if (aType.HaveCodecs()) {
CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
if (result == CANPLAY_NO || result == CANPLAY_YES) {

View file

@ -629,7 +629,6 @@ AudioCallbackDriver::Init()
cubeb_stream_params output;
cubeb_stream_params input;
uint32_t latency_frames;
bool firstStream = CubebUtils::GetFirstStream();
MOZ_ASSERT(!NS_IsMainThread(),
"This is blocking and should never run on the main thread.");

View file

@ -30,7 +30,6 @@
#include "mozilla/dom/VideoTrack.h"
#include "mozilla/dom/VideoTrackList.h"
#include "nsPrintfCString.h"
#include "mozilla/Telemetry.h"
#include "GMPService.h"
#include "Layers.h"
#include "mozilla/layers/ShadowLayers.h"
@ -421,7 +420,6 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
, INIT_CANONICAL(mPlaybackRateReliable, true)
, INIT_CANONICAL(mDecoderPosition, 0)
, INIT_CANONICAL(mIsVisible, !aOwner->IsHidden())
, mTelemetryReported(false)
{
MOZ_COUNT_CTOR(MediaDecoder);
MOZ_ASSERT(NS_IsMainThread());
@ -841,41 +839,6 @@ MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
// So we call Invalidate() after calling mOwner->MetadataLoaded to ensure
// the media element has the latest dimensions.
Invalidate();
EnsureTelemetryReported();
}
void
MediaDecoder::EnsureTelemetryReported()
{
MOZ_ASSERT(NS_IsMainThread());
if (mTelemetryReported || !mInfo) {
// Note: sometimes we get multiple MetadataLoaded calls (for example
// for chained ogg). So we ensure we don't report duplicate results for
// these resources.
return;
}
nsTArray<nsCString> codecs;
if (mInfo->HasAudio() && !mInfo->mAudio.GetAsAudioInfo()->mMimeType.IsEmpty()) {
codecs.AppendElement(mInfo->mAudio.GetAsAudioInfo()->mMimeType);
}
if (mInfo->HasVideo() && !mInfo->mVideo.GetAsVideoInfo()->mMimeType.IsEmpty()) {
codecs.AppendElement(mInfo->mVideo.GetAsVideoInfo()->mMimeType);
}
if (codecs.IsEmpty()) {
if (mResource->GetContentType().IsEmpty()) {
NS_WARNING("Somehow the resource's content type is empty");
return;
}
codecs.AppendElement(nsPrintfCString("resource; %s", mResource->GetContentType().get()));
}
for (const nsCString& codec : codecs) {
DECODER_LOG("Telemetry MEDIA_CODEC_USED= '%s'", codec.get());
}
mTelemetryReported = true;
}
const char*

View file

@ -440,8 +440,6 @@ private:
void SetCDMProxy(CDMProxy* aProxy);
void EnsureTelemetryReported();
static bool IsOggEnabled();
static bool IsOpusEnabled();
static bool IsWaveEnabled();
@ -852,8 +850,6 @@ private:
// download has ended. Called on the main thread only. aStatus is
// the result from OnStopRequest.
void NotifyDownloadEnded(nsresult aStatus);
bool mTelemetryReported;
};
} // namespace mozilla

View file

@ -1173,27 +1173,12 @@ StateObject::HandleShutdown()
return SetState<ShutdownState>();
}
static void
ReportRecoveryTelemetry(const TimeStamp& aRecoveryStart,
const MediaInfo& aMediaInfo,
bool aIsHardwareAccelerated)
{
/* STUB */
}
void
MediaDecoderStateMachine::
StateObject::HandleResumeVideoDecoding()
{
MOZ_ASSERT(mMaster->mVideoDecodeSuspended);
// Start counting recovery time from right now.
TimeStamp start = TimeStamp::Now();
// Local reference to mInfo, so that it will be copied in the lambda below.
auto& info = Info();
bool hw = Reader()->VideoIsHardwareAccelerated();
// Start video-only seek to the current time.
SeekJob seekJob;
@ -1205,10 +1190,7 @@ StateObject::HandleResumeVideoDecoding()
type,
true /* aVideoOnly */);
SetState<SeekingState>(Move(seekJob), EventVisibility::Suppressed)->Then(
AbstractThread::MainThread(), __func__,
[start, info, hw](){ ReportRecoveryTelemetry(start, info, hw); },
[](){});
SetState<SeekingState>(Move(seekJob), EventVisibility::Suppressed);
}
void

View file

@ -2035,7 +2035,6 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
}
// Determine permissions early (while we still have a stack).
nsIURI* docURI = aWindow->GetDocumentURI();
if (!docURI) {
return NS_ERROR_UNEXPECTED;
@ -2045,22 +2044,9 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
Preferences::GetBool("media.navigator.permission.disabled", false);
bool isHTTPS = false;
docURI->SchemeIs("https", &isHTTPS);
nsCString host;
nsresult rv = docURI->GetHost(host);
// Test for some other schemes that ServiceWorker recognizes
bool isFile;
docURI->SchemeIs("file", &isFile);
bool isApp;
docURI->SchemeIs("app", &isApp);
// Same localhost check as ServiceWorkers uses
// (see IsOriginPotentiallyTrustworthy())
bool isLocalhost = NS_SUCCEEDED(rv) &&
(host.LowerCaseEqualsLiteral("localhost") ||
host.LowerCaseEqualsLiteral("127.0.0.1") ||
host.LowerCaseEqualsLiteral("::1"));
nsCString origin;
rv = nsPrincipal::GetOriginForURI(docURI, origin);
nsresult rv = nsPrincipal::GetOriginForURI(docURI, origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View file

@ -16,9 +16,6 @@
#include "mp4_demuxer/Index.h"
#include "nsPrintfCString.h"
// Used for telemetry
#include "mozilla/Telemetry.h"
#include "mp4_demuxer/AnnexB.h"
#include "mp4_demuxer/H264.h"
#include "nsAutoPtr.h"
@ -72,23 +69,10 @@ private:
// Queued samples extracted by the demuxer, but not yet returned.
RefPtr<MediaRawData> mQueuedSample;
bool mNeedReIndex;
bool mNeedSPSForTelemetry;
bool mIsH264 = false;
};
// Returns true if no SPS was found and search for it should continue.
bool
AccumulateSPSTelemetry(const MediaByteBuffer* aExtradata)
{
// XXX: Do we still need this without telemetry?
mp4_demuxer::SPSData spsdata;
if (mp4_demuxer::H264::DecodeSPSFromExtraData(aExtradata, spsdata)) {
return false;
}
return true;
}
MP4Demuxer::MP4Demuxer(MediaResource* aResource)
: mResource(aResource)
, mStream(new mp4_demuxer::ResourceStream(aResource))
@ -219,25 +203,10 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent,
EnsureUpToDateIndex(); // Force update of index
VideoInfo* videoInfo = mInfo->GetAsVideoInfo();
// Collect telemetry from h264 AVCC SPS.
if (videoInfo &&
(mInfo->mMimeType.EqualsLiteral("video/mp4") ||
mInfo->mMimeType.EqualsLiteral("video/avc"))) {
mIsH264 = true;
RefPtr<MediaByteBuffer> extraData = videoInfo->mExtraData;
mNeedSPSForTelemetry = AccumulateSPSTelemetry(extraData);
mp4_demuxer::SPSData spsdata;
if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) &&
spsdata.pic_width > 0 && spsdata.pic_height > 0 &&
mp4_demuxer::H264::EnsureSPSIsSane(spsdata)) {
videoInfo->mImage.width = spsdata.pic_width;
videoInfo->mImage.height = spsdata.pic_height;
videoInfo->mDisplay.width = spsdata.display_width;
videoInfo->mDisplay.height = spsdata.display_height;
}
} else {
// No SPS to be found.
mNeedSPSForTelemetry = false;
}
}
@ -364,15 +333,6 @@ MP4TrackDemuxer::GetSamples(int32_t aNumSamples)
if (samples->mSamples.IsEmpty()) {
return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
} else {
for (const auto& sample : samples->mSamples) {
// Collect telemetry from h264 Annex B SPS.
if (mNeedSPSForTelemetry && mp4_demuxer::AnnexB::HasSPS(sample)) {
RefPtr<MediaByteBuffer> extradata =
mp4_demuxer::AnnexB::ExtractExtraData(sample);
mNeedSPSForTelemetry = AccumulateSPSTelemetry(extradata);
}
}
if (mNextKeyframeTime.isNothing() ||
samples->mSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) {
SetNextKeyFrameTime();

View file

@ -38,39 +38,6 @@ WMFMediaDataDecoder::Init()
return InitPromise::CreateAndResolve(mMFTManager->GetType(), __func__);
}
// A single telemetry sample is reported for each MediaDataDecoder object
// that has detected error or produced output successfully.
static void
SendTelemetry(unsigned long hr)
{
// Collapse the error codes into a range of 0-0xff that can be viewed in
// telemetry histograms. For most MF_E_* errors, unique samples are used,
// retaining the least significant 7 or 8 bits. Other error codes are
// bucketed.
uint32_t sample;
if (SUCCEEDED(hr)) {
sample = 0;
} else if (hr < 0xc00d36b0) {
sample = 1; // low bucket
} else if (hr < 0xc00d3700) {
sample = hr & 0xffU; // MF_E_*
} else if (hr <= 0xc00d3705) {
sample = 0x80 + (hr & 0xfU); // more MF_E_*
} else if (hr < 0xc00d6d60) {
sample = 2; // mid bucket
} else if (hr <= 0xc00d6d78) {
sample = hr & 0xffU; // MF_E_TRANSFORM_*
} else {
sample = 3; // high bucket
}
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction(
[sample] {
/* Telemetry STUB */
});
NS_DispatchToMainThread(runnable);
}
void
WMFMediaDataDecoder::Shutdown()
{
@ -90,9 +57,6 @@ WMFMediaDataDecoder::ProcessShutdown()
if (mMFTManager) {
mMFTManager->Shutdown();
mMFTManager = nullptr;
if (!mRecordedError && mHasSuccessfulOutput) {
SendTelemetry(S_OK);
}
}
}
@ -124,10 +88,6 @@ WMFMediaDataDecoder::ProcessDecode(MediaRawData* aSample)
NS_WARNING("MFTManager rejected sample");
mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("MFTManager::Input:%x", hr)));
if (!mRecordedError) {
SendTelemetry(hr);
mRecordedError = true;
}
return;
}
@ -143,7 +103,6 @@ WMFMediaDataDecoder::ProcessOutput()
HRESULT hr = S_OK;
while (SUCCEEDED(hr = mMFTManager->Output(mLastStreamOffset, output)) &&
output) {
mHasSuccessfulOutput = true;
mCallback->Output(output);
}
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
@ -152,10 +111,6 @@ WMFMediaDataDecoder::ProcessOutput()
NS_WARNING("WMFMediaDataDecoder failed to output data");
mCallback->Error(MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("MFTManager::Output:%x", hr)));
if (!mRecordedError) {
SendTelemetry(hr);
mRecordedError = true;
}
}
}

View file

@ -136,10 +136,6 @@ private:
Atomic<bool> mIsFlushing;
bool mIsShutDown;
// For telemetry
bool mHasSuccessfulOutput = false;
bool mRecordedError = false;
};
} // namespace mozilla

View file

@ -11,7 +11,6 @@
#include "mozilla/OwningNonNull.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
@ -656,172 +655,6 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
aTypes);
}
NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
NotificationTelemetryService::NotificationTelemetryService()
: mDNDRecorded(false)
{}
NotificationTelemetryService::~NotificationTelemetryService()
{
Unused << NS_WARN_IF(NS_FAILED(RemovePermissionChangeObserver()));
}
/* static */ already_AddRefed<NotificationTelemetryService>
NotificationTelemetryService::GetInstance()
{
nsCOMPtr<nsISupports> telemetrySupports =
do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID);
if (!telemetrySupports) {
return nullptr;
}
RefPtr<NotificationTelemetryService> telemetry =
static_cast<NotificationTelemetryService*>(telemetrySupports.get());
return telemetry.forget();
}
nsresult
NotificationTelemetryService::Init()
{
nsresult rv = AddPermissionChangeObserver();
NS_ENSURE_SUCCESS(rv, rv);
RecordPermissions();
return NS_OK;
}
nsresult
NotificationTelemetryService::RemovePermissionChangeObserver()
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) {
return NS_ERROR_OUT_OF_MEMORY;
}
return obs->RemoveObserver(this, "perm-changed");
}
nsresult
NotificationTelemetryService::AddPermissionChangeObserver()
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) {
return NS_ERROR_OUT_OF_MEMORY;
}
return obs->AddObserver(this, "perm-changed", false);
}
void
NotificationTelemetryService::RecordPermissions()
{
if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) {
return;
}
nsCOMPtr<nsIPermissionManager> permissionManager =
services::GetPermissionManager();
if (!permissionManager) {
return;
}
nsCOMPtr<nsISimpleEnumerator> enumerator;
nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
for (;;) {
bool hasMoreElements;
nsresult rv = enumerator->HasMoreElements(&hasMoreElements);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
if (!hasMoreElements) {
break;
}
nsCOMPtr<nsISupports> supportsPermission;
rv = enumerator->GetNext(getter_AddRefs(supportsPermission));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
uint32_t capability;
if (!GetNotificationPermission(supportsPermission, &capability)) {
continue;
}
}
}
bool
NotificationTelemetryService::GetNotificationPermission(nsISupports* aSupports,
uint32_t* aCapability)
{
nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
if (!permission) {
return false;
}
nsAutoCString type;
permission->GetType(type);
if (!type.Equals("desktop-notification")) {
return false;
}
permission->GetCapability(aCapability);
return true;
}
void
NotificationTelemetryService::RecordDNDSupported()
{
if (mDNDRecorded) {
return;
}
nsCOMPtr<nsIAlertsService> alertService =
do_GetService(NS_ALERTSERVICE_CONTRACTID);
if (!alertService) {
return;
}
nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND =
do_QueryInterface(alertService);
if (!alertServiceDND) {
return;
}
mDNDRecorded = true;
bool isEnabled;
nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled);
if (NS_FAILED(rv)) {
return;
}
}
nsresult
NotificationTelemetryService::RecordSender(nsIPrincipal* aPrincipal)
{
if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended() ||
!nsAlertsUtils::IsActionablePrincipal(aPrincipal)) {
return NS_OK;
}
nsAutoString origin;
nsresult rv = Notification::GetOrigin(aPrincipal, origin);
if (NS_FAILED(rv)) {
return rv;
}
if (!mOrigins.Contains(origin)) {
mOrigins.PutEntry(origin);
}
return NS_OK;
}
NS_IMETHODIMP
NotificationTelemetryService::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
/* STUB */
return NS_OK;
}
// Observer that the alert service calls to do common tasks and/or dispatch to the
// specific observer for the context e.g. main thread, worker, or service worker.
class NotificationObserver final : public nsIObserver
@ -1402,8 +1235,6 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
} else if (!strcmp("alertshow", aTopic) ||
!strcmp("alertfinished", aTopic)) {
RefPtr<NotificationTelemetryService> telemetry =
NotificationTelemetryService::GetInstance();
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
}

View file

@ -18,9 +18,6 @@
#include "nsTHashtable.h"
#include "nsWeakReference.h"
#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
"@mozilla.org/notificationTelemetryService;1"
class nsIPrincipal;
class nsIVariant;
@ -49,36 +46,6 @@ public:
Notify(workers::Status aStatus) override;
};
// Records telemetry probes at application startup, when a notification is
// shown, and when the notification permission is revoked for a site.
class NotificationTelemetryService final : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NotificationTelemetryService();
static already_AddRefed<NotificationTelemetryService> GetInstance();
nsresult Init();
void RecordDNDSupported();
void RecordPermissions();
nsresult RecordSender(nsIPrincipal* aPrincipal);
private:
virtual ~NotificationTelemetryService();
nsresult AddPermissionChangeObserver();
nsresult RemovePermissionChangeObserver();
bool GetNotificationPermission(nsISupports* aSupports,
uint32_t* aCapability);
bool mDNDRecorded;
nsTHashtable<nsStringHashKey> mOrigins;
};
/*
* Notifications on workers introduce some lifetime issues. The property we
* are trying to satisfy is:
@ -143,7 +110,6 @@ class Notification : public DOMEventTargetHelper
friend class ServiceWorkerNotificationObserver;
friend class WorkerGetRunnable;
friend class WorkerNotificationObserver;
friend class NotificationTelemetryService;
public:
IMPL_EVENT_HANDLER(click)

View file

@ -92,11 +92,6 @@ mozilla::plugins::SetupBridge(uint32_t aPluginId,
return true;
}
PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary());
/*
* We can't accumulate BLOCKED_ON_PLUGIN_MODULE_INIT_MS until here because
* its histogram key is not available until *after* NP_Initialize.
*/
chromeParent->AccumulateModuleInitBlockedTime();
*rv = chromeParent->GetRunID(runID);
if (NS_FAILED(*rv)) {
return true;
@ -335,16 +330,13 @@ PluginModuleContentParent::LoadModule(uint32_t aPluginId,
dom::ContentChild* cp = dom::ContentChild::GetSingleton();
nsresult rv;
uint32_t runID;
TimeStamp sendLoadPluginStart = TimeStamp::Now();
if (!cp->SendLoadPlugin(aPluginId, &rv, &runID) ||
NS_FAILED(rv)) {
return nullptr;
}
TimeStamp sendLoadPluginEnd = TimeStamp::Now();
PluginModuleContentParent* parent = mapping->GetModule();
MOZ_ASSERT(parent);
parent->mTimeBlocked += (sendLoadPluginEnd - sendLoadPluginStart);
if (!mapping->IsChannelOpened()) {
// mapping is linked into PluginModuleMapping::sModuleListHead and is
@ -440,7 +432,6 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId,
aPluginTag->mSupportsAsyncInit));
UniquePtr<LaunchCompleteTask> onLaunchedRunnable(new LaunchedTask(parent));
parent->mSubprocess->SetCallRunnableImmediately(!parent->mIsStartingAsync);
TimeStamp launchStart = TimeStamp::Now();
bool launched = parent->mSubprocess->Launch(Move(onLaunchedRunnable),
aPluginTag->mSandboxLevel);
if (!launched) {
@ -459,8 +450,6 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId,
return nullptr;
}
}
TimeStamp launchEnd = TimeStamp::Now();
parent->mTimeBlocked = (launchEnd - launchStart);
return parent.forget();
}
@ -1758,15 +1747,12 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs*
PluginSettings settings;
GetSettings(&settings);
TimeStamp callNpInitStart = TimeStamp::Now();
// Asynchronous case
if (mIsStartingAsync) {
if (!SendAsyncNP_Initialize(settings)) {
Close();
return NS_ERROR_FAILURE;
}
TimeStamp callNpInitEnd = TimeStamp::Now();
mTimeBlocked += (callNpInitEnd - callNpInitStart);
return NS_OK;
}
@ -1779,8 +1765,6 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs*
Close();
return NS_ERROR_FAILURE;
}
TimeStamp callNpInitEnd = TimeStamp::Now();
mTimeBlocked += (callNpInitEnd - callNpInitStart);
RecvNP_InitializeResult(*error);
@ -1882,13 +1866,10 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
PluginSettings settings;
GetSettings(&settings);
TimeStamp callNpInitStart = TimeStamp::Now();
if (mIsStartingAsync) {
if (!SendAsyncNP_Initialize(settings)) {
return NS_ERROR_FAILURE;
}
TimeStamp callNpInitEnd = TimeStamp::Now();
mTimeBlocked += (callNpInitEnd - callNpInitStart);
return NS_OK;
}
@ -1896,8 +1877,6 @@ PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
Close();
return NS_ERROR_FAILURE;
}
TimeStamp callNpInitEnd = TimeStamp::Now();
mTimeBlocked += (callNpInitEnd - callNpInitStart);
RecvNP_InitializeResult(*error);
return NS_OK;
}
@ -2194,14 +2173,6 @@ public:
}
};
void
PluginModuleParent::AccumulateModuleInitBlockedTime()
{
// XXX: mTimeBlocked can probably go if not used for anything besides
// telemetry.
mTimeBlocked = TimeDuration();
}
nsresult
PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
uint16_t mode,
@ -2213,13 +2184,6 @@ PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
if (mPluginName.IsEmpty()) {
GetPluginDetails();
InitQuirksModes(nsDependentCString(pluginType));
/** mTimeBlocked measures the time that the main thread has been blocked
* on plugin module initialization. As implemented, this is the sum of
* plugin-container launch + toolhelp32 snapshot + NP_Initialize.
* We don't accumulate its value until here because the plugin info
* for its histogram key is not available until *after* NP_Initialize.
*/
AccumulateModuleInitBlockedTime();
}
nsCaseInsensitiveUTF8StringArrayComparator comparator;

View file

@ -115,8 +115,6 @@ public:
return mPluginName + mPluginVersion;
}
void AccumulateModuleInitBlockedTime();
virtual nsresult GetRunID(uint32_t* aRunID) override;
virtual void SetHasLocalInstance() override {
mHadLocalInstance = true;
@ -315,7 +313,6 @@ protected:
nsString mBrowserDumpID;
nsString mHangID;
RefPtr<nsIObserver> mProfilerObserver;
TimeDuration mTimeBlocked;
nsCString mPluginName;
nsCString mPluginVersion;
int32_t mSandboxLevel;

View file

@ -35,7 +35,6 @@
#include "nsISiteSecurityService.h"
#include "mozilla/Logging.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/ipc/URIUtils.h"
@ -814,17 +813,13 @@ nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect,
//
// We do not count requests aHadInsecureImageRedirect=true, since these are
// just an artifact of the image caching system.
bool active = (classification == eMixedScript);
if (!aHadInsecureImageRedirect) {
if (XRE_IsParentProcess()) {
AccumulateMixedContentHSTS(innerContentLocation, active);
} else {
if (!XRE_IsParentProcess()) {
// Ask the parent process to do the same call
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
if (cc) {
mozilla::ipc::URIParams uri;
SerializeURI(innerContentLocation, uri);
cc->SendAccumulateMixedContentHSTS(uri, active);
}
}
}
@ -977,11 +972,3 @@ enum MixedContentHSTSState {
MCB_HSTS_ACTIVE_NO_HSTS = 2,
MCB_HSTS_ACTIVE_WITH_HSTS = 3
};
// Record information on when HSTS would have made mixed content not mixed
// content (regardless of whether it was actually blocked)
void
nsMixedContentBlocker::AccumulateMixedContentHSTS(nsIURI* aURI, bool aActive)
{
/* STUB */
}

View file

@ -61,9 +61,6 @@ public:
nsISupports* aExtra,
nsIPrincipal* aRequestPrincipal,
int16_t* aDecision);
static void AccumulateMixedContentHSTS(nsIURI* aURI,
bool aActive);
static bool sBlockMixedScript;
static bool sBlockMixedDisplay;

View file

@ -85,7 +85,6 @@ DOMStorageCache::DOMStorageCache(const nsACString* aOriginNoSuffix)
, mInitialized(false)
, mPersistent(false)
, mSessionOnlyDataSetActive(false)
, mPreloadTelemetryRecorded(false)
{
MOZ_COUNT_CTOR(DOMStorageCache);
}
@ -178,7 +177,7 @@ DOMStorageCache::DataSet(const DOMStorage* aStorage)
// Session only data set is demanded but not filled with
// current data set, copy to session only set now.
WaitForPreload(Telemetry::LOCALDOMSTORAGE_SESSIONONLY_PRELOAD_BLOCKING_MS);
WaitForPreload();
Data& defaultSet = mData[kDefaultSet];
Data& sessionSet = mData[kSessionSet];
@ -298,46 +297,18 @@ DOMStorageCache::KeepAlive()
mKeepAliveTimer.swap(timer);
}
namespace {
// The AutoTimer provided by telemetry headers is only using static,
// i.e. compile time known ID, but here we know the ID only at run time.
// Hence a new class.
class TelemetryAutoTimer
{
public:
explicit TelemetryAutoTimer(Telemetry::ID aId)
: id(aId), start(TimeStamp::Now()) {}
~TelemetryAutoTimer()
{ /* STUB */ }
private:
Telemetry::ID id;
const TimeStamp start;
};
} // namespace
void
DOMStorageCache::WaitForPreload(Telemetry::ID aTelemetryID)
DOMStorageCache::WaitForPreload()
{
if (!mPersistent) {
return;
}
bool loaded = mLoaded;
// Telemetry of rates of pending preloads
if (!mPreloadTelemetryRecorded) {
mPreloadTelemetryRecorded = true;
}
if (loaded) {
return;
}
// Measure which operation blocks and for how long
TelemetryAutoTimer timer(aTelemetryID);
// If preload already started (i.e. we got some first data, but not all)
// SyncPreload will just wait for it to finish rather then synchronously
// read from the database. It seems to me more optimal.
@ -354,7 +325,7 @@ nsresult
DOMStorageCache::GetLength(const DOMStorage* aStorage, uint32_t* aRetval)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETLENGTH_BLOCKING_MS);
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
@ -372,7 +343,7 @@ DOMStorageCache::GetKey(const DOMStorage* aStorage, uint32_t aIndex, nsAString&
// maybe we need to have a lazily populated key array here or
// something?
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETKEY_BLOCKING_MS);
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
@ -394,7 +365,7 @@ void
DOMStorageCache::GetKeys(const DOMStorage* aStorage, nsTArray<nsString>& aKeys)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETALLKEYS_BLOCKING_MS);
WaitForPreload();
}
if (NS_FAILED(mLoadResult)) {
@ -411,7 +382,7 @@ DOMStorageCache::GetItem(const DOMStorage* aStorage, const nsAString& aKey,
nsAString& aRetval)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETVALUE_BLOCKING_MS);
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
@ -436,7 +407,7 @@ DOMStorageCache::SetItem(const DOMStorage* aStorage, const nsAString& aKey,
int64_t delta = 0;
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS);
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
@ -485,7 +456,7 @@ DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey,
nsString& aOld)
{
if (Persist(aStorage)) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS);
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
return mLoadResult;
}
@ -524,9 +495,8 @@ DOMStorageCache::Clear(const DOMStorage* aStorage)
// We need to preload all data (know the size) before we can proceeed
// to correctly decrease cached usage number.
// XXX as in case of unload, this is not technically needed now, but
// after super-scope quota introduction we have to do this. Get telemetry
// right now.
WaitForPreload(Telemetry::LOCALDOMSTORAGE_CLEAR_BLOCKING_MS);
// after super-scope quota introduction we have to do this.
WaitForPreload();
if (NS_FAILED(mLoadResult)) {
// When we failed to load data from the database, force delete of the
// scope data and make use of the storage possible again.
@ -596,9 +566,8 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags)
// Must wait for preload to pass correct usage to ProcessUsageDelta
// XXX this is not technically needed right now since there is just
// per-origin isolated quota handling, but when we introduce super-
// -scope quotas, we have to do this. Better to start getting
// telemetry right now.
WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS);
// -scope quotas, we have to do this.
WaitForPreload();
mData[kDefaultSet].mKeys.Clear();
ProcessUsageDelta(kDefaultSet, -mData[kDefaultSet].mOriginQuotaUsage);
@ -617,7 +586,7 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags)
#ifdef DOM_STORAGE_TESTS
if (aUnloadFlags & kTestReload) {
WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS);
WaitForPreload();
mData[kDefaultSet].mKeys.Clear();
mLoaded = false; // This is only used in testing code

View file

@ -14,7 +14,6 @@
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "mozilla/Monitor.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Atomics.h"
namespace mozilla {
@ -168,7 +167,7 @@ private:
private:
// Synchronously blocks until the cache is fully loaded from the database
void WaitForPreload(mozilla::Telemetry::ID aTelemetryID);
void WaitForPreload();
// Helper to get one of the 3 data sets (regular, private, session)
Data& DataSet(const DOMStorage* aStorage);
@ -241,9 +240,6 @@ private:
// Drops back to false when session-only data are cleared from chrome.
bool mSessionOnlyDataSetActive : 1;
// Whether we have already captured state of the cache preload on our first access.
bool mPreloadTelemetryRecorded : 1;
// DOMStorageDBThread on the parent or single process,
// DOMStorageDBChild on the child process.
static DOMStorageDBBridge* sDatabase;

View file

@ -1530,7 +1530,6 @@ RuntimeService::RegisterWorker(WorkerPrivate* aWorkerPrivate)
const bool isServiceWorker = aWorkerPrivate->IsServiceWorker();
const bool isSharedWorker = aWorkerPrivate->IsSharedWorker();
const bool isDedicatedWorker = aWorkerPrivate->IsDedicatedWorker();
if (isServiceWorker) {
AssertIsOnMainThread();
}