Merge the last PGO-green inbound changeset to m-c.

This commit is contained in:
Ryan VanderMeulen 2012-07-22 22:01:57 -04:00
Родитель 4a7a1fccac 9a9096c83f
Коммит dca08c3a1c
44 изменённых файлов: 723 добавлений и 200 удалений

Просмотреть файл

@ -203,8 +203,7 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsINode *aNode, PRUint32 aOffset)
{
if (aNode && aNode->IsElement()) {
PRUint32 childCount = aNode->GetChildCount();
NS_ASSERTION(aOffset >= 0 && aOffset <= childCount,
"Wrong offset of the DOM point!");
NS_ASSERTION(aOffset <= childCount, "Wrong offset of the DOM point!");
// The offset can be after last child of container node that means DOM point
// is placed immediately after the last child. In this case use the DOM node

Просмотреть файл

@ -265,7 +265,7 @@ ARIAGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
void
ARIAGridAccessible::SelectedCellIndices(nsTArray<PRUint32>* aCells)
{
PRUint32 rowCount = RowCount(), colCount = ColCount();
PRUint32 colCount = ColCount();
AccIterator rowIter(this, filters::GetRow);
Accessible* row = nsnull;

Просмотреть файл

@ -1808,8 +1808,6 @@ HyperTextAccessible::SetSelectionBounds(PRInt32 aSelectionNum,
if (rangeCount < static_cast<PRUint32>(aSelectionNum))
return NS_ERROR_INVALID_ARG;
// Caret is a collapsed selection
bool isOnlyCaret = (aStartOffset == aEndOffset);
nsRefPtr<nsRange> range;
if (aSelectionNum == rangeCount)
range = new nsRange();

Просмотреть файл

@ -36,6 +36,7 @@
#include "nsArrayUtils.h"
#include "nsComponentManagerUtils.h"
using namespace mozilla;
using namespace mozilla::a11y;
////////////////////////////////////////////////////////////////////////////////
@ -766,10 +767,11 @@ HTMLTableAccessible::ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
bool isSelected;
PRInt32 columnExtent = 0;
tableLayout->
DebugOnly<nsresult> rv = tableLayout->
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
startRowIndex, startColIndex, rowSpan, colSpan,
actualRowSpan, columnExtent, isSelected);
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
return columnExtent;
}
@ -786,10 +788,11 @@ HTMLTableAccessible::RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
bool isSelected;
PRInt32 rowExtent = 0;
tableLayout->
DebugOnly<nsresult> rv = tableLayout->
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
startRowIndex, startColIndex, rowSpan, colSpan,
rowExtent, actualColSpan, isSelected);
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
return rowExtent;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "nsCOMPtr.h"
#include "nsIMutableArray.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace a11y {
@ -19,7 +20,7 @@ class Relation;
/**
* Class represents an accessible relation.
*/
class nsAccessibleRelation : public nsIAccessibleRelation
class nsAccessibleRelation MOZ_FINAL : public nsIAccessibleRelation
{
public:
nsAccessibleRelation(PRUint32 aType, Relation* aRel);

Просмотреть файл

@ -3871,6 +3871,12 @@ ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, PRUint
{
nsresult rv;
// mozJSSubScriptLoader prefixes the filenames of the scripts it loads with
// the filename of its caller. Axe that if present.
const char *arrow = strstr(filename, " -> ");
if (arrow)
filename = arrow + strlen(" -> ");
// Get the URI.
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), filename);

Просмотреть файл

@ -83,6 +83,7 @@
#include "mozilla/dom/sms/SmsChild.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
using namespace mozilla::docshell;
using namespace mozilla::dom::devicestorage;

Просмотреть файл

@ -21,6 +21,9 @@ public:
* Implementations per-platform are responsible for actually handling this.
*/
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
GeckoContentController() {};
virtual ~GeckoContentController() {};
};
}

Просмотреть файл

@ -17,6 +17,7 @@
<script type="application/javascript"><![CDATA[
const Cu = Components.utils;
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function inlinefunction() {
return 42;
@ -29,7 +30,11 @@ is(src.charAt(src.length - 1), "}", "inline XUL source should end with '}'");
src = outoflinefunction.toSource();
isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source")
is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'");
src = NetUtil.asyncFetch.toSource()
src = NetUtil.asyncFetch.toSource();
isnot(src.indexOf("return"), -1, "JSM should have source");
var ns = {};
Services.scriptloader.loadSubScript("resource://gre/modules/NetUtil.jsm", ns);
src = ns.NetUtil.asyncFetch.toSource();
isnot(src.indexOf("return"), -1, "subscript should have source");
]]></script>
</window>

Просмотреть файл

@ -58,7 +58,6 @@ XPIDLSRCS = \
nsINetworkLinkService.idl \
nsIPermission.idl \
nsIPermissionManager.idl \
nsIPrivateBrowsingConsumer.idl \
nsIPrivateBrowsingService.idl \
nsIProgressEventSink.idl \
nsIPrompt.idl \

Просмотреть файл

@ -1,22 +0,0 @@
/* 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"
[scriptable, uuid(5deb421c-592b-4375-b425-9ac11532aa30)]
interface nsIPrivateBrowsingConsumer : nsISupports
{
readonly attribute boolean usingPrivateBrowsing;
%{C++
/**
* De-XPCOMed getter to make call-sites cleaner.
*/
bool UsePrivateBrowsing() {
bool usingPB;
GetUsingPrivateBrowsing(&usingPB);
return usingPB;
}
%}
};

Просмотреть файл

