Bug 1413138 - Remove nsIWebBrowserStream and nsEmbedStream. r=mossop
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Tue, 31 Oct 2017 00:27:27 +0000
changeset 389304 8d3c08d7f8043f08029df7414213841256d52353
parent 389303 129dfaaf265a5eb9b18681fded2c3910167ddcff
child 389305 fa39e19a08f36338cb4b19c341347d2cee107d28
push id96837
push usermcastelluccio@mozilla.com
push dateTue, 31 Oct 2017 17:25:30 +0000
treeherdermozilla-inbound@8d3c08d7f804 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1413138
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 1413138 - Remove nsIWebBrowserStream and nsEmbedStream. r=mossop
toolkit/components/browser/moz.build
toolkit/components/browser/nsEmbedStream.cpp
toolkit/components/browser/nsEmbedStream.h
toolkit/components/browser/nsIWebBrowserStream.idl
toolkit/components/browser/nsWebBrowser.cpp
toolkit/components/browser/nsWebBrowser.h
--- a/toolkit/components/browser/moz.build
+++ b/toolkit/components/browser/moz.build
@@ -15,30 +15,28 @@ XPIDL_SOURCES += [
     'nsIEmbeddingSiteWindow.idl',
     'nsIWebBrowser.idl',
     'nsIWebBrowserChrome.idl',
     'nsIWebBrowserChrome2.idl',
     'nsIWebBrowserChrome3.idl',
     'nsIWebBrowserChromeFocus.idl',
     'nsIWebBrowserFocus.idl',
     'nsIWebBrowserSetup.idl',
-    'nsIWebBrowserStream.idl',
 ]
 
 if CONFIG['NS_PRINTING']:
     XPIDL_SOURCES += [
         'nsIPrintingPromptService.idl',
         'nsIWebBrowserPrint.idl',
     ]
 
 XPIDL_MODULE = 'webBrowser_core'
 
 UNIFIED_SOURCES += [
     'nsCommandHandler.cpp',
-    'nsEmbedStream.cpp',
     'nsWebBrowser.cpp',
     'nsWebBrowserContentPolicy.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/docshell/base',
     '/dom/base',
deleted file mode 100644
--- a/toolkit/components/browser/nsEmbedStream.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- 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 "nsIAsyncInputStream.h"
-#include "nsIAsyncOutputStream.h"
-#include "nsIDocShell.h"
-#include "nsIInterfaceRequestorUtils.h"
-#include "nsIPipe.h"
-
-#include "nsEmbedStream.h"
-#include "nsError.h"
-#include "nsString.h"
-
-NS_IMPL_ISUPPORTS0(nsEmbedStream)
-
-nsEmbedStream::nsEmbedStream()
-{
-  mOwner = nullptr;
-}
-
-nsEmbedStream::~nsEmbedStream()
-{
-}
-
-void
-nsEmbedStream::InitOwner(nsIWebBrowser* aOwner)
-{
-  mOwner = aOwner;
-}
-
-nsresult
-nsEmbedStream::Init(void)
-{
-  return NS_OK;
-}
-
-nsresult
-nsEmbedStream::OpenStream(nsIURI* aBaseURI, const nsACString& aContentType)
-{
-  nsresult rv;
-  NS_ENSURE_ARG_POINTER(aBaseURI);
-  NS_ENSURE_TRUE(IsASCII(aContentType), NS_ERROR_INVALID_ARG);
-
-  // if we're already doing a stream, return an error
-  if (mOutputStream) {
-    return NS_ERROR_IN_PROGRESS;
-  }
-
-  nsCOMPtr<nsIAsyncInputStream> inputStream;
-  nsCOMPtr<nsIAsyncOutputStream> outputStream;
-  rv = NS_NewPipe2(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
-                   true, false, 0, UINT32_MAX);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mOwner);
-  rv = docShell->LoadStream(inputStream, aBaseURI, aContentType,
-                            EmptyCString(), nullptr);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  mOutputStream = outputStream;
-  return rv;
-}
-
-nsresult
-nsEmbedStream::AppendToStream(const uint8_t* aData, uint32_t aLen)
-{
-  nsresult rv;
-  NS_ENSURE_STATE(mOutputStream);
-
-  uint32_t bytesWritten = 0;
-  rv = mOutputStream->Write(reinterpret_cast<const char*>(aData),
-                            aLen, &bytesWritten);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  NS_ASSERTION(bytesWritten == aLen,
-               "underlying buffer couldn't handle the write");
-  return rv;
-}
-
-nsresult
-nsEmbedStream::CloseStream(void)
-{
-  nsresult rv = NS_OK;
-
-  // NS_ENSURE_STATE returns NS_ERROR_UNEXPECTED if the condition isn't
-  // satisfied; this is exactly what we want to return.
-  NS_ENSURE_STATE(mOutputStream);
-  mOutputStream->Close();
-  mOutputStream = nullptr;
-
-  return rv;
-}
deleted file mode 100644
--- a/toolkit/components/browser/nsEmbedStream.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- 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/. */
-
-#ifndef nsEmbedStream_h__
-#define nsEmbedStream_h__
-
-#include "nsCOMPtr.h"
-#include "nsIOutputStream.h"
-#include "nsIURI.h"
-#include "nsIWebBrowser.h"
-
-class nsEmbedStream : public nsISupports
-{
-public:
-  nsEmbedStream();
-
-  void InitOwner(nsIWebBrowser* aOwner);
-  nsresult Init(void);
-
-  nsresult OpenStream(nsIURI* aBaseURI, const nsACString& aContentType);
-  nsresult AppendToStream(const uint8_t* aData, uint32_t aLen);
-  nsresult CloseStream(void);
-
-  NS_DECL_ISUPPORTS
-
-protected:
-  virtual ~nsEmbedStream();
-
-private:
-  nsIWebBrowser* mOwner;
-  nsCOMPtr<nsIOutputStream> mOutputStream;
-};
-
-#endif // nsEmbedStream_h__
deleted file mode 100644
--- a/toolkit/components/browser/nsIWebBrowserStream.idl
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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 "nsISupports.idl"
-
-interface nsIURI;
-
-/**
- * This interface provides a way to stream data to the web browser. This allows
- * loading of data from sources which can not be accessed using URIs and
- * nsIWebNavigation.
- */
-[scriptable, uuid(86d02f0e-219b-4cfc-9c88-bd98d2cce0b8)]
-interface nsIWebBrowserStream : nsISupports
-{
-  /**
-   * Prepare to load a stream of data. When this function returns successfully,
-   * it must be paired by a call to closeStream.
-   *
-   * @param aBaseURI
-   *        The base URI of the data. Must not be null. Relative
-   *        URIs will be resolved relative to this URI.
-   * @param aContentType
-   *        ASCII string giving the content type of the data. If rendering
-   *        content of this type is not supported, this method fails.
-   *        This string may include a charset declaration, for example:
-   *        text/html;charset=ISO-8859-1
-   *
-   * @throw NS_ERROR_NOT_AVAILABLE
-   *        The requested content type is not supported.
-   * @throw NS_ERROR_IN_PROGRESS
-   *        openStream was called twice without an intermediate closeStream.
-   */
-  void openStream(in nsIURI aBaseURI, in ACString aContentType);
-
-  /**
-   * Append data to this stream.
-   * @param aData The data to append
-   * @param aLen  Length of the data to append.
-   *
-   * @note To append more than 4 GB of data, call this method multiple times.
-   */
-  void appendToStream([const, array, size_is(aLen)] in octet aData,
-                      in unsigned long aLen);
-
-  /**
-   * Notifies the browser that all the data has been appended. This may notify
-   * the user that the browser is "done loading" in some form.
-   *
-   * @throw NS_ERROR_UNEXPECTED
-   *        This method was called without a preceding openStream.
-   */
-  void closeStream();
-};
--- a/toolkit/components/browser/nsWebBrowser.cpp
+++ b/toolkit/components/browser/nsWebBrowser.cpp
@@ -23,17 +23,16 @@
 #include "nsIDOMElement.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
 #include "nsIWebBrowserFocus.h"
