Ejemplo n.º 1
0
void Performance::addResourceTiming(const ResourceTimingInfo& info, Document* initiatorDocument)
{
    if (isResourceTimingBufferFull())
        return;

    const ResourceResponse& finalResponse = info.finalResponse();
    bool allowTimingDetails = passesTimingAllowCheck(finalResponse, initiatorDocument);
    double startTime = info.initialTime();

    if (info.redirectChain().isEmpty()) {
        RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(info, initiatorDocument, startTime, allowTimingDetails);
        addResourceTimingBuffer(entry);
        return;
    }

    const Vector<ResourceResponse>& redirectChain = info.redirectChain();
    bool allowRedirectDetails = allowsTimingRedirect(redirectChain, finalResponse, initiatorDocument);

    if (!allowRedirectDetails) {
        ResourceLoadTiming* finalTiming = finalResponse.resourceLoadTiming();
        ASSERT(finalTiming);
        if (finalTiming)
            startTime = finalTiming->requestTime;
    }

    ResourceLoadTiming* lastRedirectTiming = redirectChain.last().resourceLoadTiming();
    ASSERT(lastRedirectTiming);
    double lastRedirectEndTime = lastRedirectTiming->receiveHeadersEnd;

    RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(info, initiatorDocument, startTime, lastRedirectEndTime, allowTimingDetails, allowRedirectDetails);
    addResourceTimingBuffer(entry);
}
PerformanceResourceTiming::PerformanceResourceTiming(const ResourceTimingInfo& info, double timeOrigin, double startTime, double lastRedirectEndTime, bool allowTimingDetails, bool allowRedirectDetails)
    : PerformanceEntry(info.initialRequest().url().getString(), "resource", monotonicTimeToDOMHighResTimeStamp(timeOrigin, startTime), monotonicTimeToDOMHighResTimeStamp(timeOrigin, info.loadFinishTime()))
    , m_initiatorType(info.initiatorType())
    , m_timeOrigin(timeOrigin)
    , m_timing(info.finalResponse().resourceLoadTiming())
    , m_lastRedirectEndTime(lastRedirectEndTime)
    , m_finishTime(info.loadFinishTime())
    , m_didReuseConnection(info.finalResponse().connectionReused())
    , m_allowTimingDetails(allowTimingDetails)
    , m_allowRedirectDetails(allowRedirectDetails)
{
}
PerformanceResourceTiming::PerformanceResourceTiming(const ResourceTimingInfo& info, Document* requestingDocument, double startTime, double lastRedirectEndTime, bool allowTimingDetails, bool allowRedirectDetails)
    : PerformanceEntry(info.initialRequest().url().string(), "resource", monotonicTimeToDocumentMilliseconds(requestingDocument, startTime), monotonicTimeToDocumentMilliseconds(requestingDocument, info.loadFinishTime()))
    , m_initiatorType(info.initiatorType())
    , m_timing(info.finalResponse().resourceLoadTiming())
    , m_lastRedirectEndTime(lastRedirectEndTime)
    , m_finishTime(info.loadFinishTime())
    , m_didReuseConnection(info.finalResponse().connectionReused())
    , m_allowTimingDetails(allowTimingDetails)
    , m_allowRedirectDetails(allowRedirectDetails)
    , m_requestingDocument(requestingDocument)
{
}
Ejemplo n.º 4
0
void PerformanceBase::addResourceTiming(const ResourceTimingInfo& info) {
  if (isResourceTimingBufferFull() &&
      !hasObserverFor(PerformanceEntry::Resource))
    return;
  SecurityOrigin* securityOrigin = nullptr;
  ExecutionContext* context = getExecutionContext();
  if (context)
    securityOrigin = context->getSecurityOrigin();
  if (!securityOrigin)
    return;

  const ResourceResponse& finalResponse = info.finalResponse();
  bool allowTimingDetails =
      passesTimingAllowCheck(finalResponse, *securityOrigin,
                             info.originalTimingAllowOrigin(), context);
  double startTime = info.initialTime();

  if (info.redirectChain().isEmpty()) {
    PerformanceEntry* entry = PerformanceResourceTiming::create(
        info, timeOrigin(), startTime, allowTimingDetails);
    notifyObserversOfEntry(*entry);
    if (!isResourceTimingBufferFull())
      addResourceTimingBuffer(*entry);
    return;
  }

  const Vector<ResourceResponse>& redirectChain = info.redirectChain();
  bool allowRedirectDetails = allowsTimingRedirect(redirectChain, finalResponse,
                                                   *securityOrigin, context);

  if (!allowRedirectDetails) {
    ResourceLoadTiming* finalTiming = finalResponse.resourceLoadTiming();
    ASSERT(finalTiming);
    if (finalTiming)
      startTime = finalTiming->requestTime();
  }

  ResourceLoadTiming* lastRedirectTiming =
      redirectChain.back().resourceLoadTiming();
  ASSERT(lastRedirectTiming);
  double lastRedirectEndTime = lastRedirectTiming->receiveHeadersEnd();

  PerformanceEntry* entry = PerformanceResourceTiming::create(
      info, timeOrigin(), startTime, lastRedirectEndTime, allowTimingDetails,
      allowRedirectDetails);
  notifyObserversOfEntry(*entry);
  if (!isResourceTimingBufferFull())
    addResourceTimingBuffer(*entry);
}
void FrameFetchContext::addResourceTiming(const ResourceTimingInfo& info)
{
    Document* initiatorDocument = m_document && info.isMainResource() ? m_document->parentDocument() : m_document.get();
    if (!initiatorDocument || !initiatorDocument->domWindow())
        return;
    DOMWindowPerformance::performance(*initiatorDocument->domWindow())->addResourceTiming(info);
}
Ejemplo n.º 6
0
 void addResourceTiming(
     const ResourceTimingInfo& resourceTimingInfo) override {
     m_transferSize = resourceTimingInfo.transferSize();
 }