@ -74,6 +74,7 @@
#include "nsISocketProvider.h"
#include "nsIRedirectChannelRegistrar.h"
#include "nsIMIMEHeaderParam.h"
#include "nsILoadContext.h"
#include "mozilla/Services.h"
#ifdef MOZILLA_INTERNAL_API
@ -1296,6 +1297,21 @@ NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
}
}
/**
* Returns true if channel is using Private Browsing, or false if not.
*
* Note: you may get a false negative if you call this before AsyncOpen has been
* called (technically, before the channel's notificationCallbacks are set: this
* is almost always done before AsyncOpen).
*/
inline bool
NS_UsePrivateBrowsing(nsIChannel *channel)
{
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(channel, loadContext);
return loadContext && loadContext->UsePrivateBrowsing();
}
/**
* Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This
* method is provided mainly for use by other methods in this file.

Просмотреть файл

@ -1,56 +0,0 @@
/* 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 mozilla_net_PrivateBrowsingConsumer_h
#define mozilla_net_PrivateBrowsingConsumer_h
#include "nsIPrivateBrowsingConsumer.h"
#include "nsILoadContext.h"
#include "nsNetUtil.h"
#include "nsXULAppAPI.h"
namespace mozilla {
namespace net {
class PrivateBrowsingConsumer : public nsIPrivateBrowsingConsumer
{
public:
PrivateBrowsingConsumer(nsIChannel* aSelf) : mSelf(aSelf), mUsingPB(false), mOverride(false) {}
NS_IMETHOD GetUsingPrivateBrowsing(bool *aUsingPB)
{
*aUsingPB = (mOverride ? mUsingPB : UsingPrivateBrowsingInternal());
return NS_OK;
}
void OverridePrivateBrowsing(bool aUsingPrivateBrowsing)
{
MOZ_ASSERT(!mOverride);
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
mOverride = true;
mUsingPB = aUsingPrivateBrowsing;
}
protected:
bool UsingPrivateBrowsingInternal()
{
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(mSelf, loadContext);
return loadContext && loadContext->UsePrivateBrowsing();
}
private:
nsIChannel* mSelf;
// Private browsing capabilities can only be determined in content
// processes, so when networking occurs these values are used in
// lieu of UsingPrivateBrowsing().
bool mUsingPB;
bool mOverride;
};
}
}
#endif // mozilla_net_PrivateBrowsingConsumer_h

Просмотреть файл

@ -245,7 +245,6 @@ private:
friend class RedirectRunnable;
nsRefPtr<nsInputStreamPump> mPump;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIProgressEventSink> mProgressSink;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mURI;
@ -264,6 +263,7 @@ private:
protected:
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsIStreamListener> mListener;
nsCOMPtr<nsISupports> mListenerContext;
nsresult mStatus;

Просмотреть файл

@ -13,6 +13,7 @@
#include "nsMimeTypes.h"
#include "nsNetUtil.h"
#include "nsIURIFixup.h"
#include "nsILoadContext.h"
#include "nsCDefaultURIFixup.h"
#include "base/compiler_specific.h"
@ -23,8 +24,7 @@ namespace mozilla {
namespace net {
FTPChannelChild::FTPChannelChild(nsIURI* uri)
: PrivateBrowsingConsumer(this)
, mIPCOpen(false)
: mIPCOpen(false)
, ALLOW_THIS_IN_INITIALIZER_LIST(mEventQ(static_cast<nsIFTPChannel*>(this)))
, mCanceled(false)
, mSuspendCount(0)
@ -160,8 +160,27 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
// Get info from nsILoadContext, if any
bool haveLoadContext = false;
bool isContent = false;
bool usePrivateBrowsing = false;
bool isInBrowserElement = false;
PRUint32 appId = 0;
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
NS_GET_IID(nsILoadContext),
getter_AddRefs(loadContext));
if (loadContext) {
haveLoadContext = true;
loadContext->GetIsContent(&isContent);
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
loadContext->GetIsInBrowserElement(&isInBrowserElement);
loadContext->GetAppId(&appId);
}
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID,
IPC::InputStream(mUploadStream), UsePrivateBrowsing());
IPC::InputStream(mUploadStream), haveLoadContext, isContent,
usePrivateBrowsing, isInBrowserElement, appId);
// The socket transport layer in the chrome process now has a logical ref to
// us until OnStopRequest is called.

Просмотреть файл

@ -16,7 +16,6 @@
#include "nsIProxiedChannel.h"
#include "nsIResumableChannel.h"
#include "nsIChildChannel.h"
#include "PrivateBrowsingConsumer.h"
#include "nsIStreamListener.h"
@ -35,7 +34,6 @@ class FTPChannelChild : public PFTPChannelChild
, public nsIResumableChannel
, public nsIProxiedChannel
, public nsIChildChannel
, public PrivateBrowsingConsumer
{
public:
typedef ::nsIStreamListener nsIStreamListener;

Просмотреть файл

@ -19,7 +19,12 @@ namespace mozilla {
namespace net {
FTPChannelParent::FTPChannelParent()
: mIPCClosed(false)
: mIPCClosed(false)
, mHaveLoadContext(false)
, mIsContent(false)
, mUsePrivateBrowsing(false)
, mIsInBrowserElement(false)
, mAppId(0)
{
nsIProtocolHandler* handler;
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &handler);
@ -43,10 +48,11 @@ FTPChannelParent::ActorDestroy(ActorDestroyReason why)
// FTPChannelParent::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_ISUPPORTS4(FTPChannelParent,
NS_IMPL_ISUPPORTS5(FTPChannelParent,
nsIStreamListener,
nsIParentChannel,
nsIInterfaceRequestor,
nsILoadContext,
nsIRequestObserver);
//-----------------------------------------------------------------------------
@ -58,7 +64,11 @@ FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
const PRUint64& aStartPos,
const nsCString& aEntityID,
const IPC::InputStream& aUploadStream,
const bool& aUsePrivateBrowsing)
const bool& haveLoadContext,
const bool& isContent,
const bool& usePrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId)
{
nsCOMPtr<nsIURI> uri(aURI);
@ -93,7 +103,13 @@ FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
if (NS_FAILED(rv))
return SendFailedAsyncOpen(rv);
mChannel->OverridePrivateBrowsing(aUsePrivateBrowsing);
// fields needed to impersonate nsILoadContext
mHaveLoadContext = haveLoadContext;
mIsContent = isContent;
mUsePrivateBrowsing = usePrivateBrowsing;
mIsInBrowserElement = isInBrowserElement;
mAppId = appId;
mChannel->SetNotificationCallbacks(this);
rv = mChannel->AsyncOpen(this, nsnull);
if (NS_FAILED(rv))
@ -229,9 +245,82 @@ FTPChannelParent::Delete()
NS_IMETHODIMP
FTPChannelParent::GetInterface(const nsIID& uuid, void** result)
{
// Only support nsILoadContext if child channel's callbacks did too
if (uuid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
return NS_NOINTERFACE;
}
return QueryInterface(uuid, result);
}
//-----------------------------------------------------------------------------
// FTPChannelParent::nsILoadContext
//-----------------------------------------------------------------------------
NS_IMETHODIMP
FTPChannelParent::GetAssociatedWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
FTPChannelParent::GetTopWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
FTPChannelParent::IsAppOfType(PRUint32, bool*)
{
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
FTPChannelParent::GetIsContent(bool *aIsContent)
{
NS_ENSURE_ARG_POINTER(aIsContent);
*aIsContent = mIsContent;
return NS_OK;
}
NS_IMETHODIMP
FTPChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
{
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
*aUsePrivateBrowsing = mUsePrivateBrowsing;
return NS_OK;
}
NS_IMETHODIMP
FTPChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
// We shouldn't need this on parent...
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
FTPChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
{
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
*aIsInBrowserElement = mIsInBrowserElement;
return NS_OK;
}
NS_IMETHODIMP
FTPChannelParent::GetAppId(PRUint32* aAppId)
{
NS_ENSURE_ARG_POINTER(aAppId);
*aAppId = mAppId;
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -12,6 +12,7 @@
#include "mozilla/net/NeckoCommon.h"
#include "nsIParentChannel.h"
#include "nsIInterfaceRequestor.h"
#include "nsILoadContext.h"
class nsFtpChannel;
@ -21,6 +22,7 @@ namespace net {
class FTPChannelParent : public PFTPChannelParent
, public nsIParentChannel
, public nsIInterfaceRequestor
, public nsILoadContext
{
public:
NS_DECL_ISUPPORTS
@ -28,6 +30,7 @@ public:
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIPARENTCHANNEL
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSILOADCONTEXT
FTPChannelParent();
virtual ~FTPChannelParent();
@ -37,7 +40,11 @@ protected:
const PRUint64& startPos,
const nsCString& entityID,
const IPC::InputStream& uploadStream,
const bool& aUsePrivateBrowsing);
const bool& haveLoadContext,
const bool& isContent,
const bool& usingPrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId);
NS_OVERRIDE virtual bool RecvConnectChannel(const PRUint32& channelId);
NS_OVERRIDE virtual bool RecvCancel(const nsresult& status);
NS_OVERRIDE virtual bool RecvSuspend();
@ -48,6 +55,14 @@ protected:
nsRefPtr<nsFtpChannel> mChannel;
bool mIPCClosed;
// fields for impersonating nsILoadContext
bool mHaveLoadContext : 1;
bool mIsContent : 1;
bool mUsePrivateBrowsing : 1;
bool mIsInBrowserElement : 1;
PRUint32 mAppId;
};
} // namespace net

Просмотреть файл

@ -23,8 +23,15 @@ async protocol PFTPChannel
parent:
__delete__();
AsyncOpen(URI uri, PRUint64 startPos, nsCString entityID,
InputStream uploadStream, bool usePrivateBrowsing);
AsyncOpen(URI uri,
PRUint64 startPos,
nsCString entityID,
InputStream uploadStream,
bool haveLoadContext,
bool isContent,
bool usePrivateBrowsing,
bool isInBrowserElement,
PRUint32 appID);
ConnectChannel(PRUint32 channelId);
Cancel(nsresult status);
Suspend();

Просмотреть файл

@ -28,14 +28,13 @@
#include "nsIResumableChannel.h"
#include "nsHashPropertyBag.h"
#include "nsFtpProtocolHandler.h"
#include "PrivateBrowsingConsumer.h"
#include "nsNetUtil.h"
class nsFtpChannel : public nsBaseChannel,
public nsIFTPChannel,
public nsIUploadChannel,
public nsIResumableChannel,
public nsIProxiedChannel,
public mozilla::net::PrivateBrowsingConsumer
public nsIProxiedChannel
{
public:
NS_DECL_ISUPPORTS_INHERITED
@ -44,8 +43,7 @@ public:
NS_DECL_NSIPROXIEDCHANNEL
nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
: mozilla::net::PrivateBrowsingConsumer(this)
, mProxyInfo(pi)
: mProxyInfo(pi)
, mStartPos(0)
, mResumeRequested(false)
, mLastModifiedTime(0)

Просмотреть файл

@ -2217,7 +2217,7 @@ nsFtpState::CheckCache()
if (!cache)
return false;
bool isPrivate = mChannel->UsePrivateBrowsing();
bool isPrivate = NS_UsePrivateBrowsing(mChannel);
const char* sessionName = isPrivate ? "FTP-private" : "FTP";
nsCacheStoragePolicy policy =
isPrivate ? nsICache::STORE_IN_MEMORY : nsICache::STORE_ANYWHERE;

Просмотреть файл

@ -27,8 +27,7 @@ namespace mozilla {
namespace net {
HttpBaseChannel::HttpBaseChannel()
: PrivateBrowsingConsumer(this)
, mStartPos(LL_MAXUINT)
: mStartPos(LL_MAXUINT)
, mStatus(NS_OK)
, mLoadFlags(LOAD_NORMAL)
, mPriority(PRIORITY_NORMAL)
@ -49,6 +48,7 @@ HttpBaseChannel::HttpBaseChannel()
, mTracingEnabled(true)
, mTimingEnabled(false)
, mAllowSpdy(true)
, mPrivateBrowsing(false)
, mSuspendCount(0)
{
LOG(("Creating HttpBaseChannel @%x\n", this));
@ -140,8 +140,8 @@ HttpBaseChannel::Init(nsIURI *aURI,
// HttpBaseChannel::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_ISUPPORTS_INHERITED10(HttpBaseChannel,
nsHashPropertyBag,
NS_IMPL_ISUPPORTS_INHERITED9( HttpBaseChannel,
nsHashPropertyBag,
nsIRequest,
nsIChannel,
nsIEncodedChannel,
@ -150,8 +150,7 @@ NS_IMPL_ISUPPORTS_INHERITED10(HttpBaseChannel,
nsIUploadChannel,
nsIUploadChannel2,
nsISupportsPriority,
nsITraceableChannel,
nsIPrivateBrowsingConsumer)
nsITraceableChannel)
//-----------------------------------------------------------------------------
// HttpBaseChannel::nsIRequest
@ -273,6 +272,9 @@ HttpBaseChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
{
mCallbacks = aCallbacks;
mProgressSink = nsnull;
// Will never change unless SetNotificationCallbacks called again, so cache
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
return NS_OK;
}

Просмотреть файл

@ -27,8 +27,8 @@
#include "nsIApplicationCache.h"
#include "nsIResumableChannel.h"
#include "nsITraceableChannel.h"
#include "nsILoadContext.h"
#include "mozilla/net/NeckoCommon.h"
#include "PrivateBrowsingConsumer.h"
#include "nsThreadUtils.h"
namespace mozilla {
@ -50,7 +50,6 @@ class HttpBaseChannel : public nsHashPropertyBag
, public nsISupportsPriority
, public nsIResumableChannel
, public nsITraceableChannel
, public PrivateBrowsingConsumer
{
public:
NS_DECL_ISUPPORTS_INHERITED
@ -186,7 +185,7 @@ public: /* Necko internal use only... */
bool ShouldRewriteRedirectToGET(PRUint32 httpStatus, nsHttpAtom method);
bool IsSafeMethod(nsHttpAtom method);
protected:
// Handle notifying listener, removing from loadgroup if request failed.
@ -265,6 +264,7 @@ protected:
// True if timing collection is enabled
PRUint32 mTimingEnabled : 1;
PRUint32 mAllowSpdy : 1;
PRUint32 mPrivateBrowsing : 1;
// Current suspension depth for this channel object
PRUint32 mSuspendCount;