-#include "nsIWebBrowserStream.h"
 #include "nsIPresShell.h"
 #include "nsIURIContentListener.h"
 #include "nsISHistoryListener.h"
 #include "nsIURI.h"
 #include "nsIWebBrowserPersist.h"
 #include "nsCWebBrowserPersist.h"
 #include "nsIServiceManager.h"
 #include "nsFocusManager.h"
@@ -118,17 +117,16 @@ NS_INTERFACE_MAP_BEGIN(nsWebBrowser)
   NS_INTERFACE_MAP_ENTRY(nsITextScroll)
   NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserSetup)
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserPersist)
   NS_INTERFACE_MAP_ENTRY(nsICancelable)
   NS_INTERFACE_MAP_ENTRY(nsIWebBrowserFocus)
   NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
-  NS_INTERFACE_MAP_ENTRY(nsIWebBrowserStream)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
 ///*****************************************************************************
 // nsWebBrowser::nsIInterfaceRequestor
 //*****************************************************************************
 
 NS_IMETHODIMP
@@ -1891,55 +1889,8 @@ nsWebBrowser::GetFocusedElement(nsIDOMEl
 }
 
 NS_IMETHODIMP
 nsWebBrowser::SetFocusedElement(nsIDOMElement* aFocusedElement)
 {
   nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
   return fm ? fm->SetFocus(aFocusedElement, 0) : NS_OK;
 }
