Bug 722845 - Part 4: Add PB information to wyciwyg channels. r=jduell

This commit is contained in:
Josh Matthews 2012-05-24 16:31:54 +01:00
Родитель 59f6cd5233
Коммит aabb5e983a
11 изменённых файлов: 41 добавлений и 16 удалений

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

@ -53,7 +53,7 @@ class PrivateBrowsingConsumer : public nsIPrivateBrowsingConsumer
NS_IMETHOD GetUsingPrivateBrowsing(bool *aUsingPB)
{
*aUsingPB = (mOverride ? mUsingPB : UsingPrivateBrowsing());
*aUsingPB = (mOverride ? mUsingPB : UsingPrivateBrowsingInternal());
return NS_OK;
}
@ -66,7 +66,7 @@ class PrivateBrowsingConsumer : public nsIPrivateBrowsingConsumer
}
protected:
bool UsingPrivateBrowsing()
bool UsingPrivateBrowsingInternal()
{
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(mSelf, loadContext);

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

@ -161,7 +161,7 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
mLoadGroup->AddRequest(this, nsnull);
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID,
IPC::InputStream(mUploadStream), UsingPrivateBrowsing());
IPC::InputStream(mUploadStream), UsePrivateBrowsing());
// The socket transport layer in the chrome process now has a logical ref to
// us until OnStopRequest is called.

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

@ -2217,14 +2217,19 @@ nsFtpState::CheckCache()
if (!cache)
return false;
bool isPrivate = mChannel->UsePrivateBrowsing();
const char* sessionName = isPrivate ? "FTP-private" : "FTP";
nsCacheStoragePolicy policy =
isPrivate ? nsICache::STORE_IN_MEMORY : nsICache::STORE_ANYWHERE;
nsCOMPtr<nsICacheSession> session;
cache->CreateSession("FTP",
nsICache::STORE_ANYWHERE,
cache->CreateSession(sessionName,
policy,
nsICache::STREAM_BASED,
getter_AddRefs(session));
if (!session)
return false;
session->SetDoomEntriesIfExpired(false);
session->SetIsPrivate(isPrivate);
// Set cache access requested:
nsCacheAccessMode accessReq;

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

@ -1041,7 +1041,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
mPriority, mRedirectionLimit, mAllowPipelining,
mForceAllowThirdPartyCookie, mSendResumeAt,
mStartPos, mEntityID, mChooseApplicationCache,
appCacheClientId, mAllowSpdy, UsingPrivateBrowsing());
appCacheClientId, mAllowSpdy, UsePrivateBrowsing());
return NS_OK;
}

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

@ -21,7 +21,8 @@ parent:
Init(URI uri);
AsyncOpen(URI originalURI,
PRUint32 loadFlags);
PRUint32 loadFlags,
bool usingPrivateBrowsing);
// methods corresponding to those of nsIWyciwygChannel
WriteToCacheEntry(nsString data);

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

@ -24,7 +24,8 @@ NS_IMPL_ISUPPORTS3(WyciwygChannelChild,
WyciwygChannelChild::WyciwygChannelChild()
: mStatus(NS_OK)
: PrivateBrowsingConsumer(this)
, mStatus(NS_OK)
, mIsPending(false)
, mCanceled(false)
, mLoadFlags(LOAD_NORMAL)
@ -32,7 +33,7 @@ WyciwygChannelChild::WyciwygChannelChild()
, mCharsetSource(kCharsetUninitialized)
, mState(WCC_NEW)
, mIPCOpen(false)
, mEventQ(this)
, mEventQ(NS_ISUPPORTS_CAST(nsIWyciwygChannel*, this))
{
LOG(("Creating WyciwygChannelChild @%x\n", this));
}
@ -561,7 +562,7 @@ WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aConte
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags);
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, UsePrivateBrowsing());
mState = WCC_OPENED;

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

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

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

@ -78,7 +78,8 @@ WyciwygChannelParent::RecvInit(const IPC::URI& aURI)
bool
WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
const PRUint32& aLoadFlags)
const PRUint32& aLoadFlags,
const bool& aUsingPrivateBrowsing)
{
nsCOMPtr<nsIURI> original(aOriginal);
@ -97,6 +98,9 @@ WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
if (NS_FAILED(rv))
return SendCancelEarly(rv);
static_cast<nsWyciwygChannel*>(mChannel.get())->
OverridePrivateBrowsing(aUsingPrivateBrowsing);
rv = mChannel->AsyncOpen(this, nsnull);
if (NS_FAILED(rv))
return SendCancelEarly(rv);

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

@ -28,7 +28,8 @@ public:
protected:
virtual bool RecvInit(const IPC::URI& uri);
virtual bool RecvAsyncOpen(const IPC::URI& original,
const PRUint32& loadFlags);
const PRUint32& loadFlags,
const bool& usingPrivateBrowsing);
virtual bool RecvWriteToCacheEntry(const nsString& data);
virtual bool RecvCloseCacheEntry(const nsresult& reason);
virtual bool RecvSetCharsetAndSource(const PRInt32& source,

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

@ -81,10 +81,12 @@ private:
// nsWyciwygChannel methods
nsWyciwygChannel::nsWyciwygChannel()
: mStatus(NS_OK),
: PrivateBrowsingConsumer(this),
mStatus(NS_OK),
mIsPending(false),
mCharsetAndSourceSet(false),
mNeedToWriteCharset(false),
mPrivate(false),
mCharsetSource(kCharsetUninitialized),
mContentLength(-1),
mLoadFlags(LOAD_NORMAL)
@ -396,6 +398,9 @@ 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);
}
@ -665,18 +670,21 @@ nsWyciwygChannel::OpenCacheEntry(const nsACString & aCacheKey,
// honor security settings
nsCacheStoragePolicy storagePolicy;
if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
if (mPrivate || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
storagePolicy = nsICache::STORE_IN_MEMORY;
else
storagePolicy = nsICache::STORE_ANYWHERE;
nsCOMPtr<nsICacheSession> cacheSession;
// Open a stream based cache session.
rv = cacheService->CreateSession("wyciwyg", storagePolicy, true,
const char* sessionName = mPrivate ? "wyciwyg-private" : "wyciwyg";
rv = cacheService->CreateSession(sessionName, storagePolicy, true,
getter_AddRefs(cacheSession));
if (!cacheSession)
return NS_ERROR_FAILURE;
cacheSession->SetIsPrivate(mPrivate);
if (aAccessMode == nsICache::ACCESS_WRITE)
rv = cacheSession->OpenCacheEntry(aCacheKey, aAccessMode, false,
getter_AddRefs(mCacheEntry));

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

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