Просмотреть файл

@ -1015,6 +1015,22 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
}
}
// Get info from nsILoadContext, if any
bool haveLoadContext = false;
bool isContent = false;
bool usePrivateBrowsing = false;
bool isInBrowserElement = false;
PRUint32 appId = 0;
nsCOMPtr<nsILoadContext> loadContext;
GetCallback(loadContext);
if (loadContext) {
haveLoadContext = true;
loadContext->GetIsContent(&isContent);
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
loadContext->GetIsInBrowserElement(&isInBrowserElement);
loadContext->GetAppId(&appId);
}
//
// Send request to the chrome process...
//
@ -1040,8 +1056,9 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
IPC::InputStream(mUploadStream), mUploadStreamHasHeaders,
mPriority, mRedirectionLimit, mAllowPipelining,
mForceAllowThirdPartyCookie, mSendResumeAt,
mStartPos, mEntityID, mChooseApplicationCache,
appCacheClientId, mAllowSpdy, UsePrivateBrowsing());
mStartPos, mEntityID, mChooseApplicationCache,
appCacheClientId, mAllowSpdy, haveLoadContext, isContent,
usePrivateBrowsing, isInBrowserElement, appId);
return NS_OK;
}

Просмотреть файл

@ -35,6 +35,11 @@ HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding)
, mSentRedirect1Begin(false)
, mSentRedirect1BeginFailed(false)
, mReceivedRedirect2Verify(false)
, mHaveLoadContext(false)
, mIsContent(false)
, mUsePrivateBrowsing(false)
, mIsInBrowserElement(false)
, mAppId(0)
{
// Ensure gHttpHandler is initialized: we need the atom table up and running.
nsIHttpProtocolHandler* handler;
@ -62,7 +67,8 @@ HttpChannelParent::ActorDestroy(ActorDestroyReason why)
// HttpChannelParent::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_ISUPPORTS6(HttpChannelParent,
NS_IMPL_ISUPPORTS7(HttpChannelParent,
nsILoadContext,
nsIInterfaceRequestor,
nsIProgressEventSink,
nsIRequestObserver,
@ -85,6 +91,11 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
return mTabParent->QueryInterface(aIID, result);
}
// Only support nsILoadContext if child channel's callbacks did too
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
return NS_NOINTERFACE;
}
return QueryInterface(aIID, result);
}
@ -112,7 +123,11 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
const bool& chooseApplicationCache,
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& usingPrivateBrowsing)
const bool& haveLoadContext,
const bool& isContent,
const bool& usePrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId)
{
nsCOMPtr<nsIURI> uri(aURI);
nsCOMPtr<nsIURI> originalUri(aOriginalURI);
@ -134,6 +149,13 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
if (NS_FAILED(rv))
return SendFailedAsyncOpen(rv);
// fields needed to impersonate nsILoadContext
mHaveLoadContext = haveLoadContext;
mIsContent = isContent;
mUsePrivateBrowsing = usePrivateBrowsing;
mIsInBrowserElement = isInBrowserElement;
mAppId = appId;
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
if (doResumeAt)
@ -209,8 +231,6 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
}
}
httpChan->OverridePrivateBrowsing(usingPrivateBrowsing);
rv = httpChan->AsyncOpen(channelListener, nsnull);
if (NS_FAILED(rv))
return SendFailedAsyncOpen(rv);
@ -586,4 +606,72 @@ HttpChannelParent::CompleteRedirect(bool succeeded)
return NS_OK;
}
//-----------------------------------------------------------------------------
// HttpChannelParent::nsILoadContext
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpChannelParent::GetAssociatedWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
HttpChannelParent::GetTopWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
HttpChannelParent::IsAppOfType(PRUint32, bool*)
{
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
HttpChannelParent::GetIsContent(bool *aIsContent)
{
NS_ENSURE_ARG_POINTER(aIsContent);
*aIsContent = mIsContent;
return NS_OK;
}
NS_IMETHODIMP
HttpChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
{
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
*aUsePrivateBrowsing = mUsePrivateBrowsing;
return NS_OK;
}
NS_IMETHODIMP
HttpChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
// We shouldn't need this on parent...
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
HttpChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
{
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
*aIsInBrowserElement = mIsInBrowserElement;
return NS_OK;
}
NS_IMETHODIMP
HttpChannelParent::GetAppId(PRUint32* aAppId)
{
NS_ENSURE_ARG_POINTER(aAppId);
*aAppId = mAppId;
return NS_OK;
}
}} // mozilla::net