-
-//*****************************************************************************
-// nsWebBrowser::nsIWebBrowserStream
-//*****************************************************************************
-
-NS_IMETHODIMP
-nsWebBrowser::OpenStream(nsIURI* aBaseURI, const nsACString& aContentType)
-{
-  nsresult rv;
-
-  if (!mStream) {
-    mStream = new nsEmbedStream();
-    mStream->InitOwner(this);
-    rv = mStream->Init();
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-  }
-
-  return mStream->OpenStream(aBaseURI, aContentType);
-}
-
-
-NS_IMETHODIMP
-nsWebBrowser::AppendToStream(const uint8_t* aData, uint32_t aLen)
-{
-  if (!mStream) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return mStream->AppendToStream(aData, aLen);
-}
-
-NS_IMETHODIMP
-nsWebBrowser::CloseStream()
-{
-  nsresult rv;
-
-  if (!mStream) {
-    return NS_ERROR_FAILURE;
-  }
-  rv = mStream->CloseStream();
-
-  mStream = nullptr;
-
-  return rv;
-}
--- a/toolkit/components/browser/nsWebBrowser.h
+++ b/toolkit/components/browser/nsWebBrowser.h
@@ -27,20 +27,18 @@
 #include "nsIWidget.h"
 #include "nsIWebProgress.h"
 #include "nsISecureBrowserUI.h"
 #include "nsIWebBrowser.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebBrowserSetup.h"
 #include "nsIWebBrowserPersist.h"
 #include "nsIWebBrowserFocus.h"
-#include "nsIWebBrowserStream.h"
 #include "nsIWindowWatcher.h"
 #include "nsIPrintSettings.h"
-#include "nsEmbedStream.h"
 #include "nsIWidgetListener.h"
 
 #include "mozilla/BasePrincipal.h"
 #include "nsTArray.h"
 #include "nsWeakPtr.h"
 
 class nsWebBrowserInitInfo
 {
@@ -78,17 +76,16 @@ class nsWebBrowser final : public nsIWeb
                            public nsIDocShellTreeItem,
                            public nsIBaseWindow,
                            public nsIScrollable,
                            public nsITextScroll,
                            public nsIInterfaceRequestor,
                            public nsIWebBrowserPersist,
                            public nsIWebBrowserFocus,
                            public nsIWebProgressListener,
-                           public nsIWebBrowserStream,
                            public nsIWidgetListener,
                            public nsSupportsWeakReference
 {
   friend class nsDocShellTreeOwner;
 
 public:
   nsWebBrowser();
 
@@ -100,17 +97,16 @@ public:
   NS_DECL_NSISCROLLABLE
   NS_DECL_NSITEXTSCROLL
   NS_DECL_NSIWEBBROWSER
   NS_DECL_NSIWEBNAVIGATION
   NS_DECL_NSIWEBBROWSERSETUP
   NS_DECL_NSIWEBBROWSERPERSIST
   NS_DECL_NSICANCELABLE
   NS_DECL_NSIWEBBROWSERFOCUS
-  NS_DECL_NSIWEBBROWSERSTREAM
   NS_DECL_NSIWEBPROGRESSLISTENER
 
 protected:
   virtual ~nsWebBrowser();
   NS_IMETHOD InternalDestroy();
 
   // XXXbz why are these NS_IMETHOD?  They're not interface methods!
   NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
@@ -152,17 +148,14 @@ protected:
   nscolor mBackgroundColor;
 
   // persistence object
   nsCOMPtr<nsIWebBrowserPersist> mPersist;
   uint32_t mPersistCurrentState;
   nsresult mPersistResult;
   uint32_t mPersistFlags;
 
-  // stream
-  RefPtr<nsEmbedStream> mStream;
-
   // Weak Reference interfaces...
   nsIWidget* mParentWidget;
   nsAutoPtr<nsTArray<nsWebBrowserListenerState> > mListenerArray;
 };
 
 #endif /* nsWebBrowser_h__ */