mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Move nsPluginStreamListenerPeer to its own files, clean up the plugin host. b=578447 r=benwa
This commit is contained in:
parent
37f506a92a
commit
7cd34cf663
@ -61,6 +61,7 @@ CPPSRCS = \
|
||||
nsNPAPIPlugin.cpp \
|
||||
nsNPAPIPluginInstance.cpp \
|
||||
nsNPAPIPluginStreamListener.cpp \
|
||||
nsPluginStreamListenerPeer.cpp \
|
||||
nsPluginHost.cpp \
|
||||
nsPluginModule.cpp \
|
||||
nsJSNPRuntime.cpp \
|
||||
|
File diff suppressed because it is too large
Load Diff
1227
modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
Normal file
1227
modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
160
modules/plugin/base/src/nsPluginStreamListenerPeer.h
Normal file
160
modules/plugin/base/src/nsPluginStreamListenerPeer.h
Normal file
@ -0,0 +1,160 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sean Echevarria <sean@beatnik.com>
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Josh Aas <josh@mozilla.com>
|
||||
*
|
||||
* 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 "nscore.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsNPAPIPluginStreamListener.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class nsIChannel;
|
||||
|
||||
/**
|
||||
* When a plugin requests opens multiple requests to the same URL and
|
||||
* the request must be satified by saving a file to disk, each stream
|
||||
* listener holds a reference to the backing file: the file is only removed
|
||||
* when all the listeners are done.
|
||||
*/
|
||||
class CachedFileHolder
|
||||
{
|
||||
public:
|
||||
CachedFileHolder(nsIFile* cacheFile);
|
||||
~CachedFileHolder();
|
||||
|
||||
void AddRef();
|
||||
void Release();
|
||||
|
||||
nsIFile* file() const { return mFile; }
|
||||
|
||||
private:
|
||||
nsAutoRefCnt mRefCnt;
|
||||
nsCOMPtr<nsIFile> mFile;
|
||||
};
|
||||
|
||||
class nsPluginStreamListenerPeer : public nsIStreamListener,
|
||||
public nsIProgressEventSink,
|
||||
public nsIHttpHeaderVisitor,
|
||||
public nsSupportsWeakReference,
|
||||
public nsINPAPIPluginStreamInfo
|
||||
{
|
||||
public:
|
||||
nsPluginStreamListenerPeer();
|
||||
virtual ~nsPluginStreamListenerPeer();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIHTTPHEADERVISITOR
|
||||
|
||||
// nsINPAPIPluginStreamInfo interface
|
||||
NS_DECL_NSIPLUGINSTREAMINFO
|
||||
|
||||
// Called by RequestRead
|
||||
void
|
||||
MakeByteRangeString(NPByteRange* aRangeList, nsACString &string, PRInt32 *numRequests);
|
||||
|
||||
PRBool UseExistingPluginCacheFile(nsPluginStreamListenerPeer* psi);
|
||||
|
||||
// Called by GetURL and PostURL (via NewStream)
|
||||
nsresult Initialize(nsIURI *aURL,
|
||||
nsIPluginInstance *aInstance,
|
||||
nsIPluginStreamListener *aListener,
|
||||
PRInt32 requestCount = 1);
|
||||
|
||||
nsresult InitializeEmbedded(nsIURI *aURL,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsIPluginInstanceOwner *aOwner = nsnull);
|
||||
|
||||
nsresult InitializeFullPage(nsIURI* aURL, nsIPluginInstance *aInstance);
|
||||
|
||||
nsresult OnFileAvailable(nsIFile* aFile);
|
||||
|
||||
nsresult ServeStreamAsFile(nsIRequest *request, nsISupports *ctxt);
|
||||
|
||||
nsIPluginInstance *GetPluginInstance() { return mInstance; }
|
||||
|
||||
private:
|
||||
nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
|
||||
nsresult SetupPluginCacheFile(nsIChannel* channel);
|
||||
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsCString mURLSpec; // Have to keep this member because GetURL hands out char*
|
||||
nsCOMPtr<nsIPluginInstanceOwner> mOwner;
|
||||
nsCOMPtr<nsIPluginInstance> mInstance;
|
||||
nsCOMPtr<nsIPluginStreamListener> mPStreamListener;
|
||||
|
||||
// Set to PR_TRUE if we request failed (like with a HTTP response of 404)
|
||||
PRPackedBool mRequestFailed;
|
||||
|
||||
/*
|
||||
* Set to PR_TRUE after nsIPluginStreamListener::OnStartBinding() has
|
||||
* been called. Checked in ::OnStopRequest so we can call the
|
||||
* plugin's OnStartBinding if, for some reason, it has not already
|
||||
* been called.
|
||||
*/
|
||||
PRPackedBool mStartBinding;
|
||||
PRPackedBool mHaveFiredOnStartRequest;
|
||||
// these get passed to the plugin stream listener
|
||||
PRUint32 mLength;
|
||||
PRInt32 mStreamType;
|
||||
|
||||
// local cached file, we save the content into local cache if browser cache is not available,
|
||||
// or plugin asks stream as file and it expects file extension until bug 90558 got fixed
|
||||
nsRefPtr<CachedFileHolder> mLocalCachedFileHolder;
|
||||
nsCOMPtr<nsIOutputStream> mFileCacheOutputStream;
|
||||
nsHashtable *mDataForwardToRequest;
|
||||
|
||||
nsCString mContentType;
|
||||
PRBool mSeekable;
|
||||
PRUint32 mModified;
|
||||
nsCOMPtr<nsIPluginInstance> mPluginInstance;
|
||||
PRInt32 mStreamOffset;
|
||||
PRBool mStreamComplete;
|
||||
|
||||
public:
|
||||
PRBool mAbort;
|
||||
PRInt32 mPendingRequests;
|
||||
nsWeakPtr mWeakPtrChannelCallbacks;
|
||||
nsWeakPtr mWeakPtrChannelLoadGroup;
|
||||
};
|
Loading…
Reference in New Issue
Block a user