Просмотреть файл

@ -31,6 +31,7 @@ class HttpChannelParent : public PHttpChannelParent
, public nsIParentRedirectingChannel
, public nsIProgressEventSink
, public nsIInterfaceRequestor
, public nsILoadContext
{
public:
NS_DECL_ISUPPORTS
@ -40,6 +41,7 @@ public:
NS_DECL_NSIPARENTREDIRECTINGCHANNEL
NS_DECL_NSIPROGRESSEVENTSINK
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSILOADCONTEXT
HttpChannelParent(PBrowserParent* iframeEmbedding);
virtual ~HttpChannelParent();
@ -64,7 +66,11 @@ protected:
const bool& chooseApplicationCache,
const nsCString& appCacheClientID,
const bool& allowSpdy,
const bool& usingPrivateBrowsing);
const bool & haveLoadContext,
const bool & isContent,
const bool& usingPrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId);
virtual bool RecvConnectChannel(const PRUint32& channelId);
virtual bool RecvSetPriority(const PRUint16& priority);
@ -104,9 +110,17 @@ private:
PRUint64 mStoredProgress;
PRUint64 mStoredProgressMax;
bool mSentRedirect1Begin : 1;
bool mSentRedirect1BeginFailed : 1;
bool mReceivedRedirect2Verify : 1;
bool mSentRedirect1Begin : 1;
bool mSentRedirect1BeginFailed : 1;
bool mReceivedRedirect2Verify : 1;
// fields for impersonating nsILoadContext
bool mHaveLoadContext : 1;
bool mIsContent : 1;
bool mUsePrivateBrowsing : 1;
bool mIsInBrowserElement : 1;
PRUint32 mAppId;
};
} // namespace net

Просмотреть файл

@ -50,7 +50,13 @@ parent:
bool chooseApplicationCache,
nsCString appCacheClientID,
bool allowSpdy,
bool usePrivateBrowsing);
// If child channel callbacks implement nsILoadContext, we implement
// it in HttpChannelParent too
bool haveLoadContext,
bool isContent,
bool usePrivateBrowsing,
bool isInBrowserElement,
PRUint32 appID);
// Used to connect redirected-to channel on the parent with redirected-to
// channel on the child.

Просмотреть файл

