Backout 2838ba825479, 991404facac2, 7f6e22f10b99, 30a4e0cf7130, ad2c42efbe57, and 1f07f04ec01d (Bug 760067, Bug 767096, Bug 765158, Bug 729182) due to xpcshell orange.

This commit is contained in:
Ryan VanderMeulen 2012-07-10 19:21:54 -04:00
Родитель 6528e0253a
Коммит 13fc9bf9b8
21 изменённых файлов: 163 добавлений и 268 удалений

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

@ -78,7 +78,6 @@
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/VisualEventTracer.h"
// we want to explore making the document own the load group
// so we can associate the document URI with the load group.
@ -6237,8 +6236,6 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
if(!aChannel)
return NS_ERROR_NULL_POINTER;
MOZ_EVENT_TRACER_DONE(this, "Page load");
nsCOMPtr<nsIURI> url;
nsresult rv = aChannel->GetURI(getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
@ -8920,13 +8917,6 @@ nsDocShell::DoURILoad(nsIURI * aURI,
bool aBypassClassifier,
bool aForceAllowCookies)
{
#ifdef MOZ_VISUAL_EVENT_TRACER
nsCAutoString urlSpec;
aURI->GetAsciiSpec(urlSpec);
MOZ_EVENT_TRACER_NAME_OBJECT(this, urlSpec.BeginReading());
MOZ_EVENT_TRACER_EXEC(this, "Page load");
#endif
nsresult rv;
nsCOMPtr<nsIURILoader> uriLoader;

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

@ -79,7 +79,7 @@ interface nsIApplicationCacheNamespace : nsISupports
* loads. Inactive caches will be removed from the cache when they are
* no longer referenced.
*/
[scriptable, uuid(C3A17414-763B-4235-8BB7-B48324F95DF8)]
[scriptable, uuid(231e1e53-05c1-41b6-b9de-dbbcce9385c9)]
interface nsIApplicationCache : nsISupports
{
/**
@ -195,5 +195,5 @@ interface nsIApplicationCache : nsISupports
* If set, this offline cache is placed in a different directory
* than the current application profile.
*/
readonly attribute nsIFile profileDirectory;
readonly attribute nsIFile cacheDirectory;
};

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

@ -10,7 +10,7 @@
/**
* Interface implemented by channels that support application caches.
*/
[scriptable, uuid(6FA816B1-6D5F-4380-9704-054D0908CFA3)]
[scriptable, uuid(8d9024e6-ab01-442d-8119-2f55d55d91b0)]
interface nsIApplicationCacheChannel : nsIApplicationCacheContainer
{
/**
@ -49,10 +49,4 @@ interface nsIApplicationCacheChannel : nsIApplicationCacheContainer
* action handling in nsContentSink.
*/
void markOfflineCacheEntryAsForeign();
/**
* Set offline application cache object to instruct the channel
* to cache for offline use using this application cache.
*/
attribute nsIApplicationCache applicationCacheForWrite;
};

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

@ -17,7 +17,7 @@ interface nsIFile;
* 3) Support for uniquely identifying cached data in cases when the URL
* is insufficient (e.g., HTTP form submission).
*/
[scriptable, uuid(8456EBEE-7127-485b-9518-C2E328C09F5D)]
[scriptable, uuid(E2143B61-62FE-4da5-BE2E-E31981095889)]
interface nsICachingChannel : nsICacheInfoChannel
{
/**
@ -73,6 +73,26 @@ interface nsICachingChannel : nsICacheInfoChannel
*/
attribute boolean cacheAsFile;
/**
* Specifies whether or not the data should be placed in the offline cache,
* in addition to normal memory/disk caching. This may fail if the offline
* cache is not present. The value of this attribute should be set before
* opening the channel.
*/
attribute boolean cacheForOfflineUse;
/**
* The session into which to cache offline data. If not specified,
* data will be placed in "HTTP-offline"
*/
attribute ACString offlineCacheClientID;
/**
* Override base (profile) directory to work with when accessing the cache.
* When not specified, the current process' profile directory will be used.
*/
attribute nsIFile profileDirectory;
/**
* Get the "file" where the cached data can be found. This is valid for
* as long as a reference to the cache token is held. This may return

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

@ -34,8 +34,6 @@
#include "nsIProgrammingLanguage.h"
#include "nsIClassInfoImpl.h"
#include "mozilla/VisualEventTracer.h"
#if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
#include "nsNativeConnectionHelper.h"
#endif
@ -727,8 +725,6 @@ nsSocketTransport::Init(const char **types, PRUint32 typeCount,
const nsACString &host, PRUint16 port,
nsIProxyInfo *givenProxyInfo)
{
MOZ_EVENT_TRACER_NAME_OBJECT(this, host.BeginReading());
nsCOMPtr<nsProxyInfo> proxyInfo;
if (givenProxyInfo) {
proxyInfo = do_QueryInterface(givenProxyInfo);
@ -1159,7 +1155,6 @@ nsSocketTransport::InitiateSocket()
//
// Initiate the connect() to the host...
//
MOZ_EVENT_TRACER_EXEC(this, "TCP connect");
status = PR_Connect(fd, &mNetAddr, NS_SOCKET_CONNECT_TIMEOUT);
if (status == PR_SUCCESS) {
//
@ -1384,8 +1379,6 @@ nsSocketTransport::OnSocketConnected()
mFDconnected = true;
}
MOZ_EVENT_TRACER_DONE(this, "TCP connect");
SendStatus(STATUS_CONNECTED_TO);
}
@ -2008,7 +2001,6 @@ nsSocketTransport::OnLookupComplete(nsICancelable *request,
// flag host lookup complete for the benefit of the ResolveHost method.
mResolving = false;
MOZ_EVENT_TRACER_WAIT(this, "TCP connect");
nsresult rv = PostEvent(MSG_DNS_LOOKUP_COMPLETE, status, rec);
// if posting a message fails, then we should assume that the socket

15
netwerk/cache/nsCacheService.cpp поставляемый
Просмотреть файл

@ -1588,7 +1588,6 @@ nsCacheService::GetCustomOfflineDevice(nsIFile *aProfileDir,
rv = CreateCustomOfflineDevice(aProfileDir, aQuota, aDevice);
NS_ENSURE_SUCCESS(rv, rv);
(*aDevice)->SetAutoShutdown();
mCustomOfflineDevices.Put(profilePath, *aDevice);
}
@ -1677,20 +1676,6 @@ nsCacheService::CreateMemoryDevice()
return rv;
}
nsresult
nsCacheService::RemoveCustomOfflineDevice(nsOfflineCacheDevice *aDevice)
{
nsCOMPtr<nsIFile> profileDir = aDevice->BaseDirectory();
if (!profileDir)
return NS_ERROR_UNEXPECTED;
nsAutoString profilePath;
nsresult rv = profileDir->GetPath(profilePath);
NS_ENSURE_SUCCESS(rv, rv);
mCustomOfflineDevices.Remove(profilePath);
return NS_OK;
}
nsresult
nsCacheService::CreateRequest(nsCacheSession * session,

2
netwerk/cache/nsCacheService.h поставляемый
Просмотреть файл

@ -199,8 +199,6 @@ private:
nsOfflineCacheDevice **aDevice);
nsresult CreateMemoryDevice();
nsresult RemoveCustomOfflineDevice(nsOfflineCacheDevice *aDevice);
nsresult CreateRequest(nsCacheSession * session,
const nsACString & clientKey,
nsCacheAccessMode accessRequested,

34
netwerk/cache/nsDiskCacheDeviceSQL.cpp поставляемый
Просмотреть файл

@ -631,7 +631,7 @@ nsApplicationCache::GetClientID(nsACString &out)
}
NS_IMETHODIMP
nsApplicationCache::GetProfileDirectory(nsIFile **out)
nsApplicationCache::GetCacheDirectory(nsIFile **out)
{
if (mDevice->BaseDirectory())
NS_ADDREF(*out = mDevice->BaseDirectory());
@ -657,10 +657,6 @@ nsApplicationCache::Activate()
NS_ENSURE_TRUE(mDevice, NS_ERROR_NOT_AVAILABLE);
mDevice->ActivateCache(mGroup, mClientID);
if (mDevice->AutoShutdown(this))
mDevice = nsnull;
return NS_OK;
}
@ -677,12 +673,7 @@ nsApplicationCache::Discard()
mDevice->DeactivateGroup(mGroup);
}
nsresult rv = mDevice->EvictEntries(mClientID.get());
if (mDevice->AutoShutdown(this))
mDevice = nsnull;
return rv;
return mDevice->EvictEntries(mClientID.get());
}
NS_IMETHODIMP
@ -813,7 +804,6 @@ nsOfflineCacheDevice::nsOfflineCacheDevice()
: mDB(nsnull)
, mCacheCapacity(0)
, mDeltaCounter(0)
, mAutoShutdown(false)
{
}
@ -2402,23 +2392,3 @@ nsOfflineCacheDevice::SetCapacity(PRUint32 capacity)
{
mCacheCapacity = capacity * 1024;
}
bool
nsOfflineCacheDevice::AutoShutdown(nsIApplicationCache * aAppCache)
{
if (!mAutoShutdown)
return false;
mAutoShutdown = false;
Shutdown();
nsRefPtr<nsCacheService> cacheService = nsCacheService::GlobalInstance();
cacheService->RemoveCustomOfflineDevice(this);
nsCAutoString clientID;
aAppCache->GetClientID(clientID);
mCaches.Remove(clientID);
return true;
}

3
netwerk/cache/nsDiskCacheDeviceSQL.h поставляемый
Просмотреть файл

@ -167,8 +167,6 @@ public:
void SetCacheParentDirectory(nsIFile * parentDir);
void SetCapacity(PRUint32 capacity);
void SetAutoShutdown() { mAutoShutdown = true; }
bool AutoShutdown(nsIApplicationCache * aAppCache);
nsIFile * BaseDirectory() { return mBaseDirectory; }
nsIFile * CacheDirectory() { return mCacheDirectory; }
@ -259,7 +257,6 @@ private:
nsCOMPtr<nsIFile> mCacheDirectory;
PRUint32 mCacheCapacity; // in bytes
PRInt32 mDeltaCounter;
bool mAutoShutdown;
nsInterfaceHashtable<nsCStringHashKey, nsIWeakReference> mCaches;
nsClassHashtable<nsCStringHashKey, nsCString> mActiveCachesByGroup;

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

@ -29,7 +29,6 @@
#include "mozilla/FunctionTimer.h"
#include "mozilla/Attributes.h"
#include "mozilla/VisualEventTracer.h"
using namespace mozilla;
@ -279,8 +278,6 @@ nsDNSAsyncRequest::OnLookupComplete(nsHostResolver *resolver,
status = NS_ERROR_OUT_OF_MEMORY;
}
MOZ_EVENT_TRACER_DONE(this, "DNS");
mListener->OnLookupComplete(this, rec, status);
mListener = nsnull;
@ -608,9 +605,6 @@ nsDNSService::AsyncResolve(const nsACString &hostname,
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*result = req);
MOZ_EVENT_TRACER_NAME_OBJECT(req, hostname.BeginReading());
MOZ_EVENT_TRACER_WAIT(req, "DNS");
// addref for resolver; will be released when OnLookupComplete is called.
NS_ADDREF(req);
rv = res->ResolveHost(req->mHost.get(), flags, af, req);

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

@ -37,7 +37,6 @@
#include "mozilla/FunctionTimer.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Telemetry.h"
#include "mozilla/VisualEventTracer.h"
using namespace mozilla;
@ -181,8 +180,6 @@ nsHostRecord::Create(const nsHostKey *key, nsHostRecord **result)
void *place = ::operator new(size);
*result = new(place) nsHostRecord(key);
NS_ADDREF(*result);
MOZ_EVENT_TRACER_NAME_OBJECT(*result, key->host);
return NS_OK;
}
@ -715,8 +712,6 @@ nsHostResolver::ConditionallyCreateThread(nsHostRecord *rec)
nsresult
nsHostResolver::IssueLookup(nsHostRecord *rec)
{
MOZ_EVENT_TRACER_WAIT(rec, "nsHostResolver");
nsresult rv = NS_OK;
NS_ASSERTION(!rec->resolving, "record is already being resolved");
@ -894,8 +889,6 @@ nsHostResolver::OnLookupComplete(nsHostRecord *rec, nsresult status, PRAddrInfo
}
}
MOZ_EVENT_TRACER_DONE(rec, "nsHostResolver");
if (!PR_CLIST_IS_EMPTY(&cbs)) {
PRCList *node = cbs.next;
while (node != &cbs) {
@ -979,7 +972,6 @@ nsHostResolver::ThreadFunc(void *arg)
TimeStamp startTime = TimeStamp::Now();
MOZ_EVENT_TRACER_EXEC(rec, "nsHostResolver");
ai = PR_GetAddrInfoByName(rec->host, rec->af, flags);
#if defined(RES_RETRY_ON_FAILURE)
if (!ai && rs.Reset())

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

@ -1221,21 +1221,6 @@ HttpChannelChild::SetApplicationCache(nsIApplicationCache *aApplicationCache)
// HttpChannelChild::nsIApplicationCacheChannel
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpChannelChild::GetApplicationCacheForWrite(nsIApplicationCache **aApplicationCache)
{
*aApplicationCache = nsnull;
return NS_OK;
}
NS_IMETHODIMP
HttpChannelChild::SetApplicationCacheForWrite(nsIApplicationCache *aApplicationCache)
{
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
// Child channels are not intended to be used for cache writes
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
HttpChannelChild::GetLoadedFromApplicationCache(bool *aLoadedFromApplicationCache)
{

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

@ -34,7 +34,6 @@
#include "base/compiler_specific.h"
#include "NullHttpTransaction.h"
#include "mozilla/Attributes.h"
#include "mozilla/VisualEventTracer.h"
namespace mozilla { namespace net {
@ -180,14 +179,9 @@ AutoRedirectVetoNotifier::ReportRedirectResult(bool succeeded)
NS_QueryNotificationCallbacks(mChannel,
NS_GET_IID(nsIRedirectResultListener),
getter_AddRefs(vetoHook));
nsHttpChannel * channel = mChannel;
mChannel = nsnull;
if (vetoHook)
vetoHook->OnRedirectResult(succeeded);
MOZ_EVENT_TRACER_DONE(channel, "AsyncProcessRedirection");
}
class HttpCacheQuery : public nsRunnable, public nsICacheListener
@ -207,7 +201,7 @@ public:
, mHasQueryString(HasQueryString(channel->mRequestHead.Method(),
channel->mURI))
, mLoadFlags(channel->mLoadFlags)
, mCacheForOfflineUse(!!channel->mApplicationCacheForWrite)
, mCacheForOfflineUse(channel->mCacheForOfflineUse)
, mFallbackChannel(channel->mFallbackChannel)
, mClientID(clientID)
, mStoragePolicy(storagePolicy)
@ -316,6 +310,7 @@ nsHttpChannel::nsHttpChannel()
, mAuthRetryPending(false)
, mResuming(false)
, mInitedCacheEntry(false)
, mCacheForOfflineUse(false)
, mFallbackChannel(false)
, mCustomConditionalRequest(false)
, mFallingBack(false)
@ -341,12 +336,6 @@ nsHttpChannel::Init(nsIURI *uri,
PRUint8 caps,
nsProxyInfo *proxyInfo)
{
#ifdef MOZ_VISUAL_EVENT_TRACER
nsCAutoString url;
uri->GetAsciiSpec(url);
MOZ_EVENT_TRACER_NAME_OBJECT(this, url.BeginReading());
#endif
nsresult rv = HttpBaseChannel::Init(uri, caps, proxyInfo);
if (NS_FAILED(rv))
return rv;
@ -461,7 +450,7 @@ nsHttpChannel::Connect()
// if cacheForOfflineUse has been set, open up an offline cache
// entry to update
if (mApplicationCacheForWrite) {
if (mCacheForOfflineUse) {
rv = OpenOfflineCacheEntryForWriting();
if (NS_FAILED(rv)) return rv;
@ -1007,7 +996,7 @@ nsHttpChannel::CallOnStartRequest()
rv = InstallOfflineCacheListener();
if (NS_FAILED(rv)) return rv;
}
} else if (mApplicationCacheForWrite) {
} else if (mCacheForOfflineUse) {
LOG(("offline cache is up to date, not updating"));
CloseOfflineCacheEntry();
}
@ -1379,7 +1368,7 @@ nsHttpChannel::ContinueProcessResponse(nsresult rv)
InitCacheEntry();
CloseCacheEntry(false);
if (mApplicationCacheForWrite) {
if (mCacheForOfflineUse) {
// Store response in the offline cache
InitOfflineCacheEntry();
CloseOfflineCacheEntry();
@ -2280,7 +2269,8 @@ nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback)
mOfflineCacheAccess = 0;
}
mApplicationCacheForWrite = nsnull;
mCacheForOfflineUse = false;
mOfflineCacheClientID.Truncate();
mOfflineCacheEntry = 0;
mOfflineCacheAccess = 0;
@ -2379,8 +2369,6 @@ IsSubRangeRequest(nsHttpRequestHead &aRequestHead)
nsresult
nsHttpChannel::OpenCacheEntry(bool usingSSL)
{
MOZ_EVENT_TRACER_EXEC(this, "OpenCacheEntry");
nsresult rv;
NS_ASSERTION(!mOnCacheEntryAvailableCallback, "Unexpected state");
@ -2516,7 +2504,7 @@ nsHttpChannel::OnOfflineCacheEntryAvailable(nsICacheEntryDescriptor *aEntry,
if (NS_SUCCEEDED(aEntryStatus))
return NS_OK;
if (!mApplicationCacheForWrite && !mFallbackChannel) {
if (!mCacheForOfflineUse && !mFallbackChannel) {
nsCAutoString cacheKey;
GenerateCacheKey(mPostID, cacheKey);
@ -2653,14 +2641,7 @@ nsHttpChannel::OpenOfflineCacheEntryForWriting()
nsCAutoString cacheKey;
GenerateCacheKey(mPostID, cacheKey);
NS_ENSURE_TRUE(mApplicationCacheForWrite,
NS_ERROR_NOT_AVAILABLE);
nsCAutoString offlineCacheClientID;
rv = mApplicationCacheForWrite->GetClientID(offlineCacheClientID);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(!offlineCacheClientID.IsEmpty(),
NS_ENSURE_TRUE(!mOfflineCacheClientID.IsEmpty(),
NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsICacheSession> session;
@ -2668,19 +2649,14 @@ nsHttpChannel::OpenOfflineCacheEntryForWriting()
do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = serv->CreateSession(offlineCacheClientID.get(),
rv = serv->CreateSession(mOfflineCacheClientID.get(),
nsICache::STORE_OFFLINE,
nsICache::STREAM_BASED,
getter_AddRefs(session));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIFile> profileDirectory;
rv = mApplicationCacheForWrite->GetProfileDirectory(
getter_AddRefs(profileDirectory));
NS_ENSURE_SUCCESS(rv, rv);
if (profileDirectory) {
rv = session->SetProfileDirectory(profileDirectory);
if (mProfileDirectory) {
rv = session->SetProfileDirectory(mProfileDirectory);
if (NS_FAILED(rv)) return rv;
}
@ -3320,7 +3296,7 @@ HttpCacheQuery::MustValidateBasedOnQueryUrl() const
bool
nsHttpChannel::ShouldUpdateOfflineCacheEntry()
{
if (!mApplicationCacheForWrite || !mOfflineCacheEntry) {
if (!mCacheForOfflineUse || !mOfflineCacheEntry) {
return false;
}
@ -3511,7 +3487,7 @@ nsHttpChannel::ReadFromCache(bool alreadyMarkedValid)
}
if ((mLoadFlags & LOAD_ONLY_IF_MODIFIED) && !mCachedContentIsPartial) {
if (!mApplicationCacheForWrite) {
if (!mCacheForOfflineUse) {
LOG(("Skipping read from cache based on LOAD_ONLY_IF_MODIFIED "
"load flag\n"));
MOZ_ASSERT(!mCacheInputStream);
@ -3522,7 +3498,7 @@ nsHttpChannel::ReadFromCache(bool alreadyMarkedValid)
if (!ShouldUpdateOfflineCacheEntry()) {
LOG(("Skipping read from cache based on LOAD_ONLY_IF_MODIFIED "
"load flag (mApplicationCacheForWrite not null case)\n"));
"load flag (mCacheForOfflineUse case)\n"));
mCacheInputStream.CloseAndRelease();
// TODO: Bug 759040 - We should call HandleAsyncNotModified directly
// here, to avoid event dispatching latency.
@ -4013,12 +3989,11 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
cachingChannel->SetCacheKey(cacheKey);
}
}
}
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel = do_QueryInterface(newChannel);
if (appCacheChannel) {
// app cache for write
appCacheChannel->SetApplicationCacheForWrite(mApplicationCacheForWrite);
// cacheClientID, cacheForOfflineUse
cachingChannel->SetOfflineCacheClientID(mOfflineCacheClientID);
cachingChannel->SetCacheForOfflineUse(mCacheForOfflineUse);
cachingChannel->SetProfileDirectory(mProfileDirectory);
}
}
@ -4031,11 +4006,6 @@ nsHttpChannel::AsyncProcessRedirection(PRUint32 redirectType)
LOG(("nsHttpChannel::AsyncProcessRedirection [this=%p type=%u]\n",
this, redirectType));
// The channel is actually starting its operation now, at least because
// we want it to appear like being in the waiting phase until now.
MOZ_EVENT_TRACER_EXEC(this, "nsHttpChannel");
MOZ_EVENT_TRACER_EXEC(this, "AsyncProcessRedirection");
const char *location = mResponseHead->PeekHeader(nsHttp::Location);
// if a location header was not given, then we can't perform the redirect,
@ -4381,8 +4351,6 @@ nsHttpChannel::GetSecurityInfo(nsISupports **securityInfo)
NS_IMETHODIMP
nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
{
MOZ_EVENT_TRACER_WAIT(this, "nsHttpChannel");
LOG(("nsHttpChannel::AsyncOpen [this=%p]\n", this));
NS_ENSURE_ARG_POINTER(listener);
@ -5013,7 +4981,6 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st
if (mListener) {
LOG((" calling OnStopRequest\n"));
mListener->OnStopRequest(this, mListenerContext, status);
MOZ_EVENT_TRACER_DONE(this, "nsHttpChannel");
mListener = 0;
mListenerContext = 0;
}
@ -5110,8 +5077,6 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
// already streamed some data from another source (see, for example,
// OnDoneReadingPartialCacheEntry).
//
if (!mLogicalOffset)
MOZ_EVENT_TRACER_EXEC(this, "nsHttpChannel");
// report the current stream offset to our listener... if we've
// streamed more than PR_UINT32_MAX, then avoid overflowing the
@ -5414,6 +5379,62 @@ nsHttpChannel::SetCacheAsFile(bool value)
return mCacheEntry->SetStoragePolicy(policy);
}
NS_IMETHODIMP
nsHttpChannel::GetCacheForOfflineUse(bool *value)
{
*value = mCacheForOfflineUse;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetCacheForOfflineUse(bool value)
{
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
mCacheForOfflineUse = value;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetOfflineCacheClientID(nsACString &value)
{
value = mOfflineCacheClientID;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetOfflineCacheClientID(const nsACString &value)
{
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
mOfflineCacheClientID = value;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetProfileDirectory(nsIFile **_result)
{
NS_ENSURE_ARG(_result);
if (!mProfileDirectory)
return NS_ERROR_NOT_AVAILABLE;
NS_ADDREF(*_result = mProfileDirectory);
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetProfileDirectory(nsIFile *value)
{
mProfileDirectory = value;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetCacheFile(nsIFile **cacheFile)
{
@ -5449,10 +5470,6 @@ nsHttpChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry,
{
MOZ_ASSERT(NS_IsMainThread());
mozilla::eventtracer::AutoEventTracer profiler(this,
eventtracer::eNone, eventtracer::eDone,
"OpenCacheEntry");
nsresult rv;
LOG(("nsHttpChannel::OnCacheEntryAvailable [this=%p entry=%p "
@ -5528,9 +5545,9 @@ nsHttpChannel::OnCacheEntryAvailableInternal(nsICacheEntryDescriptor *entry,
// proceed without using the cache
}
// if app cache for write has been set, open up an offline cache entry
// if cacheForOfflineUse has been set, open up an offline cache entry
// to update
if (mApplicationCacheForWrite) {
if (mCacheForOfflineUse) {
rv = OpenOfflineCacheEntryForWriting();
if (mOnCacheEntryAvailableCallback) {
NS_ASSERTION(NS_SUCCEEDED(rv), "Unexpected state");
@ -5616,7 +5633,6 @@ nsHttpChannel::DoAuthRetry(nsAHttpConnection *conn)
//-----------------------------------------------------------------------------
// nsHttpChannel::nsIApplicationCacheChannel
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpChannel::GetApplicationCache(nsIApplicationCache **out)
{
@ -5633,22 +5649,6 @@ nsHttpChannel::SetApplicationCache(nsIApplicationCache *appCache)
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetApplicationCacheForWrite(nsIApplicationCache **out)
{
NS_IF_ADDREF(*out = mApplicationCacheForWrite);
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetApplicationCacheForWrite(nsIApplicationCache *appCache)
{
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
mApplicationCacheForWrite = appCache;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::GetLoadedFromApplicationCache(bool *aLoadedFromApplicationCache)
{
@ -5798,7 +5798,6 @@ nsHttpChannel::OnRedirectVerifyCallback(nsresult result)
// We are not waiting for the callback. At this moment we must release
// reference to the redirect target channel, otherwise we may leak.
mRedirectChannel = nsnull;
MOZ_EVENT_TRACER_DONE(this, "nsHttpChannel");
}
// We always resume the pumps here. If all functions on stack have been

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

@ -310,7 +310,9 @@ private:
nsCOMPtr<nsICacheEntryDescriptor> mOfflineCacheEntry;
nsCacheAccessMode mOfflineCacheAccess;
PRUint32 mOfflineCacheLastModifiedTime;
nsCOMPtr<nsIApplicationCache> mApplicationCacheForWrite;
nsCString mOfflineCacheClientID;
nsCOMPtr<nsIFile> mProfileDirectory;
// auth specific data
nsCOMPtr<nsIHttpChannelAuthProvider> mAuthProvider;
@ -338,6 +340,7 @@ private:
PRUint32 mAuthRetryPending : 1;
PRUint32 mResuming : 1;
PRUint32 mInitedCacheEntry : 1;
PRUint32 mCacheForOfflineUse : 1;
// True if we are loading a fallback cache entry from the
// application cache.
PRUint32 mFallbackChannel : 1;

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

@ -19,7 +19,6 @@
#include "nsISSLSocketControl.h"
#include "prnetdb.h"
#include "mozilla/Telemetry.h"
#include "mozilla/VisualEventTracer.h"
using namespace mozilla;
using namespace mozilla::net;

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

@ -29,7 +29,6 @@
#include "nsIHttpActivityObserver.h"
#include "mozilla/FunctionTimer.h"
#include "mozilla/VisualEventTracer.h"
using namespace mozilla;
@ -171,13 +170,6 @@ nsHttpTransaction::Init(PRUint8 caps,
nsITransportEventSink *eventsink,
nsIAsyncInputStream **responseBody)
{
MOZ_EVENT_TRACER_COMPOUND_NAME(static_cast<nsAHttpTransaction*>(this),
requestHead->PeekHeader(nsHttp::Host),
requestHead->RequestURI().BeginReading());
MOZ_EVENT_TRACER_WAIT(static_cast<nsAHttpTransaction*>(this),
"nsHttpTransaction");
NS_TIME_FUNCTION;
nsresult rv;
@ -393,11 +385,6 @@ nsHttpTransaction::SetConnection(nsAHttpConnection *conn)
{
NS_IF_RELEASE(mConnection);
NS_IF_ADDREF(mConnection = conn);
if (conn) {
MOZ_EVENT_TRACER_EXEC(static_cast<nsAHttpTransaction*>(this),
"nsHttpTransaction");
}
}
void
@ -529,12 +516,6 @@ nsHttpTransaction::ReadRequestSegment(nsIInputStream *stream,
// First data we're sending -> this is requestStart
trans->mTimings.requestStart = mozilla::TimeStamp::Now();
}
if (!trans->mSentData) {
MOZ_EVENT_TRACER_MARK(static_cast<nsAHttpTransaction*>(trans),
"First write");
}
trans->mSentData = true;
return NS_OK;
}
@ -605,11 +586,6 @@ nsHttpTransaction::WritePipeSegment(nsIOutputStream *stream,
rv = trans->mWriter->OnWriteSegment(buf, count, countWritten);
if (NS_FAILED(rv)) return rv; // caller didn't want to write anything
if (!trans->mReceivedData) {
MOZ_EVENT_TRACER_MARK(static_cast<nsAHttpTransaction*>(trans),
"First read");
}
NS_ASSERTION(*countWritten > 0, "bad writer");
trans->mReceivedData = true;
@ -808,9 +784,6 @@ nsHttpTransaction::Close(nsresult reason)
// closing this pipe triggers the channel's OnStopRequest method.
mPipeOut->CloseWithStatus(reason);
MOZ_EVENT_TRACER_DONE(static_cast<nsAHttpTransaction*>(this),
"nsHttpTransaction");
}
nsresult

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

@ -64,22 +64,6 @@ function finish_test(customDir)
file2.append("0B457F75198B29-0");
do_check_eq(file2.exists(), true);
// This must not throw an exception. After the update has finished
// the index file can be freely removed. This way we check this process
// is no longer keeping the file open. Check like this will probably
// work only Windows systems.
// This test could potentially randomaly fail when we start closing
// the offline cache database off the main thread. Tries in a loop
// may be a solution then.
try {
indexSqlFile.remove(false);
do_check_true(true);
}
catch (ex) {
do_throw("Could not remove the sqlite.index file, we still keep it open \n" + ex + "\n");
}
httpServer.stop(do_test_finished);
}

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

@ -290,11 +290,13 @@ nsOfflineCacheUpdateItem::nsOfflineCacheUpdateItem(nsIURI *aURI,
nsIURI *aReferrerURI,
nsIApplicationCache *aApplicationCache,
nsIApplicationCache *aPreviousApplicationCache,
const nsACString &aClientID,
PRUint32 type)
: mURI(aURI)
, mReferrerURI(aReferrerURI)
, mApplicationCache(aApplicationCache)
, mPreviousApplicationCache(aPreviousApplicationCache)
, mClientID(aClientID)
, mItemType(type)
, mChannel(nsnull)
, mState(nsIDOMLoadStatus::UNINITIALIZED)
@ -338,10 +340,6 @@ nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate *aUpdate)
rv = appCacheChannel->SetApplicationCache(mPreviousApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
// Set the new application cache as the targer for write.
rv = appCacheChannel->SetApplicationCacheForWrite(mApplicationCache);
NS_ENSURE_SUCCESS(rv, rv);
// configure HTTP specific stuff
nsCOMPtr<nsIHttpChannel> httpChannel =
do_QueryInterface(mChannel);
@ -352,6 +350,25 @@ nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate *aUpdate)
false);
}
nsCOMPtr<nsICachingChannel> cachingChannel =
do_QueryInterface(mChannel);
if (cachingChannel) {
rv = cachingChannel->SetCacheForOfflineUse(true);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> cacheDirectory;
rv = mApplicationCache->GetCacheDirectory(getter_AddRefs(cacheDirectory));
NS_ENSURE_SUCCESS(rv, rv);
rv = cachingChannel->SetProfileDirectory(cacheDirectory);
NS_ENSURE_SUCCESS(rv, rv);
if (!mClientID.IsEmpty()) {
rv = cachingChannel->SetOfflineCacheClientID(mClientID);
NS_ENSURE_SUCCESS(rv, rv);
}
}
rv = mChannel->AsyncOpen(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
@ -488,10 +505,22 @@ nsOfflineCacheUpdateItem::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
nsCOMPtr<nsICachingChannel> newCachingChannel =
do_QueryInterface(aNewChannel);
if (appCacheChannel) {
rv = appCacheChannel->SetApplicationCacheForWrite(mApplicationCache);
if (newCachingChannel) {
rv = newCachingChannel->SetCacheForOfflineUse(true);
NS_ENSURE_SUCCESS(rv, rv);
if (!mClientID.IsEmpty()) {
rv = newCachingChannel->SetOfflineCacheClientID(mClientID);
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIFile> cacheDirectory;
rv = mApplicationCache->GetCacheDirectory(getter_AddRefs(cacheDirectory));
NS_ENSURE_SUCCESS(rv, rv);
rv = newCachingChannel->SetProfileDirectory(cacheDirectory);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -655,9 +684,10 @@ nsOfflineCacheUpdateItem::GetStatus(PRUint16 *aStatus)
nsOfflineManifestItem::nsOfflineManifestItem(nsIURI *aURI,
nsIURI *aReferrerURI,
nsIApplicationCache *aApplicationCache,
nsIApplicationCache *aPreviousApplicationCache)
nsIApplicationCache *aPreviousApplicationCache,
const nsACString &aClientID)
: nsOfflineCacheUpdateItem(aURI, aReferrerURI,
aApplicationCache, aPreviousApplicationCache,
aApplicationCache, aPreviousApplicationCache, aClientID,
nsIApplicationCache::ITEM_MANIFEST)
, mParserState(PARSE_INIT)
, mNeedsUpdate(true)
@ -1234,6 +1264,9 @@ nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
NS_ENSURE_SUCCESS(rv, rv);
}
rv = mApplicationCache->GetClientID(mClientID);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsOfflineCacheUpdateService::OfflineAppPinnedForURI(aDocumentURI,
NULL,
&mPinned);
@ -1259,6 +1292,7 @@ nsOfflineCacheUpdate::InitPartial(nsIURI *aManifestURI,
LOG(("nsOfflineCacheUpdate::InitPartial [%p]", this));
mPartialUpdate = true;
mClientID = clientID;
mDocumentURI = aDocumentURI;
mManifestURI = aManifestURI;
@ -1269,7 +1303,7 @@ nsOfflineCacheUpdate::InitPartial(nsIURI *aManifestURI,
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = cacheService->GetApplicationCache(clientID,
rv = cacheService->GetApplicationCache(mClientID,
getter_AddRefs(mApplicationCache));
NS_ENSURE_SUCCESS(rv, rv);
@ -1596,7 +1630,8 @@ nsOfflineCacheUpdate::Begin()
mManifestItem = new nsOfflineManifestItem(mManifestURI,
mDocumentURI,
mApplicationCache,
mPreviousApplicationCache);
mPreviousApplicationCache,
mClientID);
if (!mManifestItem) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -1864,12 +1899,8 @@ nsOfflineCacheUpdate::ScheduleImplicit()
rv = mPreviousApplicationCache->GetClientID(clientID);
NS_ENSURE_SUCCESS(rv, rv);
}
else if (mApplicationCache) {
rv = mApplicationCache->GetClientID(clientID);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
NS_ERROR("Offline cache update not having set mApplicationCache?");
clientID = mClientID;
}
rv = update->InitPartial(mManifestURI, clientID, mDocumentURI);
@ -2107,6 +2138,7 @@ nsOfflineCacheUpdate::AddURI(nsIURI *aURI, PRUint32 aType)
mDocumentURI,
mApplicationCache,
mPreviousApplicationCache,
mClientID,
aType);
if (!item) return NS_ERROR_OUT_OF_MEMORY;

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

@ -57,6 +57,7 @@ public:
nsIURI *aReferrerURI,
nsIApplicationCache *aApplicationCache,
nsIApplicationCache *aPreviousApplicationCache,
const nsACString &aClientID,
PRUint32 aType);
virtual ~nsOfflineCacheUpdateItem();
@ -64,6 +65,7 @@ public:
nsCOMPtr<nsIURI> mReferrerURI;
nsCOMPtr<nsIApplicationCache> mApplicationCache;
nsCOMPtr<nsIApplicationCache> mPreviousApplicationCache;
nsCString mClientID;
nsCString mCacheKey;
PRUint32 mItemType;
@ -94,7 +96,8 @@ public:
nsOfflineManifestItem(nsIURI *aURI,
nsIURI *aReferrerURI,
nsIApplicationCache *aApplicationCache,
nsIApplicationCache *aPreviousApplicationCache);
nsIApplicationCache *aPreviousApplicationCache,
const nsACString &aClientID);
virtual ~nsOfflineManifestItem();
nsCOMArray<nsIURI> &GetExplicitURIs() { return mExplicitURIs; }

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

@ -10,8 +10,7 @@
#include "prprf.h"
#include "prio.h"
#include "prenv.h"
#include "plstr.h"
#include "nsThreadUtils.h"
#include "plstr.h"
namespace mozilla { namespace eventtracer {
@ -55,22 +54,6 @@ public:
char * mText2;
};
char * DupCurrentThreadName()
{
if (NS_IsMainThread())
return PL_strdup("Main Thread");
PRThread * currentThread = PR_GetCurrentThread();
const char * name = PR_GetThreadName(currentThread);
if (name)
return PL_strdup(name);
char buffer[128];
PR_snprintf(buffer, 127, "Nameless %p", currentThread);
return PL_strdup(buffer);
}
// An array of events, each thread keeps its own private instance
class RecordBatch {
public:
@ -79,7 +62,7 @@ public:
, mRecordsTail(mRecordsHead + kBatchSize)
, mNextRecord(mRecordsHead)
, mNextBatch(nsnull)
, mThreadNameCopy(DupCurrentThreadName())
, mThreadNameCopy(PL_strdup(PR_GetThreadName(PR_GetCurrentThread())))
{
MOZ_COUNT_CTOR(RecordBatch);
}

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

@ -315,6 +315,8 @@ NS_InitXPCOM2(nsIServiceManager* *result,
{
NS_TIME_FUNCTION;
PR_SetCurrentThreadName("Main Thread");
nsresult rv = NS_OK;
// We are not shutting down