Bug 1360603 - Mark the save channel as throttleable. r=baku
authorAmy Chung <amchung@mozilla.com>
Sun, 24 Sep 2017 00:38:32 +0800
changeset 382632 d409c2ac7d88b7193e8369aa3359a9368e1135b3
parent 382631 03dda89f9c5b5a74c4ea78978ca59631a10f438d
child 382633 6d7610f4d26d76878b83b1f2489a96116c2bdf15
push id95371
push userryanvm@gmail.com
push dateSun, 24 Sep 2017 20:55:14 +0000
treeherdermozilla-inbound@6d7610f4d26d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1360603
milestone58.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 1360603 - Mark the save channel as throttleable. r=baku
dom/webbrowserpersist/nsWebBrowserPersist.cpp
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -8,16 +8,17 @@
 #include "nspr.h"
 
 #include "nsIFileStreams.h"       // New Necko file streams
 #include <algorithm>
 
 #include "nsAutoPtr.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
+#include "nsIClassOfService.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsILoadContext.h"
 #include "nsIPrivateBrowsingChannel.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIComponentRegistrar.h"
 #include "nsIStorageStream.h"
 #include "nsISeekableStream.h"
 #include "nsIHttpChannel.h"
@@ -1492,16 +1493,22 @@ nsresult nsWebBrowserPersist::SaveChanne
         rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedInputStream),
                                        fileInputStream, BUFFERED_OUTPUT_SIZE);
         NS_ENSURE_SUCCESS(rv, rv);
         nsAutoCString contentType;
         aChannel->GetContentType(contentType);
         return StartUpload(bufferedInputStream, aFile, contentType);
     }
 
+    // Mark save channel as throttleable.
+    nsCOMPtr<nsIClassOfService> cos(do_QueryInterface(aChannel));
+    if (cos) {
+      cos->AddClassFlags(nsIClassOfService::Throttleable);
+    }
+
     // Read from the input channel
     nsresult rv = NS_MaybeOpenChannelUsingAsyncOpen2(aChannel, this);
     if (rv == NS_ERROR_NO_CONTENT)
     {
         // Assume this is a protocol such as mailto: which does not feed out
         // data and just ignore it.
         return NS_SUCCESS_DONT_FIXUP;
     }