@ -544,7 +544,7 @@ nsHttpChannel::SpeculativeConnect()
return;
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
mConnectionInfo->SetPrivate(UsingPrivateBrowsing());
mConnectionInfo->SetPrivate(mPrivateBrowsing);
gHttpHandler->SpeculativeConnect(mConnectionInfo,
callbacks, NS_GetCurrentThread());
}
@ -839,7 +839,7 @@ nsHttpChannel::SetupTransaction()
mCaps |= NS_HTTP_TIMING_ENABLED;
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
mConnectionInfo->SetPrivate(UsingPrivateBrowsing());
mConnectionInfo->SetPrivate(mPrivateBrowsing);
if (mUpgradeProtocolCallback) {
mRequestHead.SetHeader(nsHttp::Upgrade, mUpgradeProtocol, false);
@ -2447,7 +2447,7 @@ nsHttpChannel::OpenCacheEntry(bool usingSSL)
// us from writing to the offline cache as a normal cache entry.
mCacheQuery = new HttpCacheQuery(
this, appCacheClientID,
nsICache::STORE_OFFLINE, UsingPrivateBrowsing(),
nsICache::STORE_OFFLINE, mPrivateBrowsing,
cacheKey, nsICache::ACCESS_READ,
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
usingSSL, true);
@ -2548,10 +2548,9 @@ nsHttpChannel::OpenNormalCacheEntry(bool usingSSL)
nsresult rv;
bool isPrivate = UsingPrivateBrowsing();
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy(isPrivate);
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
nsDependentCString clientID(
GetCacheSessionNameForStoragePolicy(storagePolicy, isPrivate));
GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing));
nsCAutoString cacheKey;
GenerateCacheKey(mPostID, cacheKey);
@ -2563,8 +2562,7 @@ nsHttpChannel::OpenNormalCacheEntry(bool usingSSL)
mCacheQuery = new HttpCacheQuery(
this, clientID, storagePolicy,
UsingPrivateBrowsing(), cacheKey,
accessRequested,
mPrivateBrowsing, cacheKey, accessRequested,
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
usingSSL, false);
@ -5873,10 +5871,9 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
// one point by using only READ_ONLY access-policy. I think this is safe.
// First, find session holding the cache-entry - use current storage-policy
bool isPrivate = UsingPrivateBrowsing();
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy(isPrivate);
const char * clientID = GetCacheSessionNameForStoragePolicy(storagePolicy,
isPrivate);
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
const char * clientID =
GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing);
LOG(("DoInvalidateCacheEntry [channel=%p session=%s policy=%d key=%s]",
this, clientID, PRIntn(storagePolicy), key.get()));
@ -5891,7 +5888,7 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
getter_AddRefs(session));
}
if (NS_SUCCEEDED(rv)) {
rv = session->SetIsPrivate(UsingPrivateBrowsing());
rv = session->SetIsPrivate(mPrivateBrowsing);
}
if (NS_SUCCEEDED(rv)) {
rv = session->DoomEntry(key, nsnull);
@ -5902,10 +5899,10 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
}
nsCacheStoragePolicy
nsHttpChannel::DetermineStoragePolicy(bool isPrivate)
nsHttpChannel::DetermineStoragePolicy()
{
nsCacheStoragePolicy policy = nsICache::STORE_ANYWHERE;
if (isPrivate)
if (mPrivateBrowsing)
policy = nsICache::STORE_IN_MEMORY;
else if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
policy = nsICache::STORE_IN_MEMORY;

Просмотреть файл

@ -145,16 +145,6 @@ public: /* internal necko use only */
OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker();
/**
* Returns true if this channel is operating in private browsing mode,
* false otherwise.
*/
bool UsingPrivateBrowsing() {
bool usingPB;
GetUsingPrivateBrowsing(&usingPB);
return usingPB;
}
private:
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);
@ -235,7 +225,7 @@ private:
nsresult InstallCacheListener(PRUint32 offset = 0);
nsresult InstallOfflineCacheListener();
void MaybeInvalidateCacheEntryForSubsequentGet();
nsCacheStoragePolicy DetermineStoragePolicy(bool isPrivate);
nsCacheStoragePolicy DetermineStoragePolicy();
nsresult DetermineCacheAccess(nsCacheAccessMode *_retval);
void AsyncOnExamineCachedResponse();

Просмотреть файл

@ -22,7 +22,15 @@ async protocol PWebSocket
parent:
// Forwarded methods corresponding to methods on nsIWebSocketChannel
AsyncOpen(URI aURI, nsCString aOrigin, nsCString aProtocol, bool aSecure);
AsyncOpen(URI aURI,
nsCString aOrigin,
nsCString aProtocol,
bool aSecure,
bool haveLoadContext,
bool isContent,
bool usePrivateBrowsing,
bool isInBrowserElement,
PRUint32 appID);
Close(PRUint16 code, nsCString reason);
SendMsg(nsCString aMsg);
SendBinaryMsg(nsCString aMsg);

Просмотреть файл

@ -9,6 +9,8 @@
#include "mozilla/net/NeckoChild.h"
#include "WebSocketChannelChild.h"
#include "nsITabChild.h"
#include "nsILoadContext.h"
#include "nsNetUtil.h"
namespace mozilla {
namespace net {
@ -326,11 +328,31 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
}
// Get info from nsILoadContext, if any
bool haveLoadContext = false;
bool isContent = false;
bool usePrivateBrowsing = false;
bool isInBrowserElement = false;
PRUint32 appId = 0;
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
NS_GET_IID(nsILoadContext),
getter_AddRefs(loadContext));
if (loadContext) {
haveLoadContext = true;
loadContext->GetIsContent(&isContent);
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
loadContext->GetIsInBrowserElement(&isInBrowserElement);
loadContext->GetAppId(&appId);
}
// Corresponding release in DeallocPWebSocket
AddIPDLReference();
gNeckoChild->SendPWebSocketConstructor(this, tabChild);
if (!SendAsyncOpen(aURI, nsCString(aOrigin), mProtocol, mEncrypted))
if (!SendAsyncOpen(aURI, nsCString(aOrigin), mProtocol, mEncrypted,
haveLoadContext, isContent, usePrivateBrowsing,
isInBrowserElement, appId))
return NS_ERROR_UNEXPECTED;
mOriginalURI = aURI;

Просмотреть файл

