Bug 1551101. Stop using [array] in nsIContentProcess. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 13 May 2019 15:58:01 +0000
changeset 532438 c957bff02df08481f0d632033db6578a88a6f6c1
parent 532437 d48bf099053b59dc5598e6c96a614eeed3e94282
child 532439 f12becef5ac1fc08696edbabe351707f5e093e3b
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1551101
milestone68.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 1551101. Stop using [array] in nsIContentProcess. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D30833
dom/base/ProcessSelector.jsm
dom/interfaces/base/nsIContentProcess.idl
dom/ipc/ContentParent.cpp
--- a/dom/base/ProcessSelector.jsm
+++ b/dom/base/ProcessSelector.jsm
@@ -6,18 +6,18 @@
 // ones.
 function RandomSelector() {
 }
 
 RandomSelector.prototype = {
   classID:          Components.ID("{c616fcfd-9737-41f1-aa74-cee72a38f91b}"),
   QueryInterface:   ChromeUtils.generateQI([Ci.nsIContentProcessProvider]),
 
-  provideProcess(aType, aOpener, aProcesses, aCount, aMaxCount) {
-    if (aCount < aMaxCount) {
+  provideProcess(aType, aOpener, aProcesses, aMaxCount) {
+    if (aProcesses.length < aMaxCount) {
       return Ci.nsIContentProcessProvider.NEW_PROCESS;
     }
 
     let startIdx = Math.floor(Math.random() * aMaxCount);
     let curIdx = startIdx;
 
     do {
       if (aProcesses[curIdx].opener === aOpener) {
@@ -35,26 +35,26 @@ RandomSelector.prototype = {
 // ones that host the least number of tabs.
 function MinTabSelector() {
 }
 
 MinTabSelector.prototype = {
   classID:          Components.ID("{2dc08eaf-6eef-4394-b1df-a3a927c1290b}"),
   QueryInterface:   ChromeUtils.generateQI([Ci.nsIContentProcessProvider]),
 
-  provideProcess(aType, aOpener, aProcesses, aCount, aMaxCount) {
-    if (aCount < aMaxCount) {
+  provideProcess(aType, aOpener, aProcesses, aMaxCount) {
+    if (aProcesses.length < aMaxCount) {
       return Ci.nsIContentProcessProvider.NEW_PROCESS;
     }
 
     let min = Number.MAX_VALUE;
     let candidate = Ci.nsIContentProcessProvider.NEW_PROCESS;
 
     // Note, that at this point aMaxCount is in the valid range and
-    // the reason for not using aCount here is because if we keep
+    // the reason for not using aProcesses.length here is because if we keep
     // processes alive for testing but want a test to use only single
     // content process we can just keep relying on dom.ipc.processCount = 1
     // this way.
     for (let i = 0; i < aMaxCount; i++) {
       let process = aProcesses[i];
       let tabCount = process.tabCount;
       if (process.opener === aOpener && tabCount < min) {
         min = tabCount;
--- a/dom/interfaces/base/nsIContentProcess.idl
+++ b/dom/interfaces/base/nsIContentProcess.idl
@@ -46,11 +46,11 @@ interface nsIContentProcessProvider : ns
   const int32_t NEW_PROCESS = -1;
 
   /**
    * Given aAliveProcesses (with an opener aOpener), choose which process of
    * aType to use. Return nsIContentProcessProvider.NEW_PROCESS to ask the
    * caller to create a new content process.
    */
   int32_t provideProcess(in AString aType, in nsIContentProcessInfo aOpener,
-                         [array, size_is(aCount)] in nsIContentProcessInfo aAliveProcesses,
-                         in uint32_t aCount, in uint32_t aMaxCount);
+                         in Array<nsIContentProcessInfo> aAliveProcesses,
+                         in uint32_t aMaxCount);
 };
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -837,35 +837,34 @@ already_AddRefed<ContentParent> ContentP
     // We never want to re-use Large-Allocation processes.
     if (contentParents.Length() >= maxContentParents) {
       return GetNewOrUsedBrowserProcess(aFrameElement,
                                         NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE),
                                         aPriority, aOpener);
     }
   } else {
     uint32_t numberOfParents = contentParents.Length();
-    nsTArray<nsIContentProcessInfo*> infos(numberOfParents);
+    nsTArray<RefPtr<nsIContentProcessInfo>> infos(numberOfParents);
     for (auto* cp : contentParents) {
       infos.AppendElement(cp->mScriptableHelper);
     }
 
     if (aPreferUsed && numberOfParents) {
       // For the preloaded browser we don't want to create a new process but
       // reuse an existing one.
       maxContentParents = numberOfParents;
     }
 
     nsCOMPtr<nsIContentProcessProvider> cpp =
         do_GetService("@mozilla.org/ipc/processselector;1");
     nsIContentProcessInfo* openerInfo =
         aOpener ? aOpener->mScriptableHelper.get() : nullptr;
     int32_t index;
-    if (cpp && NS_SUCCEEDED(cpp->ProvideProcess(
-                   aRemoteType, openerInfo, infos.Elements(), infos.Length(),
-                   maxContentParents, &index))) {
+    if (cpp && NS_SUCCEEDED(cpp->ProvideProcess(aRemoteType, openerInfo, infos,
+                                                maxContentParents, &index))) {
       // If the provider returned an existing ContentParent, use that one.
       if (0 <= index && static_cast<uint32_t>(index) <= maxContentParents) {
         RefPtr<ContentParent> retval = contentParents[index];
         return retval.forget();
       }
     } else {
       // If there was a problem with the JS chooser, fall back to a random
       // selection.