Bug 1444490 Declare classses (and one method) in network/ final to reduce virtual function calls r?nwgh draft
authorTom Ritter <tom@mozilla.com>
Fri, 09 Mar 2018 08:37:18 -0600
changeset 765409 877d67a72eb8b7dbfbe2132cf2a0e49e7d68f3d4
parent 765246 f1965cf7425fe422c9e9c78018f11b97e0a0f229
push id102063
push userbmo:tom@mozilla.com
push dateFri, 09 Mar 2018 19:28:11 +0000
reviewersnwgh
bugs1444490
milestone60.0a1
Bug 1444490 Declare classses (and one method) in network/ final to reduce virtual function calls r?nwgh MozReview-Commit-ID: 4oaazbPhpbc
netwerk/base/Dashboard.cpp
netwerk/base/LoadContextInfo.h
netwerk/base/NetworkActivityMonitor.h
netwerk/base/Predictor.h
netwerk/base/nsBufferedStreams.h
netwerk/base/nsSimpleURI.h
netwerk/cache2/CacheFileChunk.h
netwerk/cache2/CacheFileIOManager.h
netwerk/cache2/CacheFileMetadata.h
netwerk/cache2/CacheIOThread.h
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
netwerk/cookie/nsCookie.h
netwerk/protocol/http/AlternateServices.h
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpConnectionMgr.h
netwerk/protocol/res/ExtensionProtocolHandler.cpp
netwerk/test/TestCommon.h
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -280,17 +280,17 @@ public:
 
     nsCOMPtr<nsIDNSRecord> mRecord;
     RefPtr<LookupHelper> mHelper;
 };
 
 NS_IMPL_ISUPPORTS0(LookupArgument)
 
 