@ -11,13 +11,19 @@
namespace mozilla {
namespace net {
NS_IMPL_THREADSAFE_ISUPPORTS2(WebSocketChannelParent,
NS_IMPL_THREADSAFE_ISUPPORTS3(WebSocketChannelParent,
nsIWebSocketListener,
nsILoadContext,
nsIInterfaceRequestor)
WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider)
: mAuthProvider(aAuthProvider)
, mIPCOpen(true)
, mHaveLoadContext(false)
, mIsContent(false)
, mUsePrivateBrowsing(false)
, mIsInBrowserElement(false)
, mAppId(0)
{
#if defined(PR_LOGGING)
if (!webSocketLog)
@ -25,6 +31,10 @@ WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvi
#endif
}
//-----------------------------------------------------------------------------
// WebSocketChannelParent::PWebSocketChannelParent
//-----------------------------------------------------------------------------
bool
WebSocketChannelParent::RecvDeleteSelf()
{
@ -38,7 +48,12 @@ bool
WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
const nsCString& aOrigin,
const nsCString& aProtocol,
const bool& aSecure)
const bool& aSecure,
const bool& haveLoadContext,
const bool& isContent,
const bool& usePrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId)
{
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
nsresult rv;
@ -52,6 +67,12 @@ WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
if (NS_FAILED(rv))
goto fail;
// fields needed to impersonate nsILoadContext
mHaveLoadContext = haveLoadContext;
mIsContent = isContent;
mUsePrivateBrowsing = usePrivateBrowsing;
mIsInBrowserElement = isInBrowserElement;
mAppId = appId;
rv = mChannel->SetNotificationCallbacks(this);
if (NS_FAILED(rv))
goto fail;
@ -116,16 +137,9 @@ WebSocketChannelParent::RecvSendBinaryStream(const InputStream& aStream,
return true;
}
NS_IMETHODIMP
WebSocketChannelParent::GetInterface(const nsIID & iid, void **result NS_OUTPARAM)
{
LOG(("WebSocketChannelParent::GetInterface() %p\n", this));
if (mAuthProvider && iid.Equals(NS_GET_IID(nsIAuthPromptProvider)))
return mAuthProvider->GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL,
iid, result);
return NS_ERROR_FAILURE;
}
//-----------------------------------------------------------------------------
// WebSocketChannelParent::nsIRequestObserver
//-----------------------------------------------------------------------------
NS_IMETHODIMP
WebSocketChannelParent::OnStart(nsISupports *aContext)
@ -200,5 +214,94 @@ WebSocketChannelParent::ActorDestroy(ActorDestroyReason why)
mIPCOpen = false;
}
//-----------------------------------------------------------------------------
// WebSocketChannelParent::nsIInterfaceRequestor
//-----------------------------------------------------------------------------
NS_IMETHODIMP
WebSocketChannelParent::GetInterface(const nsIID & iid, void **result NS_OUTPARAM)
{
LOG(("WebSocketChannelParent::GetInterface() %p\n", this));
if (mAuthProvider && iid.Equals(NS_GET_IID(nsIAuthPromptProvider)))
return mAuthProvider->GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL,
iid, result);
// Only support nsILoadContext if child channel's callbacks did too
if (iid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
return NS_NOINTERFACE;
}
return QueryInterface(iid, result);
}
//-----------------------------------------------------------------------------
// WebSocketChannelParent::nsILoadContext
//-----------------------------------------------------------------------------
NS_IMETHODIMP
WebSocketChannelParent::GetAssociatedWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WebSocketChannelParent::GetTopWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WebSocketChannelParent::IsAppOfType(PRUint32, bool*)
{
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WebSocketChannelParent::GetIsContent(bool *aIsContent)
{
NS_ENSURE_ARG_POINTER(aIsContent);
*aIsContent = mIsContent;
return NS_OK;
}
NS_IMETHODIMP
WebSocketChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
{
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
*aUsePrivateBrowsing = mUsePrivateBrowsing;
return NS_OK;
}
NS_IMETHODIMP
WebSocketChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
// We shouldn't need this on parent...
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WebSocketChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
{
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
*aIsInBrowserElement = mIsInBrowserElement;
return NS_OK;
}
NS_IMETHODIMP
WebSocketChannelParent::GetAppId(PRUint32* aAppId)
{
NS_ENSURE_ARG_POINTER(aAppId);
*aAppId = mAppId;
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/net/PWebSocketParent.h"
#include "nsIWebSocketListener.h"
#include "nsIWebSocketChannel.h"
#include "nsILoadContext.h"
#include "nsCOMPtr.h"
#include "nsString.h"
@ -20,12 +21,14 @@ namespace net {
class WebSocketChannelParent : public PWebSocketParent,
public nsIWebSocketListener,
public nsIInterfaceRequestor
public nsIInterfaceRequestor,
public nsILoadContext
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBSOCKETLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSILOADCONTEXT
WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider);
@ -33,7 +36,12 @@ class WebSocketChannelParent : public PWebSocketParent,
bool RecvAsyncOpen(const IPC::URI& aURI,
const nsCString& aOrigin,
const nsCString& aProtocol,
const bool& aSecure);
const bool& aSecure,
const bool& haveLoadContext,
const bool& isContent,
const bool& usingPrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId);
bool RecvClose(const PRUint16 & code, const nsCString & reason);
bool RecvSendMsg(const nsCString& aMsg);
bool RecvSendBinaryMsg(const nsCString& aMsg);
@ -46,6 +54,14 @@ class WebSocketChannelParent : public PWebSocketParent,
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
nsCOMPtr<nsIWebSocketChannel> mChannel;
bool mIPCOpen;
// fields for impersonating nsILoadContext
bool mHaveLoadContext : 1;
bool mIsContent : 1;
bool mUsePrivateBrowsing : 1;
bool mIsInBrowserElement : 1;
PRUint32 mAppId;
};
} // namespace net

Просмотреть файл

@ -22,7 +22,11 @@ parent:
Init(URI uri);
AsyncOpen(URI originalURI,
PRUint32 loadFlags,
bool usingPrivateBrowsing);
bool haveLoadContext,
bool isContent,
bool usePrivateBrowsing,
bool isInBrowserElement,
PRUint32 appID);
// methods corresponding to those of nsIWyciwygChannel
WriteToCacheEntry(nsString data);

Просмотреть файл

@ -13,6 +13,7 @@
#include "nsNetUtil.h"
#include "nsISerializable.h"
#include "nsSerializationHelper.h"
#include "nsILoadContext.h"
namespace mozilla {
namespace net {
@ -24,8 +25,7 @@ NS_IMPL_ISUPPORTS3(WyciwygChannelChild,
WyciwygChannelChild::WyciwygChannelChild()
: PrivateBrowsingConsumer(this)
, mStatus(NS_OK)
: mStatus(NS_OK)
, mIsPending(false)
, mCanceled(false)
, mLoadFlags(LOAD_NORMAL)
@ -562,7 +562,26 @@ WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aConte
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, UsePrivateBrowsing());
// Get info from nsILoadContext, if any
bool haveLoadContext = false;
bool isContent = false;
bool usePrivateBrowsing = false;
bool isInBrowserElement = false;
PRUint32 appId = 0;
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
NS_GET_IID(nsILoadContext),
getter_AddRefs(loadContext));
if (loadContext) {
haveLoadContext = true;
loadContext->GetIsContent(&isContent);
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
loadContext->GetIsInBrowserElement(&isInBrowserElement);
loadContext->GetAppId(&appId);
}
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, haveLoadContext, isContent,
usePrivateBrowsing, isInBrowserElement, appId);
mState = WCC_OPENED;

