зеркало из https://github.com/mozilla/gecko-dev.git
Bug 541496 prelim 1: remove nsIUnicharStreamListener (no in-tree implementations). r=hsivonen
This commit is contained in:
Родитель
89ca9ad02b
Коммит
3febb9d39a
|
@ -57,7 +57,6 @@ SDK_XPIDLSRCS = \
|
|||
nsIURL.idl \
|
||||
nsIFileURL.idl \
|
||||
nsIUploadChannel.idl \
|
||||
nsIUnicharStreamListener.idl \
|
||||
nsITraceableChannel.idl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIRequestObserver.idl"
|
||||
|
||||
/**
|
||||
* nsIUnicharStreamListener is very similar to nsIStreamListener with
|
||||
* the difference being that this interface gives notifications about
|
||||
* data being available after the raw data has been converted to
|
||||
* UTF-16.
|
||||
*
|
||||
* nsIUnicharStreamListener
|
||||
*/
|
||||
[scriptable, uuid(4a7e9b62-fef8-400d-9865-d6820f630b4c)]
|
||||
interface nsIUnicharStreamListener : nsIRequestObserver
|
||||
{
|
||||
/**
|
||||
* Called when the next chunk of data (corresponding to the
|
||||
* request) is available.
|
||||
*
|
||||
* @param aRequest request corresponding to the source of the data
|
||||
* @param aContext user defined context
|
||||
* @param aData the data chunk
|
||||
*
|
||||
* An exception thrown from onUnicharDataAvailable has the
|
||||
* side-effect of causing the request to be canceled.
|
||||
*/
|
||||
void onUnicharDataAvailable(in nsIRequest aRequest,
|
||||
in nsISupports aContext, in AString aData);
|
||||
};
|
|
@ -53,7 +53,6 @@
|
|||
#include "nsCOMArray.h"
|
||||
#include "nsContentSink.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsIUnicharStreamListener.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsDetectionConfident.h"
|
||||
|
|
|
@ -69,10 +69,6 @@ EXPORTS = \
|
|||
nsToken.h \
|
||||
$(NULL)
|
||||
|
||||
SDK_HEADERS = \
|
||||
nsParserDataListener.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_DEBUG
|
||||
EXPORTS += \
|
||||
nsILoggingSink.h \
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsParserDataListener_h__
|
||||
#define __nsParserDataListener_h__
|
||||
|
||||
/*
|
||||
* Include this header if you're implementing a parser data
|
||||
* listener. To make a component a parser data listener you'll need to
|
||||
* make your component implement the interface
|
||||
* nsIUnicharStreamListener. That interface has three methods (one +
|
||||
* two inherited ones, not counting what's defined in
|
||||
* nsISupports). The methods are:
|
||||
*
|
||||
* void onStartRequest(in nsIRequest aRequest,
|
||||
* in nsISupports aContext);
|
||||
* void onUnicharDataAvailable(in nsIRequest aRequest,
|
||||
* in nsISupports aContext, in AString aData);
|
||||
* void onStopRequest(in nsIRequest aRequest,
|
||||
* in nsISupports aContext,
|
||||
* in nsresult aStatusCode);
|
||||
*
|
||||
* All those methods are called for every network request that ends up
|
||||
* feeding data to the parser. The method are called in the order
|
||||
* shown above, first one call to onStartRequest(), then one call to
|
||||
* onUnicharDataAvailable() per chunk of data received and converted
|
||||
* to UTF-16, and finally one call to onStopRequest().
|
||||
*
|
||||
* The nsIRequest passed into these methods will be the same object
|
||||
* for all these calls for a given network request. If the request
|
||||
* pointer is used to uniquely identify an ongoing request, the
|
||||
* pointer should be QueryInterface()'d to nsISupports to ensure that
|
||||
* the pointer used is the identity pointer to the object.
|
||||
*
|
||||
* The context argument passed to these methods will be the document
|
||||
* (nsIDOMDocument) parsed from the stream, or null when not
|
||||
* available.
|
||||
*
|
||||
* Any errors returned from any of these calls will end up canceling
|
||||
* the stream, and the data that is passed to the call in question
|
||||
* will *not* be seen by the parser. So unless you intend to interrupt
|
||||
* a request, *make sure* that you return NS_OK from these methods!
|
||||
*/
|
||||
|
||||
#include "nsIUnicharStreamListener.h"
|
||||
|
||||
/*
|
||||
* To register a component to be a parser data listener the
|
||||
* component's contract id should be registered with the category
|
||||
* manager (nsICategoryManager), with the category
|
||||
* PARSER_DATA_LISTENER_CATEGORY, defined here.
|
||||
*/
|
||||
#define PARSER_DATA_LISTENER_CATEGORY "Parser data listener"
|
||||
|
||||
#endif // __nsParserDataListener_h__
|
|
@ -88,10 +88,6 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
nsCOMArray<nsIUnicharStreamListener> *nsParser::sParserDataListeners;
|
||||
|
||||
//-------------- Begin ParseContinue Event Definition ------------------------
|
||||
/*
|
||||
The parser can be explicitly interrupted by passing a return value of
|
||||
|
@ -672,47 +668,6 @@ nsresult
|
|||
nsParser::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICategoryManager> cm =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> e;
|
||||
rv = cm->EnumerateCategory("Parser data listener", getter_AddRefs(e));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString categoryEntry;
|
||||
nsXPIDLCString contractId;
|
||||
nsCOMPtr<nsISupports> entry;
|
||||
|
||||
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
||||
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
||||
|
||||
if (!category) {
|
||||
NS_WARNING("Category entry not an nsISupportsCString!");
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = category->GetData(categoryEntry);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cm->GetCategoryEntry("Parser data listener", categoryEntry.get(),
|
||||
getter_Copies(contractId));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicharStreamListener> listener =
|
||||
do_CreateInstance(contractId.get());
|
||||
|
||||
if (listener) {
|
||||
if (!sParserDataListeners) {
|
||||
sParserDataListeners = new nsCOMArray<nsIUnicharStreamListener>();
|
||||
|
||||
if (!sParserDataListeners)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
sParserDataListeners->AppendObject(listener);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICharsetAlias> charsetAlias =
|
||||
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
|
||||
|
@ -750,9 +705,6 @@ nsParser::Init()
|
|||
// static
|
||||
void nsParser::Shutdown()
|
||||
{
|
||||
delete sParserDataListeners;
|
||||
sParserDataListeners = nsnull;
|
||||
|
||||
NS_IF_RELEASE(sCharsetAliasService);
|
||||
NS_IF_RELEASE(sCharsetConverterManager);
|
||||
if (sSpeculativeThreadPool) {
|
||||
|
@ -1847,35 +1799,6 @@ void nsParser::HandleParserContinueEvent(nsParserContinueEvent *ev)
|
|||
ContinueInterruptedParsing();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsParser::DataAdded(const nsSubstring& aData, nsIRequest *aRequest)
|
||||
{
|
||||
NS_ASSERTION(sParserDataListeners,
|
||||
"Don't call this with no parser data listeners!");
|
||||
|
||||
if (!mSink || !aRequest) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsISupports *ctx = mSink->GetTarget();
|
||||
PRInt32 count = sParserDataListeners->Count();
|
||||
nsresult rv = NS_OK;
|
||||
PRBool canceled = PR_FALSE;
|
||||
|
||||
while (count--) {
|
||||
rv |= sParserDataListeners->ObjectAt(count)->
|
||||
OnUnicharDataAvailable(aRequest, ctx, aData);
|
||||
|
||||
if (NS_FAILED(rv) && !canceled) {
|
||||
aRequest->Cancel(rv);
|
||||
|
||||
canceled = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsParser::CanInterrupt()
|
||||
{
|
||||
|
@ -1957,12 +1880,6 @@ nsParser::Parse(nsIURI* aURL,
|
|||
pc->mDTDMode = aMode;
|
||||
PushContext(*pc);
|
||||
|
||||
// Here, and only here, hand this parser off to the scanner. We
|
||||
// only want to do that here since the only reason the scanner
|
||||
// needs the parser is to call DataAdded() on it, and that's
|
||||
// only ever wanted when parsing from an URI.
|
||||
theScanner->SetParser(this);
|
||||
|
||||
result = NS_OK;
|
||||
} else {
|
||||
result = mInternalState = NS_ERROR_HTMLPARSER_BADCONTEXT;
|
||||
|
@ -2447,16 +2364,6 @@ nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext)
|
|||
|
||||
rv = NS_OK;
|
||||
|
||||
if (sParserDataListeners && mSink) {
|
||||
nsISupports *ctx = mSink->GetTarget();
|
||||
PRInt32 count = sParserDataListeners->Count();
|
||||
|
||||
while (count--) {
|
||||
rv |= sParserDataListeners->ObjectAt(count)->
|
||||
OnStartRequest(request, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2956,16 +2863,6 @@ nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext,
|
|||
mObserver->OnStopRequest(request, aContext, status);
|
||||
}
|
||||
|
||||
if (sParserDataListeners && mSink) {
|
||||
nsISupports *ctx = mSink->GetTarget();
|
||||
PRInt32 count = sParserDataListeners->Count();
|
||||
|
||||
while (count--) {
|
||||
rv |= sParserDataListeners->ObjectAt(count)->OnStopRequest(request, ctx,
|
||||
status);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
#include "nsIContentSink.h"
|
||||
#include "nsIParserFilter.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIUnicharStreamListener.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
|
@ -384,14 +383,6 @@ class nsParser : public nsIParser,
|
|||
*/
|
||||
void HandleParserContinueEvent(class nsParserContinueEvent *);
|
||||
|
||||
/**
|
||||
* Called by top-level scanners when data from necko is added to
|
||||
* the scanner.
|
||||
*/
|
||||
nsresult DataAdded(const nsSubstring& aData, nsIRequest *aRequest);
|
||||
|
||||
static nsCOMArray<nsIUnicharStreamListener> *sParserDataListeners;
|
||||
|
||||
static nsICharsetAlias* GetCharsetAliasService() {
|
||||
return sCharsetAliasService;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ const int kBufsize=64;
|
|||
*/
|
||||
nsScanner::nsScanner(const nsAString& anHTMLString, const nsACString& aCharset,
|
||||
PRInt32 aSource)
|
||||
: mParser(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsScanner);
|
||||
|
||||
|
@ -123,7 +122,7 @@ nsScanner::nsScanner(const nsAString& anHTMLString, const nsACString& aCharset,
|
|||
*/
|
||||
nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream,
|
||||
const nsACString& aCharset, PRInt32 aSource)
|
||||
: mFilename(aFilename), mParser(nsnull)
|
||||
: mFilename(aFilename)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsScanner);
|
||||
NS_ASSERTION(!aCreateStream, "This is always true.");
|
||||
|
@ -1166,14 +1165,6 @@ PRBool nsScanner::AppendToBuffer(nsScannerString::Buffer* aBuf,
|
|||
nsIRequest *aRequest,
|
||||
PRInt32 aErrorPos)
|
||||
{
|
||||
if (nsParser::sParserDataListeners && mParser &&
|
||||
NS_FAILED(mParser->DataAdded(Substring(aBuf->DataStart(),
|
||||
aBuf->DataEnd()), aRequest))) {
|
||||
// Don't actually append on failure.
|
||||
|
||||
return mSlidingBuffer != nsnull;
|
||||
}
|
||||
|
||||
PRUint32 countRemaining = mCountRemaining;
|
||||
if (!mSlidingBuffer) {
|
||||
mSlidingBuffer = new nsScannerString(aBuf);
|
||||
|
|
|
@ -310,12 +310,6 @@ class nsScanner {
|
|||
return mFirstNonWhitespacePosition;
|
||||
}
|
||||
|
||||
void SetParser(nsParser *aParser)
|
||||
{
|
||||
mParser = aParser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override replacement character used by nsIUnicodeDecoder.
|
||||
* Default behavior is that it uses nsIUnicodeDecoder's mapping.
|
||||
|
@ -352,7 +346,6 @@ class nsScanner {
|
|||
PRInt32 mCharsetSource;
|
||||
nsCString mCharset;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
|
||||
nsParser *mParser;
|
||||
|
||||
private:
|
||||
nsScanner &operator =(const nsScanner &); // Not implemented.
|
||||
|
|
Загрузка…
Ссылка в новой задаче