-class LookupHelper
+class LookupHelper final
     : public nsIDNSListener
 {
     virtual ~LookupHelper()
     {
         if (mCancel) {
             mCancel->Cancel(NS_ERROR_ABORT);
         }
     }
--- a/netwerk/base/LoadContextInfo.h
+++ b/netwerk/base/LoadContextInfo.h
@@ -8,17 +8,17 @@
 #include "nsILoadContextInfo.h"
 
 class nsIChannel;
 class nsILoadContext;
 
 namespace mozilla {
 namespace net {
 
-class LoadContextInfo : public nsILoadContextInfo
+class LoadContextInfo final : public nsILoadContextInfo
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSILOADCONTEXTINFO
 
   LoadContextInfo(bool aIsAnonymous, OriginAttributes aOriginAttributes);
 
 private:
--- a/netwerk/base/NetworkActivityMonitor.h
+++ b/netwerk/base/NetworkActivityMonitor.h
@@ -50,18 +50,19 @@ private:
   nsString mHost;
   int32_t mPort;
   int32_t mFd;
   int32_t mRx;
   int32_t mTx;
 };
 
 
-class NetworkActivityMonitor: public nsITimerCallback
-                            , public nsINamed
+class NetworkActivityMonitor final
+    : public nsITimerCallback
+    , public nsINamed
 {
 public:
   enum Direction {
     kUpload   = 0,
     kDownload = 1
   };
 
   NetworkActivityMonitor();
--- a/netwerk/base/Predictor.h
+++ b/netwerk/base/Predictor.h
@@ -32,22 +32,23 @@ class nsILoadContextInfo;
 class nsITimer;
 
 namespace mozilla {
 namespace net {
 
 class nsHttpRequestHead;
 class nsHttpResponseHead;
 
-class Predictor : public nsINetworkPredictor
-                , public nsIObserver
-                , public nsISpeculativeConnectionOverrider
-                , public nsIInterfaceRequestor
-                , public nsICacheEntryMetaDataVisitor
-                , public nsINetworkPredictorVerifier
+class Predictor final
+  : public nsINetworkPredictor
+  , public nsIObserver
+  , public nsISpeculativeConnectionOverrider
+  , public nsIInterfaceRequestor
+  , public nsICacheEntryMetaDataVisitor
+  , public nsINetworkPredictorVerifier
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSINETWORKPREDICTOR
   NS_DECL_NSIOBSERVER
   NS_DECL_NSISPECULATIVECONNECTIONOVERRIDER
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSICACHEENTRYMETADATAVISITOR
--- a/netwerk/base/nsBufferedStreams.h
+++ b/netwerk/base/nsBufferedStreams.h
@@ -56,23 +56,24 @@ protected:
 
     bool                        mBufferDisabled;
     bool                        mEOF;  // True if mStream is at EOF
     uint8_t                     mGetBufferCount;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 
-class nsBufferedInputStream : public nsBufferedStream,
-                              public nsIBufferedInputStream,
-                              public nsIStreamBufferAccess,
-                              public nsIIPCSerializableInputStream,
-                              public nsIAsyncInputStream,
-                              public nsIInputStreamCallback,
-                              public nsICloneableInputStream
+class nsBufferedInputStream final
+    : public nsBufferedStream,
+      public nsIBufferedInputStream,
+      public nsIStreamBufferAccess,
+      public nsIIPCSerializableInputStream,
+      public nsIAsyncInputStream,
+      public nsIInputStreamCallback,
+      public nsICloneableInputStream
 {
 public:
     NS_DECL_ISUPPORTS_INHERITED
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIBUFFEREDINPUTSTREAM
     NS_DECL_NSISTREAMBUFFERACCESS
     NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
     NS_DECL_NSIASYNCINPUTSTREAM
--- a/netwerk/base/nsSimpleURI.h
+++ b/netwerk/base/nsSimpleURI.h
@@ -73,17 +73,17 @@ protected:
         eIgnoreRef,
         eHonorRef,
         eReplaceRef
     };
 
     virtual nsresult SetSpecInternal(const nsACString &input);
     virtual nsresult SetScheme(const nsACString &input);
     virtual nsresult SetUserPass(const nsACString &input);
-    virtual nsresult SetUsername(const nsACString &input);
+    nsresult SetUsername(const nsACString &input);
     virtual nsresult SetPassword(const nsACString &input);
     virtual nsresult SetHostPort(const nsACString &aValue);
     virtual nsresult SetHost(const nsACString &input);
     virtual nsresult SetPort(int32_t port);
     virtual nsresult SetPathQueryRef(const nsACString &input);
     virtual nsresult SetRef(const nsACString &input);
     virtual nsresult SetFilePath(const nsACString &input);
     virtual nsresult SetQuery(const nsACString &input);
--- a/netwerk/cache2/CacheFileChunk.h
+++ b/netwerk/cache2/CacheFileChunk.h
@@ -129,18 +129,19 @@ public:
 class ChunkListeners {
 public:
   ChunkListeners()  { MOZ_COUNT_CTOR(ChunkListeners); }
   ~ChunkListeners() { MOZ_COUNT_DTOR(ChunkListeners); }
 
   nsTArray<ChunkListenerItem *> mItems;
 };
 
-class CacheFileChunk : public CacheFileIOListener
-                     , public CacheMemoryConsumer
+class CacheFileChunk final
+  : public CacheFileIOListener
+  , public CacheMemoryConsumer
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   bool DispatchRelease();
 
   CacheFileChunk(CacheFile *aFile, uint32_t aIndex, bool aInitByWriter);
 
   void     InitNew();
--- a/netwerk/cache2/CacheFileIOManager.h
+++ b/netwerk/cache2/CacheFileIOManager.h
@@ -38,17 +38,17 @@ class CacheFileIOListener;
 class CacheFileHandlesEntry;
 #endif
 
 #define ENTRIES_DIR "entries"
 #define DOOMED_DIR  "doomed"
 #define TRASH_DIR   "trash"
 
 
-class CacheFileHandle : public nsISupports
+class CacheFileHandle final : public nsISupports
 {
 public:
   enum class PinningStatus : uint32_t {
     UNKNOWN,
     NON_PINNED,
     PINNED
   };
 
@@ -254,18 +254,19 @@ public:
   NS_IMETHOD OnFileRenamed(CacheFileHandle *aHandle, nsresult aResult) = 0;
 
   virtual bool IsKilled() { return false; }
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(CacheFileIOListener, CACHEFILEIOLISTENER_IID)
 
 
-class CacheFileIOManager : public nsITimerCallback
-                         , public nsINamed
+class CacheFileIOManager final
+  : public nsITimerCallback
+  , public nsINamed
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSINAMED
 
   enum {
     OPEN         =  0U,
--- a/netwerk/cache2/CacheFileMetadata.h
+++ b/netwerk/cache2/CacheFileMetadata.h
@@ -118,18 +118,19 @@ public:
   NS_IMETHOD OnMetadataWritten(nsresult aResult) = 0;
   virtual bool IsKilled() = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(CacheFileMetadataListener,
                               CACHEFILEMETADATALISTENER_IID)
 
 
-class CacheFileMetadata : public CacheFileIOListener
-                        , public CacheMemoryConsumer
+class CacheFileMetadata final
+  : public CacheFileIOListener
+  , public CacheMemoryConsumer
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   CacheFileMetadata(CacheFileHandle *aHandle,
                     const nsACString &aKey);
   CacheFileMetadata(bool aMemoryOnly,
                     bool aPinned,
--- a/netwerk/cache2/CacheIOThread.h
+++ b/netwerk/cache2/CacheIOThread.h
@@ -23,17 +23,17 @@ namespace net {
 namespace detail {
 // A class keeping platform specific information needed to watch and
 // cancel any long blocking synchronous IO.  Must be predeclared here
 // since including windows.h breaks stuff with number of macro definition
 // conflicts.
 class BlockingIOWatcher;
 }
 
-class CacheIOThread : public nsIThreadObserver
+class CacheIOThread final : public nsIThreadObserver
 {
   virtual ~CacheIOThread();
 
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITHREADOBSERVER
 
   CacheIOThread();
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -173,17 +173,17 @@ private:
   const SHA1Sum::Hash *mHash;
   RefPtr<CacheIndex> mIndex;
   CacheIndexRecord    *mOldRecord;
   uint32_t             mOldFrecency;
   bool                 mDoNotSearchInIndex;
   bool                 mDoNotSearchInUpdates;
 };
 
-class FileOpenHelper : public CacheFileIOListener
+class FileOpenHelper final : public CacheFileIOListener
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   explicit FileOpenHelper(CacheIndex* aIndex)
     : mIndex(aIndex)
     , mCanceled(false)
   {}
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -661,18 +661,19 @@ private:
   // information is not correct.
   bool     mStateLogged;
 
   // Disables logging in this instance of CacheIndexStats
   bool     mDisableLogging;
 #endif
 };
 
-class CacheIndex : public CacheFileIOListener
-                 , public nsIRunnable
+class CacheIndex final
+  : public CacheFileIOListener
+  , public nsIRunnable
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
 
   CacheIndex();
 
   static nsresult Init(nsIFile *aCacheDirectory);
--- a/netwerk/cookie/nsCookie.h
+++ b/netwerk/cookie/nsCookie.h
@@ -22,17 +22,17 @@ using mozilla::OriginAttributes;
  * for xpcom access of cookie objects.
  */
 
 /******************************************************************************
  * nsCookie:
  * implementation
  ******************************************************************************/
 
-class nsCookie : public nsICookie2
+class nsCookie final : public nsICookie2
 {
   public:
     // nsISupports
     NS_DECL_ISUPPORTS
     NS_DECL_NSICOOKIE
     NS_DECL_NSICOOKIE2
 
   private:
--- a/netwerk/protocol/http/AlternateServices.h
+++ b/netwerk/protocol/http/AlternateServices.h
@@ -137,17 +137,17 @@ public:
   explicit AltSvcOverride(nsIInterfaceRequestor *aRequestor)
     : mCallbacks(aRequestor) {}
 
 private:
   virtual ~AltSvcOverride() {}
   nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
 };
 
-class TransactionObserver : public nsIStreamListener
+class TransactionObserver final : public nsIStreamListener
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSISTREAMLISTENER
   NS_DECL_NSIREQUESTOBSERVER
 
   TransactionObserver(nsHttpChannel *channel, WellKnownChecker *checker);
   void Complete(nsHttpTransaction *, nsresult);
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -27,17 +27,17 @@
 // however, proxy conenctions made with http/2 (or spdy) can tunnel to the origin
 // and multiplex non tunneled transactions at the same time, so they have a
 // special wildcard CI that accepts all origins through that proxy.
 
 namespace mozilla { namespace net {
 
 extern LazyLogModule gHttpLog;
 
-class nsHttpConnectionInfo: public ARefBase
+class nsHttpConnectionInfo final : public ARefBase
 {
 public:
     nsHttpConnectionInfo(const nsACString &originHost,
                          int32_t originPort,
                          const nsACString &npnToken,
                          const nsACString &username,
                          nsProxyInfo *proxyInfo,
                          const OriginAttributes &originAttributes,
--- a/netwerk/protocol/http/nsHttpConnectionMgr.h
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.h
@@ -501,17 +501,17 @@ private:
         RefPtr<nsConnectionEntry>      mEnt;
         nsCOMPtr<nsITimer>             mSynTimer;
         nsCOMPtr<nsISocketTransport>   mBackupTransport;
         nsCOMPtr<nsIAsyncOutputStream> mBackupStreamOut;
         nsCOMPtr<nsIAsyncInputStream>  mBackupStreamIn;
     };
     friend class nsHalfOpenSocket;
 
-    class PendingTransactionInfo : public ARefBase
+    class PendingTransactionInfo final : public ARefBase
     {
     public:
         explicit PendingTransactionInfo(nsHttpTransaction * trans)
             : mTransaction(trans)
         {}
 
         NS_INLINE_DECL_THREADSAFE_REFCOUNTING(PendingTransactionInfo, override)
 
--- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp
+++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp
@@ -132,17 +132,17 @@ class ExtensionStreamGetter : public Ref
     nsCOMPtr<nsIJARChannel> mJarChannel;
     nsCOMPtr<nsIFile> mJarFile;
     nsCOMPtr<nsIStreamListener> mListener;
     nsCOMPtr<nsIChannel> mChannel;
     nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
     bool mIsJarChannel;
 };
 
-class ExtensionJARFileOpener : public nsISupports
+class ExtensionJARFileOpener final : public nsISupports
 {
 public:
   ExtensionJARFileOpener(nsIFile* aFile,
                          NeckoParent::GetExtensionFDResolver& aResolve) :
     mFile(aFile),
     mResolve(aResolve)
   {
     MOZ_ASSERT(aFile);
--- a/netwerk/test/TestCommon.h
+++ b/netwerk/test/TestCommon.h
@@ -6,17 +6,17 @@
 #define TestCommon_h__
 
 #include <stdlib.h>
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
 //-----------------------------------------------------------------------------
 
-class WaitForCondition : public nsIRunnable
+class WaitForCondition final : public nsIRunnable
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
   void Wait(int pending)
   {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(mPending == 0);