2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-11-13 17:02:03 +03:00
|
|
|
/* vim: set sw=4 ts=4 sts=4 et cin: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-06-25 02:58:42 +04:00
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
1999-06-25 02:58:42 +04:00
|
|
|
#include "nsLoadGroup.h"
|
2012-12-09 14:04:21 +04:00
|
|
|
|
|
|
|
#include "nsArrayEnumerator.h"
|
|
|
|
#include "nsCOMArray.h"
|
1999-07-10 01:18:47 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2000-08-21 12:23:54 +04:00
|
|
|
#include "nsString.h"
|
2009-02-23 04:05:28 +03:00
|
|
|
#include "nsTArray.h"
|
2011-07-02 00:22:18 +04:00
|
|
|
#include "mozilla/Telemetry.h"
|
2013-09-22 07:04:57 +04:00
|
|
|
#include "nsITimedChannel.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
|
|
|
#include "nsIRequestObserver.h"
|
2016-04-21 17:59:17 +03:00
|
|
|
#include "nsIRequestContext.h"
|
2013-09-26 23:37:04 +04:00
|
|
|
#include "CacheObserver.h"
|
2013-10-17 21:21:32 +04:00
|
|
|
#include "MainThreadUtils.h"
|
2017-03-15 07:10:10 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2011-07-02 00:22:18 +04:00
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
1999-06-25 02:58:42 +04:00
|
|
|
|
1999-07-27 12:45:35 +04:00
|
|
|
//
|
|
|
|
// Log module for nsILoadGroup logging...
|
|
|
|
//
|
|
|
|
// To enable logging (see prlog.h for full details):
|
|
|
|
//
|
2016-05-26 02:13:54 +03:00
|
|
|
// set MOZ_LOG=LoadGroup:5
|
|
|
|
// set MOZ_LOG_FILE=network.log
|
1999-07-27 12:45:35 +04:00
|
|
|
//
|
2016-05-26 02:13:54 +03:00
|
|
|
// This enables LogLevel::Debug level information and places all output in
|
|
|
|
// the file network.log.
|
1999-07-27 12:45:35 +04:00
|
|
|
//
|
2015-11-03 07:35:29 +03:00
|
|
|
static LazyLogModule gLoadGroupLog("LoadGroup");
|
2013-11-21 02:55:44 +04:00
|
|
|
#undef LOG
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOG(args) MOZ_LOG(gLoadGroupLog, mozilla::LogLevel::Debug, args)
|
1999-07-27 12:45:35 +04:00
|
|
|
|
1999-07-10 01:18:47 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
class RequestMapEntry : public PLDHashEntryHdr
|
|
|
|
{
|
|
|
|
public:
|
2014-08-05 17:20:24 +04:00
|
|
|
explicit RequestMapEntry(nsIRequest *aRequest) :
|
2002-07-09 05:03:45 +04:00
|
|
|
mKey(aRequest)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRequest> mKey;
|
|
|
|
};
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2016-03-16 07:33:44 +03:00
|
|
|
RequestHashMatchEntry(const PLDHashEntryHdr *entry, const void *key)
|
2002-07-09 05:03:45 +04:00
|
|
|
{
|
|
|
|
const RequestMapEntry *e =
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<const RequestMapEntry *>(entry);
|
|
|
|
const nsIRequest *request = static_cast<const nsIRequest *>(key);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
return e->mKey == request;
|
|
|
|
}
|
|
|
|
|
2008-10-10 19:04:34 +04:00
|
|
|
static void
|
2002-07-09 05:03:45 +04:00
|
|
|
RequestHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
RequestMapEntry *e = static_cast<RequestMapEntry *>(entry);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
// An entry is being cleared, let the entry do its own cleanup.
|
|
|
|
e->~RequestMapEntry();
|
|
|
|
}
|
|
|
|
|
2015-02-11 20:46:40 +03:00
|
|
|
static void
|
|
|
|
RequestHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
2002-07-09 05:03:45 +04:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
const nsIRequest *const_request = static_cast<const nsIRequest *>(key);
|
|
|
|
nsIRequest *request = const_cast<nsIRequest *>(const_request);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
// Initialize the entry with placement new
|
|
|
|
new (entry) RequestMapEntry(request);
|
|
|
|
}
|
|
|
|
|
2015-05-13 03:33:44 +03:00
|
|
|
static const PLDHashTableOps sRequestHashOps =
|
|
|
|
{
|
2015-09-15 00:23:47 +03:00
|
|
|
PLDHashTable::HashVoidPtrKeyStub,
|
2015-05-13 03:33:44 +03:00
|
|
|
RequestHashMatchEntry,
|
2015-09-15 00:23:47 +03:00
|
|
|
PLDHashTable::MoveEntryStub,
|
2015-05-13 03:33:44 +03:00
|
|
|
RequestHashClearEntry,
|
|
|
|
RequestHashInitEntry
|
|
|
|
};
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2005-02-21 23:58:01 +03:00
|
|
|
static void
|
2012-08-22 19:56:38 +04:00
|
|
|
RescheduleRequest(nsIRequest *aRequest, int32_t delta)
|
2005-02-21 23:58:01 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(aRequest);
|
|
|
|
if (p)
|
2005-02-22 01:21:21 +03:00
|
|
|
p->AdjustPriority(delta);
|
2005-02-21 23:58:01 +03:00
|
|
|
}
|
|
|
|
|
1999-06-25 02:58:42 +04:00
|
|
|
nsLoadGroup::nsLoadGroup(nsISupports* outer)
|
2001-04-14 06:02:19 +04:00
|
|
|
: mForegroundCount(0)
|
|
|
|
, mLoadFlags(LOAD_NORMAL)
|
2013-09-06 10:33:29 +04:00
|
|
|
, mDefaultLoadFlags(0)
|
2015-05-13 03:33:44 +03:00
|
|
|
, mRequests(&sRequestHashOps, sizeof(RequestMapEntry))
|
2001-04-10 10:01:08 +04:00
|
|
|
, mStatus(NS_OK)
|
2005-02-27 18:19:05 +03:00
|
|
|
, mPriority(PRIORITY_NORMAL)
|
2011-10-17 18:59:28 +04:00
|
|
|
, mIsCanceling(false)
|
2011-07-02 00:22:18 +04:00
|
|
|
, mDefaultLoadIsTimed(false)
|
|
|
|
, mTimedRequests(0)
|
|
|
|
, mCachedRequests(0)
|
2013-04-15 17:41:27 +04:00
|
|
|
, mTimedNonCachedRequestsUntilOnEndPageLoad(0)
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
|
|
|
NS_INIT_AGGREGATED(outer);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Created.\n", this));
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLoadGroup::~nsLoadGroup()
|
|
|
|
{
|
2012-10-25 23:47:55 +04:00
|
|
|
DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED);
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2016-11-10 06:11:27 +03:00
|
|
|
mDefaultLoadRequest = nullptr;
|
1999-07-31 10:28:31 +04:00
|
|
|
|
2016-04-21 17:59:17 +03:00
|
|
|
if (mRequestContext) {
|
2017-03-23 17:40:36 +03:00
|
|
|
uint64_t rcid;
|
2016-04-21 17:59:17 +03:00
|
|
|
mRequestContext->GetID(&rcid);
|
2017-08-30 16:32:00 +03:00
|
|
|
mRequestContextService->RemoveRequestContext(rcid);
|
2015-07-31 23:50:08 +03:00
|
|
|
}
|
|
|
|
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Destroyed.\n", this));
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports methods:
|
1999-08-27 02:45:55 +04:00
|
|
|
|
2003-09-08 03:12:15 +04:00
|
|
|
NS_IMPL_AGGREGATED(nsLoadGroup)
|
2005-09-28 17:13:27 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_AGGREGATED(nsLoadGroup)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsILoadGroup)
|
2013-04-15 17:41:27 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsPILoadGroupInternal)
|
2013-04-09 21:38:48 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsILoadGroupChild)
|
2005-09-28 17:13:27 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRequest)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
|
|
|
NS_INTERFACE_MAP_END
|
1999-06-25 02:58:42 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIRequest methods:
|
|
|
|
|
2000-08-21 12:23:54 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-21 01:50:33 +03:00
|
|
|
nsLoadGroup::GetName(nsACString &result)
|
2000-08-21 12:23:54 +04:00
|
|
|
{
|
|
|
|
// XXX is this the right "name" for a load group?
|
2001-10-11 05:09:18 +04:00
|
|
|
|
|
|
|
if (!mDefaultLoadRequest) {
|
2002-03-21 01:50:33 +03:00
|
|
|
result.Truncate();
|
2001-10-11 05:09:18 +04:00
|
|
|
return NS_OK;
|
2000-08-21 12:23:54 +04:00
|
|
|
}
|
2016-02-10 00:33:34 +03:00
|
|
|
|
2001-10-11 05:09:18 +04:00
|
|
|
return mDefaultLoadRequest->GetName(result);
|
2000-08-21 12:23:54 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsLoadGroup::IsPending(bool *aResult)
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
*aResult = (mForegroundCount > 0) ? true : false;
|
1999-11-22 08:46:03 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-29 07:58:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetStatus(nsresult *status)
|
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
if (NS_SUCCEEDED(mStatus) && mDefaultLoadRequest)
|
|
|
|
return mDefaultLoadRequest->GetStatus(status);
|
2016-02-10 00:33:34 +03:00
|
|
|
|
2000-10-26 10:34:20 +04:00
|
|
|
*status = mStatus;
|
2016-02-10 00:33:34 +03:00
|
|
|
return NS_OK;
|
2000-03-29 07:58:50 +04:00
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2015-06-10 23:07:40 +03:00
|
|
|
static bool
|
|
|
|
AppendRequestsToArray(PLDHashTable* aTable, nsTArray<nsIRequest*> *aArray)
|
2002-07-09 05:03:45 +04:00
|
|
|
{
|
2015-06-12 07:19:53 +03:00
|
|
|
for (auto iter = aTable->Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
auto e = static_cast<RequestMapEntry*>(iter.Get());
|
2015-06-10 23:07:40 +03:00
|
|
|
nsIRequest *request = e->mKey;
|
2015-09-16 06:49:53 +03:00
|
|
|
NS_ASSERTION(request, "What? Null key in PLDHashTable entry?");
|
2015-06-10 23:07:40 +03:00
|
|
|
|
|
|
|
bool ok = !!aArray->AppendElement(request);
|
|
|
|
if (!ok) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
NS_ADDREF(request);
|
2002-07-09 05:03:45 +04:00
|
|
|
}
|
|
|
|
|
2015-06-10 23:07:40 +03:00
|
|
|
if (aArray->Length() != aTable->EntryCount()) {
|
|
|
|
for (uint32_t i = 0, len = aArray->Length(); i < len; ++i) {
|
|
|
|
NS_RELEASE((*aArray)[i]);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2002-07-09 05:03:45 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
NS_IMETHODIMP
|
2000-03-29 07:58:50 +04:00
|
|
|
nsLoadGroup::Cancel(nsresult status)
|
1999-11-22 08:46:03 +03:00
|
|
|
{
|
2013-10-17 21:21:32 +04:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2000-04-12 11:58:24 +04:00
|
|
|
NS_ASSERTION(NS_FAILED(status), "shouldn't cancel with a success code");
|
2004-11-13 17:02:03 +03:00
|
|
|
nsresult rv;
|
2014-08-26 03:56:33 +04:00
|
|
|
uint32_t count = mRequests.EntryCount();
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsIRequest*, 8> requests;
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-06-10 23:07:40 +03:00
|
|
|
if (!AppendRequestsToArray(&mRequests, &requests)) {
|
2002-07-09 05:03:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-04-28 01:05:52 +04:00
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
// set the load group status to our cancel status while we cancel
|
2000-10-26 10:34:20 +04:00
|
|
|
// all our requests...once the cancel is done, we'll reset it...
|
2001-04-28 01:05:52 +04:00
|
|
|
//
|
2000-10-26 10:34:20 +04:00
|
|
|
mStatus = status;
|
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
// Set the flag indicating that the loadgroup is being canceled... This
|
|
|
|
// prevents any new channels from being added during the operation.
|
|
|
|
//
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsCanceling = true;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2004-11-13 17:02:03 +03:00
|
|
|
nsresult firstError = NS_OK;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
while (count > 0) {
|
2009-02-23 04:05:28 +03:00
|
|
|
nsIRequest* request = requests.ElementAt(--count);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(request, "NULL request found in list.");
|
|
|
|
|
2015-05-21 10:34:25 +03:00
|
|
|
if (!mRequests.Search(request)) {
|
2002-07-09 05:03:45 +04:00
|
|
|
// |request| was removed already
|
|
|
|
NS_RELEASE(request);
|
|
|
|
continue;
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
|
2015-05-07 22:52:45 +03:00
|
|
|
nsAutoCString nameStr;
|
|
|
|
request->GetName(nameStr);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Canceling request %p %s.\n",
|
2015-05-07 22:52:45 +03:00
|
|
|
this, request, nameStr.get()));
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
//
|
|
|
|
// Remove the request from the load group... This may cause
|
|
|
|
// the OnStopRequest notification to fire...
|
|
|
|
//
|
|
|
|
// XXX: What should the context be?
|
|
|
|
//
|
2012-07-30 18:20:58 +04:00
|
|
|
(void)RemoveRequest(request, nullptr, status);
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
// Cancel the request...
|
|
|
|
rv = request->Cancel(status);
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
// Remember the first failure and return it...
|
|
|
|
if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
|
|
|
|
firstError = rv;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
NS_RELEASE(request);
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2017-08-30 16:32:00 +03:00
|
|
|
if (mRequestContext) {
|
|
|
|
Unused << mRequestContext->CancelTailPendingRequests(status);
|
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
#if defined(DEBUG)
|
2014-08-26 03:56:33 +04:00
|
|
|
NS_ASSERTION(mRequests.EntryCount() == 0, "Request list is not empty.");
|
2002-07-09 05:03:45 +04:00
|
|
|
NS_ASSERTION(mForegroundCount == 0, "Foreground URLs are active.");
|
2001-04-10 10:01:08 +04:00
|
|
|
#endif
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2000-10-26 10:34:20 +04:00
|
|
|
mStatus = NS_OK;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsCanceling = false;
|
2001-04-28 01:05:52 +04:00
|
|
|
|
1999-11-02 11:00:07 +03:00
|
|
|
return firstError;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
1999-07-31 10:28:31 +04:00
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-22 08:46:03 +03:00
|
|
|
nsLoadGroup::Suspend()
|
1999-07-01 23:30:20 +04:00
|
|
|
{
|
1999-11-22 08:46:03 +03:00
|
|
|
nsresult rv, firstError;
|
2014-08-26 03:56:33 +04:00
|
|
|
uint32_t count = mRequests.EntryCount();
|
1999-07-01 23:30:20 +04:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsIRequest*, 8> requests;
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-06-10 23:07:40 +03:00
|
|
|
if (!AppendRequestsToArray(&mRequests, &requests)) {
|
2002-07-09 05:03:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
|
|
|
firstError = NS_OK;
|
|
|
|
//
|
|
|
|
// Operate the elements from back to front so that if items get
|
|
|
|
// get removed from the list it won't affect our iteration
|
|
|
|
//
|
|
|
|
while (count > 0) {
|
2009-02-23 04:05:28 +03:00
|
|
|
nsIRequest* request = requests.ElementAt(--count);
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_ASSERTION(request, "NULL request found in list.");
|
2001-04-10 10:01:08 +04:00
|
|
|
if (!request)
|
1999-07-16 15:14:36 +04:00
|
|
|
continue;
|
1999-07-01 23:30:20 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
|
2015-05-07 22:52:45 +03:00
|
|
|
nsAutoCString nameStr;
|
|
|
|
request->GetName(nameStr);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Suspending request %p %s.\n",
|
2015-05-07 22:52:45 +03:00
|
|
|
this, request, nameStr.get()));
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Suspend the request...
|
|
|
|
rv = request->Suspend();
|
1999-11-22 08:46:03 +03:00
|
|
|
|
|
|
|
// Remember the first failure and return it...
|
2001-04-10 10:01:08 +04:00
|
|
|
if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
|
|
|
|
firstError = rv;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_RELEASE(request);
|
1999-07-27 12:45:35 +04:00
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
|
|
|
return firstError;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
|
1999-06-25 02:58:42 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-22 08:46:03 +03:00
|
|
|
nsLoadGroup::Resume()
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
1999-11-22 08:46:03 +03:00
|
|
|
nsresult rv, firstError;
|
2014-08-26 03:56:33 +04:00
|
|
|
uint32_t count = mRequests.EntryCount();
|
1999-11-02 11:00:07 +03:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsIRequest*, 8> requests;
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-06-10 23:07:40 +03:00
|
|
|
if (!AppendRequestsToArray(&mRequests, &requests)) {
|
2002-07-09 05:03:45 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-11-02 11:00:07 +03:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
firstError = NS_OK;
|
|
|
|
//
|
|
|
|
// Operate the elements from back to front so that if items get
|
|
|
|
// get removed from the list it won't affect our iteration
|
|
|
|
//
|
|
|
|
while (count > 0) {
|
2009-02-23 04:05:28 +03:00
|
|
|
nsIRequest* request = requests.ElementAt(--count);
|
1999-11-02 11:00:07 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_ASSERTION(request, "NULL request found in list.");
|
2001-04-10 10:01:08 +04:00
|
|
|
if (!request)
|
1999-11-22 08:46:03 +03:00
|
|
|
continue;
|
1999-06-25 02:58:42 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
|
2015-05-07 22:52:45 +03:00
|
|
|
nsAutoCString nameStr;
|
|
|
|
request->GetName(nameStr);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Resuming request %p %s.\n",
|
2015-05-07 22:52:45 +03:00
|
|
|
this, request, nameStr.get()));
|
|
|
|
}
|
1999-06-25 02:58:42 +04:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
// Resume the request...
|
|
|
|
rv = request->Resume();
|
1999-11-22 08:46:03 +03:00
|
|
|
|
|
|
|
// Remember the first failure and return it...
|
2001-04-10 10:01:08 +04:00
|
|
|
if (NS_FAILED(rv) && NS_SUCCEEDED(firstError))
|
|
|
|
firstError = rv;
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
NS_RELEASE(request);
|
1999-07-27 12:45:35 +04:00
|
|
|
}
|
1999-06-25 02:58:42 +04:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
return firstError;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::GetLoadFlags(uint32_t *aLoadFlags)
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
*aLoadFlags = mLoadFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-07-16 15:14:36 +04:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::SetLoadFlags(uint32_t aLoadFlags)
|
2001-04-10 10:01:08 +04:00
|
|
|
{
|
|
|
|
mLoadFlags = aLoadFlags;
|
|
|
|
return NS_OK;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
1999-07-10 15:26:47 +04:00
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::GetLoadGroup(nsILoadGroup **loadGroup)
|
1999-07-10 15:26:47 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
*loadGroup = mLoadGroup;
|
2004-11-13 17:02:03 +03:00
|
|
|
NS_IF_ADDREF(*loadGroup);
|
1999-07-10 15:26:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::SetLoadGroup(nsILoadGroup *loadGroup)
|
1999-07-10 15:26:47 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
mLoadGroup = loadGroup;
|
1999-07-10 15:26:47 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsILoadGroup methods:
|
|
|
|
|
1999-08-27 02:45:55 +04:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsLoadGroup::GetDefaultLoadRequest(nsIRequest * *aRequest)
|
1999-08-27 02:45:55 +04:00
|
|
|
{
|
2001-02-21 23:38:08 +03:00
|
|
|
*aRequest = mDefaultLoadRequest;
|
|
|
|
NS_IF_ADDREF(*aRequest);
|
1999-08-27 02:45:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsLoadGroup::SetDefaultLoadRequest(nsIRequest *aRequest)
|
1999-08-27 02:45:55 +04:00
|
|
|
{
|
2017-08-17 19:16:00 +03:00
|
|
|
LOG(("nsLoadGroup::SetDefaultLoadRequest this=%p default-request=%p",
|
|
|
|
this, aRequest));
|
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
mDefaultLoadRequest = aRequest;
|
2001-04-14 06:02:19 +04:00
|
|
|
// Inherit the group load flags from the default load request
|
2002-05-10 00:37:50 +04:00
|
|
|
if (mDefaultLoadRequest) {
|
2001-04-14 06:02:19 +04:00
|
|
|
mDefaultLoadRequest->GetLoadFlags(&mLoadFlags);
|
2002-05-10 00:37:50 +04:00
|
|
|
//
|
|
|
|
// Mask off any bits that are not part of the nsIRequest flags.
|
|
|
|
// in particular, nsIChannel::LOAD_DOCUMENT_URI...
|
|
|
|
//
|
2011-06-09 23:03:41 +04:00
|
|
|
mLoadFlags &= nsIRequest::LOAD_REQUESTMASK;
|
2011-07-02 00:22:18 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(aRequest);
|
2012-07-30 18:20:58 +04:00
|
|
|
mDefaultLoadIsTimed = timedChannel != nullptr;
|
2011-07-02 00:22:18 +04:00
|
|
|
if (mDefaultLoadIsTimed) {
|
|
|
|
timedChannel->GetChannelCreation(&mDefaultRequestCreationTime);
|
2011-10-17 18:59:28 +04:00
|
|
|
timedChannel->SetTimingEnabled(true);
|
2011-07-02 00:22:18 +04:00
|
|
|
}
|
2002-05-10 00:37:50 +04:00
|
|
|
}
|
2001-08-25 02:24:10 +04:00
|
|
|
// Else, do not change the group's load flags (see bug 95981)
|
1999-08-27 02:45:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-25 02:58:42 +04:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
1999-07-02 08:56:53 +04:00
|
|
|
nsresult rv;
|
1999-07-27 12:45:35 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString nameStr;
|
2002-07-09 05:03:45 +04:00
|
|
|
request->GetName(nameStr);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Adding request %p %s (count=%d).\n",
|
2014-08-26 03:56:33 +04:00
|
|
|
this, request, nameStr.get(), mRequests.EntryCount()));
|
2002-07-09 05:03:45 +04:00
|
|
|
}
|
2001-04-28 01:05:52 +04:00
|
|
|
|
2015-05-21 10:34:25 +03:00
|
|
|
NS_ASSERTION(!mRequests.Search(request),
|
2015-01-23 08:06:55 +03:00
|
|
|
"Entry added to loadgroup twice, don't do that");
|
2007-07-19 01:37:39 +04:00
|
|
|
|
2001-04-28 01:05:52 +04:00
|
|
|
//
|
|
|
|
// Do not add the channel, if the loadgroup is being canceled...
|
|
|
|
//
|
|
|
|
if (mIsCanceling) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: AddChannel() ABORTED because LoadGroup is"
|
2001-04-28 01:05:52 +04:00
|
|
|
" being canceled!!\n", this));
|
|
|
|
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
}
|
1999-06-25 02:58:42 +04:00
|
|
|
|
1999-07-16 15:14:36 +04:00
|
|
|
nsLoadFlags flags;
|
2015-07-21 16:23:00 +03:00
|
|
|
// if the request is the default load request or if the default load
|
|
|
|
// request is null, then the load group should inherit its load flags from
|
|
|
|
// the request, but also we need to enforce defaultLoadFlags.
|
|
|
|
if (mDefaultLoadRequest == request || !mDefaultLoadRequest) {
|
|
|
|
rv = MergeDefaultLoadFlags(request, flags);
|
|
|
|
} else {
|
2001-08-25 02:24:10 +04:00
|
|
|
rv = MergeLoadFlags(request, flags);
|
2015-07-21 16:23:00 +03:00
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2016-02-10 00:33:34 +03:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
2001-02-21 23:38:08 +03:00
|
|
|
// Add the request to the list of active requests...
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-09-15 00:23:12 +03:00
|
|
|
auto entry =
|
|
|
|
static_cast<RequestMapEntry*>(mRequests.Add(request, fallible));
|
2002-07-09 05:03:45 +04:00
|
|
|
if (!entry) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2005-02-21 23:58:01 +03:00
|
|
|
if (mPriority != 0)
|
|
|
|
RescheduleRequest(request, mPriority);
|
|
|
|
|
2011-07-02 00:22:18 +04:00
|
|
|
nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(request);
|
|
|
|
if (timedChannel)
|
2011-10-17 18:59:28 +04:00
|
|
|
timedChannel->SetTimingEnabled(true);
|
2011-07-02 00:22:18 +04:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
if (!(flags & nsIRequest::LOAD_BACKGROUND)) {
|
1999-11-22 08:46:03 +03:00
|
|
|
// Update the count of foreground URIs..
|
|
|
|
mForegroundCount += 1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Fire the OnStartRequest notification out to the observer...
|
|
|
|
//
|
2001-02-21 23:38:08 +03:00
|
|
|
// If the notification fails then DO NOT add the request to
|
1999-11-22 08:46:03 +03:00
|
|
|
// the load group.
|
|
|
|
//
|
2001-04-10 10:01:08 +04:00
|
|
|
nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
|
2000-03-24 08:42:10 +03:00
|
|
|
if (observer) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Firing OnStartRequest for request %p."
|
2001-04-10 10:01:08 +04:00
|
|
|
"(foreground count=%d).\n", this, request, mForegroundCount));
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-02-21 23:38:08 +03:00
|
|
|
rv = observer->OnStartRequest(request, ctxt);
|
1999-11-22 08:46:03 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: OnStartRequest for request %p FAILED.\n",
|
2001-04-10 10:01:08 +04:00
|
|
|
this, request));
|
1999-11-22 08:46:03 +03:00
|
|
|
//
|
|
|
|
// The URI load has been canceled by the observer. Clean up
|
|
|
|
// the damage...
|
|
|
|
//
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-09-15 00:23:24 +03:00
|
|
|
mRequests.Remove(request);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
rv = NS_OK;
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
mForegroundCount -= 1;
|
1999-07-16 15:14:36 +04:00
|
|
|
}
|
|
|
|
}
|
2004-11-13 17:02:03 +03:00
|
|
|
|
|
|
|
// Ensure that we're part of our loadgroup while pending
|
|
|
|
if (mForegroundCount == 1 && mLoadGroup) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mLoadGroup->AddRequest(this, nullptr);
|
2004-11-13 17:02:03 +03:00
|
|
|
}
|
|
|
|
|
1999-07-02 08:56:53 +04:00
|
|
|
}
|
1999-07-16 15:14:36 +04:00
|
|
|
|
|
|
|
return rv;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
1999-07-01 23:30:20 +04:00
|
|
|
NS_IMETHODIMP
|
2002-07-09 05:03:45 +04:00
|
|
|
nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt,
|
|
|
|
nsresult aStatus)
|
1999-07-01 23:30:20 +04:00
|
|
|
{
|
2002-01-16 03:16:51 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(request);
|
1999-07-02 08:56:53 +04:00
|
|
|
nsresult rv;
|
1999-07-16 15:14:36 +04:00
|
|
|
|
2015-06-04 01:25:57 +03:00
|
|
|
if (MOZ_LOG_TEST(gLoadGroupLog, LogLevel::Debug)) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString nameStr;
|
2002-03-21 01:50:33 +03:00
|
|
|
request->GetName(nameStr);
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Removing request %p %s status %" PRIx32 " (count=%d).\n",
|
|
|
|
this, request, nameStr.get(), static_cast<uint32_t>(aStatus),
|
|
|
|
mRequests.EntryCount() - 1));
|
2002-07-09 05:03:45 +04:00
|
|
|
}
|
1999-07-27 12:45:35 +04:00
|
|
|
|
2002-07-09 05:03:45 +04:00
|
|
|
// Make sure we have a owning reference to the request we're about
|
|
|
|
// to remove.
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRequest> kungFuDeathGrip(request);
|
|
|
|
|
1999-08-27 02:45:55 +04:00
|
|
|
//
|
2001-02-21 23:38:08 +03:00
|
|
|
// Remove the request from the group. If this fails, it means that
|
|
|
|
// the request was *not* in the group so do not update the foreground
|
1999-08-27 02:45:55 +04:00
|
|
|
// count or it will get messed up...
|
|
|
|
//
|
2015-05-21 10:34:25 +03:00
|
|
|
auto entry = static_cast<RequestMapEntry*>(mRequests.Search(request));
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-01-23 08:06:55 +03:00
|
|
|
if (!entry) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Unable to remove request %p. Not in group!\n",
|
2001-04-10 10:01:08 +04:00
|
|
|
this, request));
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-27 02:45:55 +04:00
|
|
|
}
|
|
|
|
|
2015-09-08 05:20:16 +03:00
|
|
|
mRequests.RemoveEntry(entry);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2011-07-02 00:22:18 +04:00
|
|
|
// Collect telemetry stats only when default request is a timed channel.
|
|
|
|
// Don't include failed requests in the timing statistics.
|
|
|
|
if (mDefaultLoadIsTimed && NS_SUCCEEDED(aStatus)) {
|
|
|
|
nsCOMPtr<nsITimedChannel> timedChannel = do_QueryInterface(request);
|
|
|
|
if (timedChannel) {
|
|
|
|
// Figure out if this request was served from the cache
|
|
|
|
++mTimedRequests;
|
|
|
|
TimeStamp timeStamp;
|
|
|
|
rv = timedChannel->GetCacheReadStart(&timeStamp);
|
2013-04-15 17:41:27 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && !timeStamp.IsNull()) {
|
2011-07-02 00:22:18 +04:00
|
|
|
++mCachedRequests;
|
2013-04-15 17:41:27 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mTimedNonCachedRequestsUntilOnEndPageLoad++;
|
|
|
|
}
|
2011-07-02 00:22:18 +04:00
|
|
|
|
|
|
|
rv = timedChannel->GetAsyncOpen(&timeStamp);
|
|
|
|
if (NS_SUCCEEDED(rv) && !timeStamp.IsNull()) {
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta(
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_SUBITEM_OPEN_LATENCY_TIME,
|
2011-10-10 21:05:47 +04:00
|
|
|
mDefaultRequestCreationTime, timeStamp);
|
2011-07-02 00:22:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rv = timedChannel->GetResponseStart(&timeStamp);
|
|
|
|
if (NS_SUCCEEDED(rv) && !timeStamp.IsNull()) {
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta(
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_SUBITEM_FIRST_BYTE_LATENCY_TIME,
|
2011-10-10 21:05:47 +04:00
|
|
|
mDefaultRequestCreationTime, timeStamp);
|
2011-07-02 00:22:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TelemetryReportChannel(timedChannel, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-26 03:56:33 +04:00
|
|
|
if (mRequests.EntryCount() == 0) {
|
2011-07-02 00:22:18 +04:00
|
|
|
TelemetryReport();
|
|
|
|
}
|
|
|
|
|
2005-02-21 23:58:01 +03:00
|
|
|
// Undo any group priority delta...
|
|
|
|
if (mPriority != 0)
|
|
|
|
RescheduleRequest(request, -mPriority);
|
|
|
|
|
1999-07-16 15:14:36 +04:00
|
|
|
nsLoadFlags flags;
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = request->GetLoadFlags(&flags);
|
1999-11-22 08:46:03 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-07-01 23:30:20 +04:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
if (!(flags & nsIRequest::LOAD_BACKGROUND)) {
|
1999-11-22 08:46:03 +03:00
|
|
|
NS_ASSERTION(mForegroundCount > 0, "ForegroundCount messed up");
|
|
|
|
mForegroundCount -= 1;
|
1999-07-10 01:18:47 +04:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
// Fire the OnStopRequest out to the observer...
|
2001-04-10 10:01:08 +04:00
|
|
|
nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
|
2000-03-24 08:42:10 +03:00
|
|
|
if (observer) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: Firing OnStopRequest for request %p."
|
2001-04-10 10:01:08 +04:00
|
|
|
"(foreground count=%d).\n", this, request, mForegroundCount));
|
1999-11-22 08:46:03 +03:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = observer->OnStopRequest(request, ctxt, aStatus);
|
2002-07-09 05:03:45 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
2016-12-16 06:16:31 +03:00
|
|
|
LOG(("LOADGROUP [%p]: OnStopRequest for request %p FAILED.\n",
|
2001-04-10 10:01:08 +04:00
|
|
|
this, request));
|
2002-07-09 05:03:45 +04:00
|
|
|
}
|
1999-11-22 08:46:03 +03:00
|
|
|
}
|
2004-11-13 17:02:03 +03:00
|
|
|
|
|
|
|
// If that was the last request -> remove ourselves from loadgroup
|
|
|
|
if (mForegroundCount == 0 && mLoadGroup) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mLoadGroup->RemoveRequest(this, nullptr, aStatus);
|
2004-11-13 17:02:03 +03:00
|
|
|
}
|
1999-07-02 08:56:53 +04:00
|
|
|
}
|
1999-07-27 12:45:35 +04:00
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
return rv;
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 23:38:08 +03:00
|
|
|
nsLoadGroup::GetRequests(nsISimpleEnumerator * *aRequests)
|
1999-06-25 02:58:42 +04:00
|
|
|
{
|
2012-12-09 14:04:21 +04:00
|
|
|
nsCOMArray<nsIRequest> requests;
|
2014-08-26 03:56:33 +04:00
|
|
|
requests.SetCapacity(mRequests.EntryCount());
|
2002-07-09 05:03:45 +04:00
|
|
|
|
2015-06-12 07:19:53 +03:00
|
|
|
for (auto iter = mRequests.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
auto e = static_cast<RequestMapEntry*>(iter.Get());
|
2015-06-10 23:07:40 +03:00
|
|
|
requests.AppendObject(e->mKey);
|
|
|
|
}
|
2012-12-09 14:04:21 +04:00
|
|
|
|
|
|
|
return NS_NewArrayEnumerator(aRequests, requests);
|
1999-06-25 02:58:42 +04:00
|
|
|
}
|
|
|
|
|
1999-08-27 02:45:55 +04:00
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::SetGroupObserver(nsIRequestObserver* aObserver)
|
1999-08-27 02:45:55 +04:00
|
|
|
{
|
2003-07-25 23:06:59 +04:00
|
|
|
mObserver = do_GetWeakReference(aObserver);
|
1999-08-27 02:45:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::GetGroupObserver(nsIRequestObserver* *aResult)
|
1999-08-27 02:45:55 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
nsCOMPtr<nsIRequestObserver> observer = do_QueryReferent(mObserver);
|
|
|
|
*aResult = observer;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
1999-08-27 02:45:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:36:07 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::GetActiveCount(uint32_t* aResult)
|
1999-10-19 23:36:07 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
*aResult = mForegroundCount;
|
|
|
|
return NS_OK;
|
1999-10-19 23:36:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks)
|
1999-10-19 23:36:07 +04:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aCallbacks);
|
|
|
|
*aCallbacks = mCallbacks;
|
|
|
|
NS_IF_ADDREF(*aCallbacks);
|
|
|
|
return NS_OK;
|
1999-10-19 23:36:07 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 08:46:03 +03:00
|
|
|
NS_IMETHODIMP
|
2001-04-10 10:01:08 +04:00
|
|
|
nsLoadGroup::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
|
1999-11-22 08:46:03 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
mCallbacks = aCallbacks;
|
1999-11-22 08:46:03 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-05 03:06:29 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-23 17:40:36 +03:00
|
|
|
nsLoadGroup::GetRequestContextID(uint64_t *aRCID)
|
2012-12-05 03:06:29 +04:00
|
|
|
{
|
2016-04-21 17:59:17 +03:00
|
|
|
if (!mRequestContext) {
|
2015-07-31 23:50:08 +03:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2016-04-21 17:59:17 +03:00
|
|
|
return mRequestContext->GetID(aRCID);
|
2012-12-05 03:06:29 +04:00
|
|
|
}
|
|
|
|
|
2013-04-09 21:38:48 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsILoadGroupChild methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetParentLoadGroup(nsILoadGroup * *aParentLoadGroup)
|
|
|
|
{
|
|
|
|
*aParentLoadGroup = nullptr;
|
|
|
|
nsCOMPtr<nsILoadGroup> parent = do_QueryReferent(mParentLoadGroup);
|
|
|
|
if (!parent)
|
|
|
|
return NS_OK;
|
|
|
|
parent.forget(aParentLoadGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::SetParentLoadGroup(nsILoadGroup *aParentLoadGroup)
|
|
|
|
{
|
|
|
|
mParentLoadGroup = do_GetWeakReference(aParentLoadGroup);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetChildLoadGroup(nsILoadGroup * *aChildLoadGroup)
|
|
|
|
{
|
|
|
|
NS_ADDREF(*aChildLoadGroup = this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetRootLoadGroup(nsILoadGroup * *aRootLoadGroup)
|
|
|
|
{
|
|
|
|
// first recursively try the root load group of our parent
|
|
|
|
nsCOMPtr<nsILoadGroupChild> ancestor = do_QueryReferent(mParentLoadGroup);
|
|
|
|
if (ancestor)
|
|
|
|
return ancestor->GetRootLoadGroup(aRootLoadGroup);
|
|
|
|
|
|
|
|
// next recursively try the root load group of our own load grop
|
|
|
|
ancestor = do_QueryInterface(mLoadGroup);
|
|
|
|
if (ancestor)
|
|
|
|
return ancestor->GetRootLoadGroup(aRootLoadGroup);
|
|
|
|
|
|
|
|
// finally just return this
|
|
|
|
NS_ADDREF(*aRootLoadGroup = this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-15 17:41:27 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsPILoadGroupInternal methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::OnEndPageLoad(nsIChannel *aDefaultChannel)
|
|
|
|
{
|
2017-08-17 19:16:00 +03:00
|
|
|
LOG(("nsLoadGroup::OnEndPageLoad this=%p default-request=%p",
|
|
|
|
this, aDefaultChannel));
|
|
|
|
|
2013-05-08 19:43:31 +04:00
|
|
|
// for the moment, nothing to do here.
|
2013-04-15 17:41:27 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-21 23:58:01 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupportsPriority methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::GetPriority(int32_t *aValue)
|
2005-02-21 23:58:01 +03:00
|
|
|
{
|
|
|
|
*aValue = mPriority;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::SetPriority(int32_t aValue)
|
2005-02-21 23:58:01 +03:00
|
|
|
{
|
2005-02-22 01:21:21 +03:00
|
|
|
return AdjustPriority(aValue - mPriority);
|
2005-02-21 23:58:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsLoadGroup::AdjustPriority(int32_t aDelta)
|
2005-02-21 23:58:01 +03:00
|
|
|
{
|
|
|
|
// Update the priority for each request that supports nsISupportsPriority
|
|
|
|
if (aDelta != 0) {
|
|
|
|
mPriority += aDelta;
|
2015-06-12 07:19:53 +03:00
|
|
|
for (auto iter = mRequests.Iter(); !iter.Done(); iter.Next()) {
|
|
|
|
auto e = static_cast<RequestMapEntry*>(iter.Get());
|
2015-06-10 23:07:40 +03:00
|
|
|
RescheduleRequest(e->mKey, aDelta);
|
|
|
|
}
|
2005-02-21 23:58:01 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:33:29 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetDefaultLoadFlags(uint32_t *aFlags)
|
|
|
|
{
|
|
|
|
*aFlags = mDefaultLoadFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::SetDefaultLoadFlags(uint32_t aFlags)
|
|
|
|
{
|
|
|
|
mDefaultLoadFlags = aFlags;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-10 00:33:34 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::GetUserAgentOverrideCache(nsACString & aUserAgentOverrideCache)
|
|
|
|
{
|
|
|
|
aUserAgentOverrideCache = mUserAgentOverrideCache;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsLoadGroup::SetUserAgentOverrideCache(const nsACString & aUserAgentOverrideCache)
|
|
|
|
{
|
|
|
|
mUserAgentOverrideCache = aUserAgentOverrideCache;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-09-06 10:33:29 +04:00
|
|
|
|
1999-06-25 02:58:42 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2000-01-15 09:12:54 +03:00
|
|
|
|
2016-02-10 00:33:34 +03:00
|
|
|
void
|
2011-07-02 00:22:18 +04:00
|
|
|
nsLoadGroup::TelemetryReport()
|
|
|
|
{
|
2017-05-29 23:15:37 +03:00
|
|
|
nsresult defaultStatus = NS_ERROR_INVALID_ARG;
|
|
|
|
// We should only report HTTP_PAGE_* telemetry if the defaultRequest was
|
|
|
|
// actually successful.
|
|
|
|
if (mDefaultLoadRequest) {
|
|
|
|
mDefaultLoadRequest->GetStatus(&defaultStatus);
|
|
|
|
}
|
|
|
|
if (mDefaultLoadIsTimed && NS_SUCCEEDED(defaultStatus)) {
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_PAGE, mTimedRequests);
|
|
|
|
if (mTimedRequests) {
|
|
|
|
Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_PAGE_FROM_CACHE,
|
|
|
|
mCachedRequests * 100 / mTimedRequests);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsITimedChannel> timedChannel =
|
|
|
|
do_QueryInterface(mDefaultLoadRequest);
|
|
|
|
if (timedChannel)
|
|
|
|
TelemetryReportChannel(timedChannel, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
mTimedRequests = 0;
|
|
|
|
mCachedRequests = 0;
|
|
|
|
mDefaultLoadIsTimed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsLoadGroup::TelemetryReportChannel(nsITimedChannel *aTimedChannel,
|
|
|
|
bool aDefaultRequest)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool timingEnabled;
|
2011-07-02 00:22:18 +04:00
|
|
|
rv = aTimedChannel->GetTimingEnabled(&timingEnabled);
|
|
|
|
if (NS_FAILED(rv) || !timingEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp asyncOpen;
|
|
|
|
rv = aTimedChannel->GetAsyncOpen(&asyncOpen);
|
|
|
|
// We do not check !asyncOpen.IsNull() bellow, prevent ASSERTIONs this way
|
|
|
|
if (NS_FAILED(rv) || asyncOpen.IsNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp cacheReadStart;
|
|
|
|
rv = aTimedChannel->GetCacheReadStart(&cacheReadStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp cacheReadEnd;
|
|
|
|
rv = aTimedChannel->GetCacheReadEnd(&cacheReadEnd);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp domainLookupStart;
|
|
|
|
rv = aTimedChannel->GetDomainLookupStart(&domainLookupStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp domainLookupEnd;
|
|
|
|
rv = aTimedChannel->GetDomainLookupEnd(&domainLookupEnd);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp connectStart;
|
|
|
|
rv = aTimedChannel->GetConnectStart(&connectStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
2017-07-10 22:01:35 +03:00
|
|
|
TimeStamp secureConnectionStart;
|
|
|
|
rv = aTimedChannel->GetSecureConnectionStart(&secureConnectionStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
2011-07-02 00:22:18 +04:00
|
|
|
TimeStamp connectEnd;
|
|
|
|
rv = aTimedChannel->GetConnectEnd(&connectEnd);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp requestStart;
|
|
|
|
rv = aTimedChannel->GetRequestStart(&requestStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp responseStart;
|
|
|
|
rv = aTimedChannel->GetResponseStart(&responseStart);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TimeStamp responseEnd;
|
|
|
|
rv = aTimedChannel->GetResponseEnd(&responseEnd);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
#define HTTP_REQUEST_HISTOGRAMS(prefix) \
|
|
|
|
if (!domainLookupStart.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_DNS_ISSUE_TIME, \
|
2011-10-10 21:05:47 +04:00
|
|
|
asyncOpen, domainLookupStart); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (!domainLookupStart.IsNull() && !domainLookupEnd.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_DNS_LOOKUP_TIME, \
|
2011-10-10 21:05:47 +04:00
|
|
|
domainLookupStart, domainLookupEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
\
|
2017-07-10 22:01:35 +03:00
|
|
|
if (!secureConnectionStart.IsNull() && !connectEnd.IsNull()) { \
|
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_TLS_HANDSHAKE, \
|
|
|
|
secureConnectionStart, connectEnd); \
|
|
|
|
} \
|
|
|
|
\
|
2011-07-02 00:22:18 +04:00
|
|
|
if (!connectStart.IsNull() && !connectEnd.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2017-07-10 22:01:35 +03:00
|
|
|
Telemetry::HTTP_##prefix##_TCP_CONNECTION_2, \
|
2011-10-10 21:05:47 +04:00
|
|
|
connectStart, connectEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (!requestStart.IsNull() && !responseEnd.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_SENT, \
|
2011-10-10 21:05:47 +04:00
|
|
|
asyncOpen, requestStart); \
|
2011-07-02 00:22:18 +04:00
|
|
|
\
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_FIRST_SENT_TO_LAST_RECEIVED, \
|
2011-10-10 21:05:47 +04:00
|
|
|
requestStart, responseEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
\
|
2011-08-21 12:27:29 +04:00
|
|
|
if (cacheReadStart.IsNull() && !responseStart.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_RECEIVED, \
|
2011-10-10 21:05:47 +04:00
|
|
|
asyncOpen, responseStart); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (!cacheReadStart.IsNull() && !cacheReadEnd.IsNull()) { \
|
2017-08-24 11:25:38 +03:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_OPEN_TO_FIRST_FROM_CACHE_V2, \
|
|
|
|
asyncOpen, cacheReadStart); \
|
2011-07-02 00:22:18 +04:00
|
|
|
\
|
2017-08-24 11:25:38 +03:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_CACHE_READ_TIME_V2, \
|
|
|
|
cacheReadStart, cacheReadEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
\
|
|
|
|
if (!requestStart.IsNull() && !responseEnd.IsNull()) { \
|
2011-10-10 21:05:47 +04:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
2011-07-02 00:22:18 +04:00
|
|
|
Telemetry::HTTP_##prefix##_REVALIDATION, \
|
2011-10-10 21:05:47 +04:00
|
|
|
requestStart, responseEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if (!cacheReadEnd.IsNull()) { \
|
2017-08-24 11:25:38 +03:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \
|
|
|
|
asyncOpen, cacheReadEnd); \
|
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_COMPLETE_LOAD_CACHED_V2, \
|
|
|
|
asyncOpen, cacheReadEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
} \
|
|
|
|
else if (!responseEnd.IsNull()) { \
|
2017-08-24 11:25:38 +03:00
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_COMPLETE_LOAD_V2, \
|
|
|
|
asyncOpen, responseEnd); \
|
|
|
|
Telemetry::AccumulateTimeDelta( \
|
|
|
|
Telemetry::HTTP_##prefix##_COMPLETE_LOAD_NET_V2, \
|
|
|
|
asyncOpen, responseEnd); \
|
2011-07-02 00:22:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aDefaultRequest) {
|
|
|
|
HTTP_REQUEST_HISTOGRAMS(PAGE)
|
|
|
|
} else {
|
|
|
|
HTTP_REQUEST_HISTOGRAMS(SUB)
|
|
|
|
}
|
|
|
|
#undef HTTP_REQUEST_HISTOGRAMS
|
|
|
|
}
|
|
|
|
|
2015-07-21 16:23:00 +03:00
|
|
|
nsresult nsLoadGroup::MergeLoadFlags(nsIRequest *aRequest,
|
|
|
|
nsLoadFlags& outFlags)
|
2000-01-15 09:12:54 +03:00
|
|
|
{
|
2001-04-10 10:01:08 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsLoadFlags flags, oldFlags;
|
2000-01-15 09:12:54 +03:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = aRequest->GetLoadFlags(&flags);
|
2015-07-21 16:23:00 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2001-04-10 10:01:08 +04:00
|
|
|
return rv;
|
2015-07-21 16:23:00 +03:00
|
|
|
}
|
2001-02-21 23:38:08 +03:00
|
|
|
|
2001-04-10 10:01:08 +04:00
|
|
|
oldFlags = flags;
|
|
|
|
|
2001-04-14 06:02:19 +04:00
|
|
|
// Inherit the following bits...
|
|
|
|
flags |= (mLoadFlags & (LOAD_BACKGROUND |
|
|
|
|
LOAD_BYPASS_CACHE |
|
|
|
|
LOAD_FROM_CACHE |
|
|
|
|
VALIDATE_ALWAYS |
|
|
|
|
VALIDATE_ONCE_PER_SESSION |
|
|
|
|
VALIDATE_NEVER));
|
2001-04-10 10:01:08 +04:00
|
|
|
|
2013-09-06 10:33:29 +04:00
|
|
|
// ... and force the default flags.
|
|
|
|
flags |= mDefaultLoadFlags;
|
|
|
|
|
2015-07-21 16:23:00 +03:00
|
|
|
if (flags != oldFlags) {
|
2001-04-10 10:01:08 +04:00
|
|
|
rv = aRequest->SetLoadFlags(flags);
|
2015-07-21 16:23:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
outFlags = flags;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsLoadGroup::MergeDefaultLoadFlags(nsIRequest *aRequest,
|
|
|
|
nsLoadFlags& outFlags)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsLoadFlags flags, oldFlags;
|
|
|
|
|
|
|
|
rv = aRequest->GetLoadFlags(&flags);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-04-10 10:01:08 +04:00
|
|
|
|
2015-07-21 16:23:00 +03:00
|
|
|
oldFlags = flags;
|
|
|
|
// ... and force the default flags.
|
|
|
|
flags |= mDefaultLoadFlags;
|
|
|
|
|
|
|
|
if (flags != oldFlags) {
|
|
|
|
rv = aRequest->SetLoadFlags(flags);
|
|
|
|
}
|
2001-04-10 10:01:08 +04:00
|
|
|
outFlags = flags;
|
|
|
|
return rv;
|
2000-01-15 09:12:54 +03:00
|
|
|
}
|
2012-12-05 03:06:29 +04:00
|
|
|
|
2015-07-31 23:50:08 +03:00
|
|
|
nsresult nsLoadGroup::Init()
|
|
|
|
{
|
2016-04-21 17:59:17 +03:00
|
|
|
mRequestContextService = do_GetService("@mozilla.org/network/request-context-service;1");
|
|
|
|
if (mRequestContextService) {
|
2017-03-15 07:10:10 +03:00
|
|
|
Unused << mRequestContextService->NewRequestContext(getter_AddRefs(mRequestContext));
|
2015-07-31 23:50:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-12-03 05:56:50 +04:00
|
|
|
#undef LOG
|