Просмотреть файл

@ -10,7 +10,6 @@
#include "nsIWyciwygChannel.h"
#include "nsIChannel.h"
#include "nsIProgressEventSink.h"
#include "PrivateBrowsingConsumer.h"
namespace mozilla {
namespace net {
@ -35,7 +34,6 @@ enum WyciwygChannelChildState {
// Header file contents
class WyciwygChannelChild : public PWyciwygChannelChild
, public nsIWyciwygChannel
, public PrivateBrowsingConsumer
{
public:
NS_DECL_ISUPPORTS

Просмотреть файл

@ -17,6 +17,11 @@ namespace net {
WyciwygChannelParent::WyciwygChannelParent()
: mIPCClosed(false)
, mHaveLoadContext(false)
, mIsContent(false)
, mUsePrivateBrowsing(false)
, mIsInBrowserElement(false)
, mAppId(0)
{
#if defined(PR_LOGGING)
if (!gWyciwygLog)
@ -40,8 +45,10 @@ WyciwygChannelParent::ActorDestroy(ActorDestroyReason why)
// WyciwygChannelParent::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_ISUPPORTS2(WyciwygChannelParent,
NS_IMPL_ISUPPORTS4(WyciwygChannelParent,
nsIStreamListener,
nsIInterfaceRequestor,
nsILoadContext,
nsIRequestObserver);
//-----------------------------------------------------------------------------
@ -79,7 +86,11 @@ WyciwygChannelParent::RecvInit(const IPC::URI& aURI)
bool
WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
const PRUint32& aLoadFlags,
const bool& aUsingPrivateBrowsing)
const bool& haveLoadContext,
const bool& isContent,
const bool& usePrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId)
{
nsCOMPtr<nsIURI> original(aOriginal);
@ -98,8 +109,13 @@ WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
if (NS_FAILED(rv))
return SendCancelEarly(rv);
static_cast<nsWyciwygChannel*>(mChannel.get())->
OverridePrivateBrowsing(aUsingPrivateBrowsing);
// fields needed to impersonate nsILoadContext
mHaveLoadContext = haveLoadContext;
mIsContent = isContent;
mUsePrivateBrowsing = usePrivateBrowsing;
mIsInBrowserElement = isInBrowserElement;
mAppId = appId;
mChannel->SetNotificationCallbacks(this);
rv = mChannel->AsyncOpen(this, nsnull);
if (NS_FAILED(rv))
@ -241,4 +257,87 @@ WyciwygChannelParent::OnDataAvailable(nsIRequest *aRequest,
return NS_OK;
}
//-----------------------------------------------------------------------------
// WyciwygChannelParent::nsIInterfaceRequestor
//-----------------------------------------------------------------------------
NS_IMETHODIMP
WyciwygChannelParent::GetInterface(const nsIID& uuid, void** result)
{
// Only support nsILoadContext if child channel's callbacks did too
if (uuid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
return NS_NOINTERFACE;
}
return QueryInterface(uuid, result);
}
//-----------------------------------------------------------------------------
// WyciwygChannelParent::nsILoadContext
//-----------------------------------------------------------------------------
NS_IMETHODIMP
WyciwygChannelParent::GetAssociatedWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WyciwygChannelParent::GetTopWindow(nsIDOMWindow**)
{
// can't support this in the parent process
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WyciwygChannelParent::IsAppOfType(PRUint32, bool*)
{
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WyciwygChannelParent::GetIsContent(bool *aIsContent)
{
NS_ENSURE_ARG_POINTER(aIsContent);
*aIsContent = mIsContent;
return NS_OK;
}
NS_IMETHODIMP
WyciwygChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
{
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
*aUsePrivateBrowsing = mUsePrivateBrowsing;
return NS_OK;
}
NS_IMETHODIMP
WyciwygChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
// We shouldn't need this on parent...
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
WyciwygChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
{
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
*aIsInBrowserElement = mIsInBrowserElement;
return NS_OK;
}
NS_IMETHODIMP
WyciwygChannelParent::GetAppId(PRUint32* aAppId)
{
NS_ENSURE_ARG_POINTER(aAppId);
*aAppId = mAppId;
return NS_OK;
}
}} // mozilla::net

Просмотреть файл

@ -10,17 +10,23 @@
#include "nsIStreamListener.h"
#include "nsIWyciwygChannel.h"
#include "nsIInterfaceRequestor.h"
#include "nsILoadContext.h"
namespace mozilla {
namespace net {
class WyciwygChannelParent : public PWyciwygChannelParent
, public nsIStreamListener
, public nsIInterfaceRequestor
, public nsILoadContext
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSILOADCONTEXT
WyciwygChannelParent();
virtual ~WyciwygChannelParent();
@ -29,7 +35,11 @@ protected:
virtual bool RecvInit(const IPC::URI& uri);
virtual bool RecvAsyncOpen(const IPC::URI& original,
const PRUint32& loadFlags,
const bool& usingPrivateBrowsing);
const bool& haveLoadContext,
const bool& isContent,
const bool& usingPrivateBrowsing,
const bool& isInBrowserElement,
const PRUint32& appId);
virtual bool RecvWriteToCacheEntry(const nsString& data);
virtual bool RecvCloseCacheEntry(const nsresult& reason);
virtual bool RecvSetCharsetAndSource(const PRInt32& source,
@ -41,6 +51,14 @@ protected:
nsCOMPtr<nsIWyciwygChannel> mChannel;
bool mIPCClosed;
// fields for impersonating nsILoadContext
bool mHaveLoadContext : 1;
bool mIsContent : 1;
bool mUsePrivateBrowsing : 1;
bool mIsInBrowserElement : 1;
PRUint32 mAppId;
};
} // namespace net

Просмотреть файл

@ -79,12 +79,11 @@ private:
// nsWyciwygChannel methods
nsWyciwygChannel::nsWyciwygChannel()
: PrivateBrowsingConsumer(this),
mStatus(NS_OK),
: mStatus(NS_OK),
mIsPending(false),
mCharsetAndSourceSet(false),
mNeedToWriteCharset(false),
mPrivate(false),
mPrivateBrowsing(false),
mCharsetSource(kCharsetUninitialized),
mContentLength(-1),
mLoadFlags(LOAD_NORMAL)
@ -272,6 +271,10 @@ nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationC
mLoadGroup,
NS_GET_IID(nsIProgressEventSink),
getter_AddRefs(mProgressSink));
// Will never change unless SetNotificationCallbacks called again, so cache
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
return NS_OK;
}
@ -396,9 +399,6 @@ nsWyciwygChannel::WriteToCacheEntry(const nsAString &aData)
if (NS_FAILED(rv))
return rv;
// UsePrivateBrowsing deals with non-threadsafe objects
mPrivate = UsePrivateBrowsing();
return mCacheIOTarget->Dispatch(new nsWyciwygWriteEvent(this, aData, spec),
NS_DISPATCH_NORMAL);
}
@ -668,20 +668,20 @@ nsWyciwygChannel::OpenCacheEntry(const nsACString & aCacheKey,
// honor security settings
nsCacheStoragePolicy storagePolicy;
if (mPrivate || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
if (mPrivateBrowsing || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
storagePolicy = nsICache::STORE_IN_MEMORY;
else
storagePolicy = nsICache::STORE_ANYWHERE;
nsCOMPtr<nsICacheSession> cacheSession;
// Open a stream based cache session.
const char* sessionName = mPrivate ? "wyciwyg-private" : "wyciwyg";
const char* sessionName = mPrivateBrowsing ? "wyciwyg-private" : "wyciwyg";
rv = cacheService->CreateSession(sessionName, storagePolicy, true,
getter_AddRefs(cacheSession));
if (!cacheSession)
return NS_ERROR_FAILURE;
cacheSession->SetIsPrivate(mPrivate);
cacheSession->SetIsPrivate(mPrivateBrowsing);
if (aAccessMode == nsICache::ACCESS_WRITE)
rv = cacheSession->OpenCacheEntry(aCacheKey, aAccessMode, false,

Просмотреть файл

@ -24,7 +24,8 @@
#include "nsICacheEntryDescriptor.h"
#include "nsIURI.h"
#include "nsIEventTarget.h"
#include "PrivateBrowsingConsumer.h"
#include "nsILoadContext.h"
#include "nsNetUtil.h"
extern PRLogModuleInfo * gWyciwygLog;
@ -32,8 +33,7 @@ extern PRLogModuleInfo * gWyciwygLog;
class nsWyciwygChannel: public nsIWyciwygChannel,
public nsIStreamListener,
public nsICacheListener,
public mozilla::net::PrivateBrowsingConsumer
public nsICacheListener
{
public:
NS_DECL_ISUPPORTS
@ -72,7 +72,7 @@ protected:
bool mIsPending;
bool mCharsetAndSourceSet;
bool mNeedToWriteCharset;
bool mPrivate;
bool mPrivateBrowsing;
PRInt32 mCharsetSource;
nsCString mCharset;
PRInt32 mContentLength;

Просмотреть файл

@ -11,20 +11,49 @@ var longexpPath = "/longexp" + suffix;
var nocachePath = "/nocache" + suffix;
var nostorePath = "/nostore" + suffix;
function make_channel(url, flags) {
// We attach this to channel when we want to test Private Browsing mode
function LoadContext(usePrivateBrowsing) {
this.usePrivateBrowsing = usePrivateBrowsing;
}
LoadContext.prototype = {
usePrivateBrowsing: false,
// don't bother defining rest of nsILoadContext fields: don't need 'em
QueryInterface: function(iid) {
if (iid.equals(Ci.nsILoadContext))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
getInterface: function(iid) {
if (iid.equals(Ci.nsILoadContext))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
};
PrivateBrowsingLoadContext = new LoadContext(true);
function make_channel(url, flags, usePrivateBrowsing) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var req = ios.newChannel(url, null, null);
req.loadFlags = flags;
if (usePrivateBrowsing) {
req.notificationCallbacks = PrivateBrowsingLoadContext;
}
return req;
}
function Test(path, flags, expectSuccess, readFromCache, hitServer) {
function Test(path, flags, expectSuccess, readFromCache, hitServer,
usePrivateBrowsing /* defaults to false */) {
this.path = path;
this.flags = flags;
this.expectSuccess = expectSuccess;
this.readFromCache = readFromCache;
this.hitServer = hitServer;
this.usePrivateBrowsing = usePrivateBrowsing;
}
Test.prototype = {
@ -32,6 +61,7 @@ Test.prototype = {
expectSuccess: true,
readFromCache: false,
hitServer: true,
usePrivateBrowsing: false,
_buffer: "",
_isFromCache: false,
@ -44,7 +74,7 @@ Test.prototype = {
},
onStartRequest: function(request, context) {
var cachingChannel = request.QueryInterface(Ci.nsICachingChannel);
var cachingChannel = request.QueryInterface(Ci.nsICacheInfoChannel);
this._isFromCache = request.isPending() && cachingChannel.isFromCache();
},
@ -68,7 +98,7 @@ Test.prototype = {
"\n " + this.readFromCache +
"\n " + this.hitServer + "\n");
gHitServer = false;
var channel = make_channel(this.path, this.flags);
var channel = make_channel(this.path, this.flags, this.usePrivateBrowsing);
channel.asyncOpen(this, null);
}
};
@ -76,6 +106,12 @@ Test.prototype = {
var gHitServer = false;
var gTests = [
new Test(httpBase + shortexpPath, 0,
true, // expect success
false, // read from cache
true, // hit server
true), // USE PRIVATE BROWSING, so not cached for later requests
new Test(httpBase + shortexpPath, 0,
true, // expect success
false, // read from cache

Просмотреть файл

@ -0,0 +1,7 @@
//
// Run test script in content process instead of chrome (xpcshell's default)
//
function run_test() {
run_test_in_child("../unit/test_cacheflags.js");
}

Просмотреть файл

@ -2,6 +2,7 @@
head = head_channels_clone.js
tail =
[test_cacheflags_wrap.js]
[test_channel_close_wrap.js]
[test_cookie_wrap.js]
[test_duplicate_headers_wrap.js]

Просмотреть файл

@ -106,7 +106,6 @@
#include "nsIDocShellTreeOwner.h"
#include "nsIDocShellTreeItem.h"
#include "ExternalHelperAppChild.h"
#include "nsIPrivateBrowsingConsumer.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
@ -2181,8 +2180,8 @@ nsresult nsExternalAppHandler::OpenWithApplication()
// See whether the channel has been opened in private browsing mode
NS_ASSERTION(mRequest, "This should never be called with a null request");
nsCOMPtr<nsIPrivateBrowsingConsumer> pbConsumer = do_QueryInterface(mRequest);
bool inPrivateBrowsing = pbConsumer && pbConsumer->UsePrivateBrowsing();
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
bool inPrivateBrowsing = channel && NS_UsePrivateBrowsing(channel);
// make the tmp file readonly so users won't edit it and lose the changes
// only if we're going to delete the file