Bug 1603187 - P1. Add IPDL serialiser for nsDOMNavigationTiming object. r=mattwoodrow,smaug
Differential Revision: https://phabricator.services.mozilla.com/D57770
This commit is contained in:
@@ -7,17 +7,18 @@
|
|||||||
#include "nsDOMNavigationTiming.h"
|
#include "nsDOMNavigationTiming.h"
|
||||||
|
|
||||||
#include "GeckoProfiler.h"
|
#include "GeckoProfiler.h"
|
||||||
|
#include "mozilla/Telemetry.h"
|
||||||
|
#include "mozilla/TimeStamp.h"
|
||||||
|
#include "mozilla/dom/PerformanceNavigation.h"
|
||||||
|
#include "mozilla/ipc/IPDLParamTraits.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsDocShell.h"
|
#include "nsDocShell.h"
|
||||||
#include "nsHttp.h"
|
#include "nsHttp.h"
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "prtime.h"
|
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
#include "mozilla/dom/PerformanceNavigation.h"
|
#include "prtime.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
|
||||||
#include "mozilla/Telemetry.h"
|
|
||||||
#ifdef MOZ_GECKO_PROFILER
|
#ifdef MOZ_GECKO_PROFILER
|
||||||
# include "ProfilerMarkerPayload.h"
|
# include "ProfilerMarkerPayload.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -533,3 +534,74 @@ bool nsDOMNavigationTiming::IsTopLevelContentDocumentInContentProcess() const {
|
|||||||
}
|
}
|
||||||
return mDocShell->GetBrowsingContext()->IsTopContent();
|
return mDocShell->GetBrowsingContext()->IsTopContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void mozilla::ipc::IPDLParamTraits<nsDOMNavigationTiming*>::Write(
|
||||||
|
IPC::Message* aMsg, IProtocol* aActor, nsDOMNavigationTiming* aParam) {
|
||||||
|
RefPtr<nsIURI> unloadedURI = aParam->mUnloadedURI.get();
|
||||||
|
RefPtr<nsIURI> loadedURI = aParam->mLoadedURI.get();
|
||||||
|
WriteIPDLParam(aMsg, aActor, unloadedURI ? Some(unloadedURI) : Nothing());
|
||||||
|
WriteIPDLParam(aMsg, aActor, loadedURI ? Some(loadedURI) : Nothing());
|
||||||
|
WriteIPDLParam(aMsg, aActor, uint32_t(aParam->mNavigationType));
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mNavigationStartHighRes);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mNavigationStart);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mNonBlankPaint);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mContentfulPaint);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMContentFlushed);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mBeforeUnloadStart);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mUnloadStart);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mUnloadEnd);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mLoadEventStart);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mLoadEventEnd);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMLoading);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMInteractive);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMContentLoadedEventStart);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMContentLoadedEventEnd);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mDOMComplete);
|
||||||
|
WriteIPDLParam(aMsg, aActor, aParam->mTTFI);
|
||||||
|
WriteIPDLParam(aMsg, aActor,
|
||||||
|
aParam->mDocShellHasBeenActiveSinceNavigationStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
bool mozilla::ipc::IPDLParamTraits<nsDOMNavigationTiming*>::Read(
|
||||||
|
const IPC::Message* aMsg, PickleIterator* aIter, IProtocol* aActor,
|
||||||
|
RefPtr<nsDOMNavigationTiming>* aResult) {
|
||||||
|
auto timing = MakeRefPtr<nsDOMNavigationTiming>(nullptr);
|
||||||
|
uint32_t type;
|
||||||
|
Maybe<RefPtr<nsIURI>> unloadedURI;
|
||||||
|
Maybe<RefPtr<nsIURI>> loadedURI;
|
||||||
|
if (!ReadIPDLParam(aMsg, aIter, aActor, &unloadedURI) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &loadedURI) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &type) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mNavigationStartHighRes) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mNavigationStart) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mNonBlankPaint) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mContentfulPaint) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMContentFlushed) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mBeforeUnloadStart) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mUnloadStart) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mUnloadEnd) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mLoadEventStart) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mLoadEventEnd) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMLoading) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMInteractive) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor,
|
||||||
|
&timing->mDOMContentLoadedEventStart) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMContentLoadedEventEnd) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mDOMComplete) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor, &timing->mTTFI) ||
|
||||||
|
!ReadIPDLParam(aMsg, aIter, aActor,
|
||||||
|
&timing->mDocShellHasBeenActiveSinceNavigationStart)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
timing->mNavigationType = nsDOMNavigationTiming::Type(type);
|
||||||
|
if (unloadedURI) {
|
||||||
|
timing->mUnloadedURI = unloadedURI->forget();
|
||||||
|
}
|
||||||
|
if (loadedURI) {
|
||||||
|
timing->mLoadedURI = loadedURI->forget();
|
||||||
|
}
|
||||||
|
*aResult = timing.forget();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,18 @@ class nsIURI;
|
|||||||
typedef unsigned long long DOMTimeMilliSec;
|
typedef unsigned long long DOMTimeMilliSec;
|
||||||
typedef double DOMHighResTimeStamp;
|
typedef double DOMHighResTimeStamp;
|
||||||
|
|
||||||
|
class PickleIterator;
|
||||||
|
namespace IPC {
|
||||||
|
class Message;
|
||||||
|
} // namespace IPC
|
||||||
|
namespace mozilla {
|
||||||
|
namespace ipc {
|
||||||
|
class IProtocol;
|
||||||
|
template <typename>
|
||||||
|
struct IPDLParamTraits;
|
||||||
|
} // namespace ipc
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
class nsDOMNavigationTiming final : public mozilla::RelativeTimeline {
|
class nsDOMNavigationTiming final : public mozilla::RelativeTimeline {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -173,6 +185,8 @@ class nsDOMNavigationTiming final : public mozilla::RelativeTimeline {
|
|||||||
|
|
||||||
bool IsTopLevelContentDocumentInContentProcess() const;
|
bool IsTopLevelContentDocumentInContentProcess() const;
|
||||||
|
|
||||||
|
// Should those be amended, the IPC serializer should be updated
|
||||||
|
// accordingly.
|
||||||
mozilla::WeakPtr<nsDocShell> mDocShell;
|
mozilla::WeakPtr<nsDocShell> mDocShell;
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> mUnloadedURI;
|
nsCOMPtr<nsIURI> mUnloadedURI;
|
||||||
@@ -200,7 +214,26 @@ class nsDOMNavigationTiming final : public mozilla::RelativeTimeline {
|
|||||||
|
|
||||||
mozilla::TimeStamp mTTFI;
|
mozilla::TimeStamp mTTFI;
|
||||||
|
|
||||||
bool mDocShellHasBeenActiveSinceNavigationStart : 1;
|
bool mDocShellHasBeenActiveSinceNavigationStart;
|
||||||
|
|
||||||
|
friend struct mozilla::ipc::IPDLParamTraits<nsDOMNavigationTiming*>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// IPDL serializer. Please be aware of the caveats in sending across
|
||||||
|
// the information and the potential resulting data leakage.
|
||||||
|
// For now, this serializer is to only be used under a very narrowed scope
|
||||||
|
// so that only the starting times are ever set.
|
||||||
|
namespace mozilla {
|
||||||
|
namespace ipc {
|
||||||
|
template <>
|
||||||
|
struct IPDLParamTraits<nsDOMNavigationTiming*> {
|
||||||
|
static void Write(IPC::Message* aMsg, IProtocol* aActor,
|
||||||
|
nsDOMNavigationTiming* aParam);
|
||||||
|
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
|
||||||
|
IProtocol* aActor, RefPtr<nsDOMNavigationTiming>* aResult);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ipc
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* nsDOMNavigationTiming_h___ */
|
#endif /* nsDOMNavigationTiming_h___ */
|
||||||
|
|||||||
Reference in New Issue
Block a user