Bug 1388391 - Track DOMError usage with telemetry; r?smaug,francois
MozReview-Commit-ID: A0kH6xsg4mm
--- a/dom/base/DOMError.cpp
+++ b/dom/base/DOMError.cpp
@@ -2,16 +2,17 @@
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/DOMError.h"
#include "mozilla/dom/DOMErrorBinding.h"
#include "mozilla/dom/DOMException.h"
+#include "mozilla/UseCounter.h"
#include "nsPIDOMWindow.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMError, mWindow)
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMError)
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMError)
@@ -62,16 +63,23 @@ DOMError::WrapObject(JSContext* aCx, JS:
/* static */ already_AddRefed<DOMError>
DOMError::Constructor(const GlobalObject& aGlobal,
const nsAString& aName, const nsAString& aMessage,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
+ if (window) {
+ nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
+ if (doc) {
+ doc->SetDocumentAndPageUseCounter(eUseCounter_custom_DOMErrorConstructor);
+ }
+ }
+
// Window is null for chrome code.
RefPtr<DOMError> ret = new DOMError(window, aName, aMessage);
return ret.forget();
}
} // namespace dom
} // namespace mozilla
--- a/dom/base/UseCounters.conf
+++ b/dom/base/UseCounters.conf
@@ -44,16 +44,19 @@
// annotating the WebIDL files does nothing for identifying CSS
// property usage, which we would also like to track.
method SVGSVGElement.getElementById
attribute SVGSVGElement.currentScale
property Fill
property FillOpacity
attribute XMLDocument.async
+attribute DOMError.name
+attribute DOMError.message
+custom DOMErrorConstructor constructed a DOMError
// Push API
method PushManager.subscribe
method PushSubscription.unsubscribe
// window.sidebar.addSearchEngine
attribute Window.sidebar
method External.addSearchEngine
--- a/dom/webidl/DOMError.webidl
+++ b/dom/webidl/DOMError.webidl
@@ -8,14 +8,14 @@
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Constructor(DOMString name, optional DOMString message = ""),
Exposed=(Window,Worker,System)]
interface DOMError {
- [Constant]
+ [Constant, UseCounter]
readonly attribute DOMString name;
- [Constant]
+ [Constant, UseCounter]
readonly attribute DOMString message;
};