Bug 1317297 - nextHopProtocol is an empty string for local fetch r=baku
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 01 Dec 2016 16:13:19 +0100
changeset 372269 9e5cd2bf4d66a602b934235f9071ff2247a66d94
parent 372268 8c4dcbaa44b92fe8248c8aac2c6191c15fc91b1d
child 372270 dd01d903f823c089789b30c7f95d4da80e5e6162
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1317297
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1317297 - nextHopProtocol is an empty string for local fetch r=baku MozReview-Commit-ID: 7oC29OthYja
dom/performance/PerformanceMainThread.cpp
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "PerformanceMainThread.h"
 #include "PerformanceNavigation.h"
+#include "nsICacheInfoChannel.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
                                                 Performance)
@@ -160,16 +161,27 @@ PerformanceMainThread::AddEntry(nsIHttpC
 
     // The PerformanceResourceTiming object will use the PerformanceTiming
     // object to get all the required timings.
     RefPtr<PerformanceResourceTiming> performanceEntry =
       new PerformanceResourceTiming(performanceTiming, this, entryName);
 
     nsAutoCString protocol;
     channel->GetProtocolVersion(protocol);
+
+    // If this is a local fetch, nextHopProtocol should be set to empty string.
+    nsCOMPtr<nsICacheInfoChannel> cachedChannel = do_QueryInterface(channel);
+    if (cachedChannel) {
+      bool isFromCache;
+      if (NS_SUCCEEDED(cachedChannel->IsFromCache(&isFromCache))
+          && isFromCache) {
+        protocol.Truncate();
+      }
+    }
+
     performanceEntry->SetNextHopProtocol(NS_ConvertUTF8toUTF16(protocol));
 
     uint64_t encodedBodySize = 0;
     channel->GetEncodedBodySize(&encodedBodySize);
     performanceEntry->SetEncodedBodySize(encodedBodySize);
 
     uint64_t transferSize = 0;
     channel->GetTransferSize(&transferSize);