mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP headers, don't do redirects, observers, load groups, or anything else other than basic things like looking at the reply body, Content-type, Content-length, etc. - Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922) - Only used if "NECKO_E10S_HTTP" set in environment. - Force http.h to get #included before any IPDL files, to centralize #define handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug 545995)
This commit is contained in:
parent
1ad383c970
commit
5ffecf8e1f
@ -38,6 +38,7 @@
|
||||
#include "necko-config.h"
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#define ALLOW_LATE_NSHTTP_H_INCLUDE 1
|
||||
#include "base/basictypes.h"
|
||||
#endif
|
||||
|
||||
|
@ -53,6 +53,7 @@ EXPORTS_NAMESPACES = mozilla/net
|
||||
EXPORTS_mozilla/net = \
|
||||
NeckoParent.h \
|
||||
NeckoChild.h \
|
||||
NeckoCommon.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -60,6 +61,11 @@ CPPSRCS = \
|
||||
NeckoParent.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../protocol/http/src \
|
||||
-I$(srcdir)/../base/src \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -38,6 +38,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsHttp.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/dom/ContentProcessChild.h"
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
@ -58,7 +59,9 @@ NeckoChild::~NeckoChild()
|
||||
|
||||
void NeckoChild::InitNeckoChild()
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
NS_ABORT_IF_FALSE(IsNeckoChild(), "InitNeckoChild called by non-child!");
|
||||
|
||||
if (!gNeckoChild) {
|
||||
mozilla::dom::ContentProcessChild * cpc =
|
||||
mozilla::dom::ContentProcessChild::GetSingleton();
|
||||
NS_ASSERTION(cpc, "Content Protocol is NULL!");
|
||||
@ -67,16 +70,36 @@ void NeckoChild::InitNeckoChild()
|
||||
}
|
||||
}
|
||||
|
||||
// Note: not actually called; has some lifespan as child process, so
|
||||
// automatically destroyed at exit.
|
||||
void NeckoChild::DestroyNeckoChild()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(IsNeckoChild(), "DestroyNeckoChild called by non-child!");
|
||||
static bool alreadyDestroyed = false;
|
||||
NS_ABORT_IF_FALSE(!alreadyDestroyed, "DestroyNeckoChild already called!");
|
||||
|
||||
if (!alreadyDestroyed) {
|
||||
Send__delete__(gNeckoChild);
|
||||
gNeckoChild = nsnull;
|
||||
alreadyDestroyed = true;
|
||||
}
|
||||
}
|
||||
|
||||
PHttpChannelChild*
|
||||
NeckoChild::AllocPHttpChannel()
|
||||
{
|
||||
return new HttpChannelChild();
|
||||
// We don't allocate here: see HttpChannelChild::AsyncOpen()
|
||||
NS_RUNTIMEABORT("AllocPHttpChannel should not be called");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
bool
|
||||
NeckoChild::DeallocPHttpChannel(PHttpChannelChild* channel)
|
||||
{
|
||||
delete channel;
|
||||
NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPHttpChannel called by non-child!");
|
||||
|
||||
HttpChannelChild *p = static_cast<HttpChannelChild*>(channel);
|
||||
p->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,7 @@
|
||||
#define mozilla_net_NeckoChild_h
|
||||
|
||||
#include "mozilla/net/PNeckoChild.h"
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -57,11 +56,11 @@ public:
|
||||
virtual ~NeckoChild();
|
||||
|
||||
static void InitNeckoChild();
|
||||
|
||||
virtual PHttpChannelChild* AllocPHttpChannel();
|
||||
virtual bool DeallocPHttpChannel(PHttpChannelChild*);
|
||||
static void DestroyNeckoChild();
|
||||
|
||||
protected:
|
||||
virtual PHttpChannelChild* AllocPHttpChannel();
|
||||
virtual bool DeallocPHttpChannel(PHttpChannelChild*);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -70,12 +69,6 @@ protected:
|
||||
*/
|
||||
extern PNeckoChild *gNeckoChild;
|
||||
|
||||
static inline PRBool
|
||||
IsNeckoChild()
|
||||
{
|
||||
return XRE_GetProcessType() == GeckoProcessType_Content;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
|
87
netwerk/ipc/NeckoCommon.h
Normal file
87
netwerk/ipc/NeckoCommon.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 : */
|
||||
|
||||
/* ***** 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
|
||||
* The Mozilla Foundation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jason Duell <jduell.mcbugs@gmail.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 ***** */
|
||||
|
||||
#ifndef mozilla_net_NeckoCommon_h
|
||||
#define mozilla_net_NeckoCommon_h
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
// Temporary: use while we figure out which XPCOM interfaces (from list
|
||||
// copied from nsHttpChannel) HttpChannel{Child|Parent}, etc., actually need to
|
||||
// implement. I.e., implement interfaces as we need them, and if we never hit a
|
||||
// given interface, figure out if we can stop advertising it.
|
||||
|
||||
#define DROP_DEAD() \
|
||||
do { \
|
||||
fprintf(stderr, \
|
||||
"*&*&*&*&*&*&*&**&*&&*& FATAL ERROR: '%s' UNIMPLEMENTED: %s +%d", \
|
||||
__FUNCTION__, __FILE__, __LINE__); \
|
||||
NS_ABORT(); \
|
||||
return NS_ERROR_NOT_IMPLEMENTED; \
|
||||
} while (0)
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
inline bool
|
||||
IsNeckoChild()
|
||||
{
|
||||
// TODO: remove env var check eventually.
|
||||
// - For now: if unset, necko works with full stack in each process,
|
||||
// i.e. no IPC.
|
||||
static bool didCheck = false;
|
||||
static bool amChild = false;
|
||||
|
||||
if (!didCheck) {
|
||||
const char * e = PR_GetEnv("NECKO_E10S_HTTP");
|
||||
if (e && *e)
|
||||
amChild = (XRE_GetProcessType() == GeckoProcessType_Content);
|
||||
didCheck = true;
|
||||
}
|
||||
return amChild;
|
||||
}
|
||||
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_net_NeckoCommon_h
|
||||
|
@ -38,6 +38,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsHttp.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
#include "mozilla/net/HttpChannelParent.h"
|
||||
|
||||
@ -56,13 +57,16 @@ NeckoParent::~NeckoParent()
|
||||
PHttpChannelParent*
|
||||
NeckoParent::AllocPHttpChannel()
|
||||
{
|
||||
return new HttpChannelParent();
|
||||
HttpChannelParent *p = new HttpChannelParent();
|
||||
p->AddRef();
|
||||
return p;
|
||||
}
|
||||
|
||||
bool
|
||||
NeckoParent::DeallocPHttpChannel(PHttpChannelParent* channel)
|
||||
{
|
||||
delete channel;
|
||||
HttpChannelParent *p = static_cast<HttpChannelParent *>(channel);
|
||||
p->Release();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/net/PNeckoParent.h"
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
|
||||
#ifndef mozilla_net_NeckoParent_h
|
||||
#define mozilla_net_NeckoParent_h
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,20 +42,138 @@
|
||||
#define mozilla_net_HttpChannelChild_h
|
||||
|
||||
#include "mozilla/net/PHttpChannelChild.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
|
||||
#include "nsHttpRequestHead.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsICacheListener.h"
|
||||
#include "nsIApplicationCache.h"
|
||||
#include "nsIApplicationCacheChannel.h"
|
||||
#include "nsIEncodedChannel.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsIUploadChannel2.h"
|
||||
#include "nsIResumableChannel.h"
|
||||
#include "nsISupportsPriority.h"
|
||||
#include "nsIProtocolProxyCallback.h"
|
||||
#include "nsIProxiedChannel.h"
|
||||
#include "nsITraceableChannel.h"
|
||||
#include "nsIAuthPromptCallback.h"
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
// TODO: replace with IPDL states
|
||||
enum HttpChannelChildState {
|
||||
HCC_NEW,
|
||||
HCC_OPENED,
|
||||
HCC_ONSTART,
|
||||
HCC_ONDATA,
|
||||
HCC_ONSTOP
|
||||
};
|
||||
|
||||
// Header file contents
|
||||
class HttpChannelChild :
|
||||
public PHttpChannelChild
|
||||
class HttpChannelChild : public PHttpChannelChild
|
||||
, public nsIHttpChannel
|
||||
, public nsHashPropertyBag
|
||||
, public nsIHttpChannelInternal
|
||||
, public nsIStreamListener
|
||||
, public nsICachingChannel
|
||||
, public nsIUploadChannel
|
||||
, public nsIUploadChannel2
|
||||
, public nsICacheListener
|
||||
, public nsIEncodedChannel
|
||||
, public nsITransportEventSink
|
||||
, public nsIResumableChannel
|
||||
, public nsISupportsPriority
|
||||
, public nsIProtocolProxyCallback
|
||||
, public nsIProxiedChannel
|
||||
, public nsITraceableChannel
|
||||
, public nsIApplicationCacheChannel
|
||||
, public nsIAuthPromptCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSIHTTPCHANNEL
|
||||
NS_DECL_NSIHTTPCHANNELINTERNAL
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSICACHINGCHANNEL
|
||||
NS_DECL_NSIUPLOADCHANNEL
|
||||
NS_DECL_NSIUPLOADCHANNEL2
|
||||
NS_DECL_NSICACHELISTENER
|
||||
NS_DECL_NSIENCODEDCHANNEL
|
||||
NS_DECL_NSITRANSPORTEVENTSINK
|
||||
NS_DECL_NSIRESUMABLECHANNEL
|
||||
NS_DECL_NSISUPPORTSPRIORITY
|
||||
NS_DECL_NSIPROTOCOLPROXYCALLBACK
|
||||
NS_DECL_NSIPROXIEDCHANNEL
|
||||
NS_DECL_NSITRACEABLECHANNEL
|
||||
NS_DECL_NSIAPPLICATIONCACHECONTAINER
|
||||
NS_DECL_NSIAPPLICATIONCACHECHANNEL
|
||||
NS_DECL_NSIAUTHPROMPTCALLBACK
|
||||
|
||||
HttpChannelChild();
|
||||
virtual ~HttpChannelChild();
|
||||
|
||||
nsresult Init(nsIURI *uri);
|
||||
|
||||
protected:
|
||||
bool RecvOnStartRequest(const PRInt32& HACK_ContentLength,
|
||||
const nsCString& HACK_ContentType,
|
||||
const PRUint32& HACK_Status,
|
||||
const nsCString& HACK_StatusText);
|
||||
bool RecvOnDataAvailable(const nsCString& data,
|
||||
const PRUint32& offset,
|
||||
const PRUint32& count);
|
||||
bool RecvOnStopRequest(const nsresult& statusCode);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIStreamListener> mChildListener;
|
||||
nsCOMPtr<nsISupports> mChildListenerContext;
|
||||
|
||||
// FIXME: copy full ResponseHead (bug 536283)
|
||||
PRInt32 mContentLength_HACK;
|
||||
nsCString mContentType_HACK;
|
||||
PRUint32 mResponseStatus_HACK;
|
||||
nsCString mResponseStatusText_HACK;
|
||||
|
||||
// FIXME: replace with IPDL states (bug 536319)
|
||||
enum HttpChannelChildState mState;
|
||||
|
||||
/**
|
||||
* fields copied from nsHttpChannel.h
|
||||
*/
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
||||
|
||||
nsHttpRequestHead mRequestHead;
|
||||
|
||||
nsCString mSpec; // ASCII encoded URL spec
|
||||
|
||||
PRUint32 mLoadFlags;
|
||||
PRUint32 mStatus;
|
||||
|
||||
// state flags
|
||||
PRUint32 mIsPending : 1;
|
||||
PRUint32 mWasOpened : 1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,7 +38,10 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsHttp.h"
|
||||
#include "mozilla/net/HttpChannelParent.h"
|
||||
#include "nsHttpChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -53,12 +56,176 @@ HttpChannelParent::~HttpChannelParent()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
bool HttpChannelParent::RecvasyncOpen(const nsCString& uri)
|
||||
// HttpChannelParent::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS3(HttpChannelParent,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIInterfaceRequestor);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelParent::PHttpChannelParent
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
|
||||
const nsCString& charset,
|
||||
const nsCString& originalUriSpec,
|
||||
const nsCString& originalCharset,
|
||||
const nsCString& docUriSpec,
|
||||
const nsCString& docCharset,
|
||||
const PRUint32& loadFlags)
|
||||
{
|
||||
puts("[HttpChannelParent] got asyncOpen msg");
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
|
||||
if (NS_FAILED(rv))
|
||||
return false; // TODO: send fail msg to child, return true
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), uriSpec, charset.get(), nsnull, ios);
|
||||
if (NS_FAILED(rv))
|
||||
return false; // TODO: send fail msg to child, return true
|
||||
|
||||
// Delay log to here, as gHttpLog may not exist in parent until we init
|
||||
// gHttpHandler via above call to NS_NewURI. Avoids segfault :)
|
||||
LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s (%s)]\n",
|
||||
this, uriSpec.get(), charset.get()));
|
||||
|
||||
nsCOMPtr<nsIChannel> chan;
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, ios, nsnull, nsnull, loadFlags);
|
||||
if (NS_FAILED(rv))
|
||||
return false; // TODO: send fail msg to child, return true
|
||||
|
||||
if (!originalUriSpec.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> originalUri;
|
||||
rv = NS_NewURI(getter_AddRefs(originalUri), originalUriSpec,
|
||||
originalCharset.get(), nsnull, ios);
|
||||
if (!NS_FAILED(rv))
|
||||
chan->SetOriginalURI(originalUri);
|
||||
}
|
||||
if (!docUriSpec.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> docUri;
|
||||
rv = NS_NewURI(getter_AddRefs(docUri), docUriSpec,
|
||||
docCharset.get(), nsnull, ios);
|
||||
if (!NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIHttpChannelInternal> iChan(do_QueryInterface(chan));
|
||||
if (iChan)
|
||||
iChan->SetDocumentURI(docUri);
|
||||
}
|
||||
}
|
||||
if (loadFlags != nsIRequest::LOAD_NORMAL)
|
||||
chan->SetLoadFlags(loadFlags);
|
||||
|
||||
// TODO: implement needed interfaces, and either proxy calls back to child
|
||||
// process, or rig up appropriate hacks.
|
||||
// chan->SetNotificationCallbacks(this);
|
||||
|
||||
rv = chan->AsyncOpen(this, nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return false; // TODO: send fail msg to child, return true
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelParent::nsIRequestObserver
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
LOG(("HttpChannelParent::OnStartRequest [this=%x]\n", this));
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> chan(do_QueryInterface(aRequest));
|
||||
NS_ENSURE_TRUE(chan, NS_ERROR_FAILURE);
|
||||
|
||||
/*
|
||||
* - TODO: Need to send all or most of mResponseHead
|
||||
* - TODO: if getting vals fails, still need to call OnStartRequest on child,
|
||||
* not just fail here?
|
||||
*/
|
||||
PRInt32 contentLength_HACK;
|
||||
chan->GetContentLength(&contentLength_HACK);
|
||||
nsCAutoString contentType_HACK;
|
||||
chan->GetContentType(contentType_HACK);
|
||||
PRUint32 status_HACK;
|
||||
chan->GetResponseStatus(&status_HACK);
|
||||
nsCAutoString statusText_HACK;
|
||||
chan->GetResponseStatusText(statusText_HACK);
|
||||
|
||||
if (!SendOnStartRequest(contentLength_HACK, contentType_HACK,
|
||||
status_HACK, statusText_HACK))
|
||||
{
|
||||
// IPDL error--child dead/dying & our own destructor will be called
|
||||
// automatically
|
||||
// -- TODO: verify that that's the case :)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsresult aStatusCode)
|
||||
{
|
||||
LOG(("HttpChannelParent::OnStopRequest: [this=%x status=%ul]\n",
|
||||
this, aStatusCode));
|
||||
|
||||
if (!SendOnStopRequest(aStatusCode)) {
|
||||
// IPDL error--child dead/dying & our own destructor will be called
|
||||
// automatically
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelParent::nsIStreamListener
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
||||
nsISupports *aContext,
|
||||
nsIInputStream *aInputStream,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount)
|
||||
{
|
||||
LOG(("HttpChannelParent::OnDataAvailable [this=%x]\n", this));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCString data;
|
||||
data.SetLength(aCount);
|
||||
char * p = data.BeginWriting();
|
||||
PRUint32 bytesRead;
|
||||
rv = aInputStream->Read(p, aCount, &bytesRead);
|
||||
data.EndWriting();
|
||||
if (!NS_SUCCEEDED(rv) || bytesRead != aCount) {
|
||||
return rv; // TODO: figure out error handling
|
||||
}
|
||||
|
||||
if (!SendOnDataAvailable(data, aOffset, bytesRead)) {
|
||||
// IPDL error--child dead/dying & our own destructor will be called
|
||||
// automatically
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelParent::nsIInterfaceRequestor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelParent::GetInterface(const nsIID& uuid, void **result)
|
||||
{
|
||||
DROP_DEAD();
|
||||
}
|
||||
|
||||
|
||||
}} // mozilla::net
|
||||
|
||||
|
@ -41,21 +41,37 @@
|
||||
#ifndef mozilla_net_HttpChannelParent_h
|
||||
#define mozilla_net_HttpChannelParent_h
|
||||
|
||||
#include "nsHttp.h"
|
||||
#include "mozilla/net/PHttpChannelParent.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
// Header file contents
|
||||
class HttpChannelParent :
|
||||
public PHttpChannelParent
|
||||
class HttpChannelParent : public PHttpChannelParent
|
||||
, public nsIStreamListener
|
||||
, public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
HttpChannelParent();
|
||||
virtual ~HttpChannelParent();
|
||||
|
||||
protected:
|
||||
virtual bool RecvasyncOpen(const nsCString& uri);
|
||||
virtual bool RecvAsyncOpen(const nsCString& uriSpec,
|
||||
const nsCString& originCharset,
|
||||
const nsCString& originalUriSpec,
|
||||
const nsCString& originalCharset,
|
||||
const nsCString& docUriSpec,
|
||||
const nsCString& docCharset,
|
||||
const PRUint32& loadFlags);
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
@ -83,7 +83,10 @@ CPPSRCS += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES=-I$(srcdir)/../../../base/src -I$(topsrcdir)/xpcom/ds
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
-I$(topsrcdir)/xpcom/ds \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
|
@ -43,7 +43,6 @@ include protocol "PNecko.ipdl";
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protocol PHttpChannel
|
||||
{
|
||||
@ -52,7 +51,29 @@ protocol PHttpChannel
|
||||
parent:
|
||||
__delete__();
|
||||
|
||||
asyncOpen(nsCString uri);
|
||||
AsyncOpen(nsCString uriSpec,
|
||||
nsCString originCharset,
|
||||
// - TODO: unclear if any HTTP channel clients ever set
|
||||
// originalURI != uri (about:credits?); also not clear if chrome
|
||||
// channel would ever need to know. Can we get rid of next two
|
||||
// args?
|
||||
nsCString originalUriSpec,
|
||||
nsCString originalCharset,
|
||||
nsCString documentUriSpec,
|
||||
nsCString documentCharset,
|
||||
PRUint32 loadFlags);
|
||||
|
||||
child:
|
||||
OnStartRequest(PRInt32 HACK_ContentLength,
|
||||
nsCString HACK_ContentType,
|
||||
PRUint32 HACK_Status,
|
||||
nsCString HACK_StatusText);
|
||||
|
||||
OnDataAvailable(nsCString data,
|
||||
PRUint32 offset,
|
||||
PRUint32 count);
|
||||
|
||||
OnStopRequest(nsresult statusCode);
|
||||
};
|
||||
|
||||
|
||||
|
@ -45,8 +45,22 @@
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
// e10s mess: IPDL-generatd headers include chromium which both #includes
|
||||
// prlog.h, and #defines LOG in conflict with this file.
|
||||
// Solution: (as described in bug 545995)
|
||||
// 1) ensure that this file is #included before any IPDL-generated files and
|
||||
// anything else that #includes prlog.h, so that we can make sure prlog.h
|
||||
// sees FORCE_PR_LOG if needed.
|
||||
// 2) #include IPDL boilerplate, and then undef LOG so our LOG wins.
|
||||
// 3) nsNetModule.cpp does its own crazy stuff with #including prlog.h
|
||||
// multiple times; allow it to define ALLOW_LATE_NSHTTP_H_INCLUDE to bypass
|
||||
// check.
|
||||
#if defined(PR_LOG) && !defined(ALLOW_LATE_NSHTTP_H_INCLUDE)
|
||||
#error "If nsHttp.h #included it must come before any IPDL-generated files or other files that #include prlog.h"
|
||||
#endif
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#endif
|
||||
#undef LOG
|
||||
#endif // MOZ_IPC
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
@ -71,7 +85,6 @@
|
||||
extern PRLogModuleInfo *gHttpLog;
|
||||
#endif
|
||||
|
||||
#undef LOG
|
||||
// http logging
|
||||
#define LOG1(args) PR_LOG(gHttpLog, 1, args)
|
||||
#define LOG2(args) PR_LOG(gHttpLog, 2, args)
|
||||
|
@ -77,6 +77,10 @@
|
||||
|
||||
#include "nsIXULAppInfo.h"
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
@ -97,6 +101,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef MOZ_IPC
|
||||
using namespace mozilla::net;
|
||||
#include "mozilla/net/HttpChannelChild.h"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -208,6 +213,9 @@ nsHttpHandler::~nsHttpHandler()
|
||||
NS_RELEASE(mConnMgr);
|
||||
}
|
||||
|
||||
// Note: don't call NeckoChild::DestroyNeckoChild() here, as it's too late
|
||||
// and it'll segfault. NeckoChild will get cleaned up by process exit.
|
||||
|
||||
nsHttp::DestroyAtomTable();
|
||||
|
||||
gHttpHandler = nsnull;
|
||||
@ -231,7 +239,7 @@ nsHttpHandler::Init()
|
||||
}
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
if (IsNeckoChild() && !gNeckoChild)
|
||||
if (IsNeckoChild())
|
||||
NeckoChild::InitNeckoChild();
|
||||
#endif // MOZ_IPC
|
||||
|
||||
@ -1497,6 +1505,32 @@ nsHttpHandler::NewProxiedChannel(nsIURI *uri,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
#if MOZ_IPC
|
||||
if (IsNeckoChild()) {
|
||||
LOG(("NECKO_E10S_HTTP set: using experimental interprocess HTTP\n"));
|
||||
// TODO_JCD:
|
||||
// - Create a common BaseHttpChannel so can share logic?
|
||||
HttpChannelChild *childChannel = nsnull;
|
||||
NS_NEWXPCOM(childChannel, HttpChannelChild);
|
||||
if (!childChannel)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(childChannel);
|
||||
// TODO: Just ignore HTTPS and proxying for now
|
||||
if (https)
|
||||
DROP_DEAD();
|
||||
if (givenProxyInfo)
|
||||
DROP_DEAD();
|
||||
// TODO: Init caps, etc, as below?
|
||||
rv = childChannel->Init(uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(childChannel);
|
||||
return rv;
|
||||
}
|
||||
*result = childChannel;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_NEWXPCOM(httpChannel, nsHttpChannel);
|
||||
if (!httpChannel)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user