mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 950311 - deCOM nsIDOMLoadStatus. r=mayhemer
This commit is contained in:
parent
b71a9b5209
commit
0ca884d24e
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMLoadStatus.idl',
|
||||
'nsIDOMOfflineResourceList.idl',
|
||||
]
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "domstubs.idl"
|
||||
|
||||
[uuid(2cb53a8a-d2f4-4ddf-874f-3bc2d595c41a)]
|
||||
interface nsIDOMLoadStatus : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMNode source;
|
||||
readonly attribute DOMString uri;
|
||||
readonly attribute long totalSize;
|
||||
readonly attribute long loadedSize;
|
||||
readonly attribute unsigned short readyState;
|
||||
readonly attribute unsigned short status;
|
||||
|
||||
const unsigned short UNINITIALIZED = 0;
|
||||
const unsigned short REQUESTED = 1;
|
||||
const unsigned short RECEIVING = 2;
|
||||
const unsigned short LOADED = 3;
|
||||
};
|
@ -14,7 +14,6 @@
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsICacheService.h"
|
||||
#include "nsIOfflineCacheUpdate.h"
|
||||
#include "nsIDOMLoadStatus.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
|
@ -9,7 +9,6 @@ interface nsIURI;
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDOMNode;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIDOMLoadStatus;
|
||||
interface nsIOfflineCacheUpdate;
|
||||
interface nsIPrincipal;
|
||||
interface nsIPrefBranch;
|
||||
@ -55,10 +54,6 @@ interface nsIOfflineCacheUpdateObserver : nsISupports {
|
||||
*
|
||||
* It can be used to perform partial or complete updates.
|
||||
*
|
||||
* Each update object maintains a list of nsIDOMLoadStatus items for the
|
||||
* resources it is updating. The list of these items will be available
|
||||
* after the object is scheduled.
|
||||
*
|
||||
* One update object will be updating at a time. The active object will
|
||||
* load its items one by one, sending itemCompleted() to any registered
|
||||
* observers.
|
||||
|
@ -26,8 +26,7 @@ interface nsIPrefetchService : nsISupports
|
||||
in boolean aExplicit);
|
||||
|
||||
/**
|
||||
* Enumerate the items in the prefetch queue. Each element in the
|
||||
* enumeration is an nsIDOMLoadStatus.
|
||||
* Enumerate the items in the prefetch queue.
|
||||
*/
|
||||
nsISimpleEnumerator enumerateQueue();
|
||||
|
||||
|
@ -309,8 +309,7 @@ nsManifestCheck::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
||||
// nsOfflineCacheUpdateItem::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS6(nsOfflineCacheUpdateItem,
|
||||
nsIDOMLoadStatus,
|
||||
NS_IMPL_ISUPPORTS5(nsOfflineCacheUpdateItem,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIRunnable,
|
||||
@ -332,7 +331,7 @@ nsOfflineCacheUpdateItem::nsOfflineCacheUpdateItem(nsIURI *aURI,
|
||||
, mPreviousApplicationCache(aPreviousApplicationCache)
|
||||
, mItemType(type)
|
||||
, mChannel(nullptr)
|
||||
, mState(nsIDOMLoadStatus::UNINITIALIZED)
|
||||
, mState(LoadStatus::UNINITIALIZED)
|
||||
, mBytesRead(0)
|
||||
{
|
||||
}
|
||||
@ -409,7 +408,7 @@ nsOfflineCacheUpdateItem::OpenChannel(nsOfflineCacheUpdate *aUpdate)
|
||||
|
||||
mUpdate = aUpdate;
|
||||
|
||||
mState = nsIDOMLoadStatus::REQUESTED;
|
||||
mState = LoadStatus::REQUESTED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -422,7 +421,7 @@ nsOfflineCacheUpdateItem::Cancel()
|
||||
mChannel = nullptr;
|
||||
}
|
||||
|
||||
mState = nsIDOMLoadStatus::UNINITIALIZED;
|
||||
mState = LoadStatus::UNINITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -435,7 +434,7 @@ NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::OnStartRequest(nsIRequest *aRequest,
|
||||
nsISupports *aContext)
|
||||
{
|
||||
mState = nsIDOMLoadStatus::RECEIVING;
|
||||
mState = LoadStatus::RECEIVING;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -512,7 +511,7 @@ nsOfflineCacheUpdateItem::Run()
|
||||
// take this item as already finished and finish the update process too
|
||||
// early when ProcessNextURI() would get called between OnStopRequest()
|
||||
// and Run() of this item. Finish() would then have been called twice.
|
||||
mState = nsIDOMLoadStatus::LOADED;
|
||||
mState = LoadStatus::LOADED;
|
||||
|
||||
nsRefPtr<nsOfflineCacheUpdate> update;
|
||||
update.swap(mUpdate);
|
||||
@ -591,57 +590,6 @@ nsOfflineCacheUpdateItem::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsOfflineCacheUpdateItem::nsIDOMLoadStatus
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetSource(nsIDOMNode **aSource)
|
||||
{
|
||||
*aSource = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetUri(nsAString &aURI)
|
||||
{
|
||||
nsAutoCString spec;
|
||||
nsresult rv = mURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CopyUTF8toUTF16(spec, aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetTotalSize(int32_t *aTotalSize)
|
||||
{
|
||||
if (mChannel) {
|
||||
int64_t size64;
|
||||
nsresult rv = mChannel->GetContentLength(&size64);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aTotalSize = int32_t(size64); // XXX - loses precision
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aTotalSize = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetLoadedSize(int32_t *aLoadedSize)
|
||||
{
|
||||
*aLoadedSize = int32_t(mBytesRead); // XXX - loses precision
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsOfflineCacheUpdateItem::GetReadyState(uint16_t *aReadyState)
|
||||
{
|
||||
*aReadyState = mState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdateItem::GetRequestSucceeded(bool * succeeded)
|
||||
{
|
||||
@ -681,23 +629,23 @@ nsOfflineCacheUpdateItem::GetRequestSucceeded(bool * succeeded)
|
||||
bool
|
||||
nsOfflineCacheUpdateItem::IsScheduled()
|
||||
{
|
||||
return mState == nsIDOMLoadStatus::UNINITIALIZED;
|
||||
return mState == LoadStatus::UNINITIALIZED;
|
||||
}
|
||||
|
||||
bool
|
||||
nsOfflineCacheUpdateItem::IsInProgress()
|
||||
{
|
||||
return mState == nsIDOMLoadStatus::REQUESTED ||
|
||||
mState == nsIDOMLoadStatus::RECEIVING;
|
||||
return mState == LoadStatus::REQUESTED ||
|
||||
mState == LoadStatus::RECEIVING;
|
||||
}
|
||||
|
||||
bool
|
||||
nsOfflineCacheUpdateItem::IsCompleted()
|
||||
{
|
||||
return mState == nsIDOMLoadStatus::LOADED;
|
||||
return mState == LoadStatus::LOADED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsOfflineCacheUpdateItem::GetStatus(uint16_t *aStatus)
|
||||
{
|
||||
if (!mChannel) {
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMLoadStatus.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIObserver.h"
|
||||
@ -39,15 +38,13 @@ class nsICacheEntryDescriptor;
|
||||
class nsIUTF8StringEnumerator;
|
||||
class nsILoadContext;
|
||||
|
||||
class nsOfflineCacheUpdateItem : public nsIDOMLoadStatus
|
||||
, public nsIStreamListener
|
||||
class nsOfflineCacheUpdateItem : public nsIStreamListener
|
||||
, public nsIRunnable
|
||||
, public nsIInterfaceRequestor
|
||||
, public nsIChannelEventSink
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMLOADSTATUS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIRUNNABLE
|
||||
@ -76,7 +73,16 @@ public:
|
||||
bool IsScheduled();
|
||||
bool IsCompleted();
|
||||
|
||||
nsresult GetStatus(uint16_t *aStatus);
|
||||
|
||||
private:
|
||||
enum LoadStatus MOZ_ENUM_TYPE(uint16_t) {
|
||||
UNINITIALIZED = 0U,
|
||||
REQUESTED = 1U,
|
||||
RECEIVING = 2U,
|
||||
LOADED = 3U
|
||||
};
|
||||
|
||||
nsRefPtr<nsOfflineCacheUpdate> mUpdate;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
uint16_t mState;
|
||||
|
@ -114,7 +114,7 @@ nsPrefetchQueueEnumerator::GetNext(nsISupports **aItem)
|
||||
{
|
||||
if (!mCurrent) return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ADDREF(*aItem = static_cast<nsIDOMLoadStatus*>(mCurrent.get()));
|
||||
NS_ADDREF(*aItem = static_cast<nsIStreamListener*>(mCurrent.get()));
|
||||
|
||||
Increment();
|
||||
|
||||
@ -171,7 +171,6 @@ nsPrefetchNode::nsPrefetchNode(nsPrefetchService *aService,
|
||||
, mReferrerURI(aReferrerURI)
|
||||
, mService(aService)
|
||||
, mChannel(nullptr)
|
||||
, mState(nsIDOMLoadStatus::UNINITIALIZED)
|
||||
, mBytesRead(0)
|
||||
{
|
||||
mSource = do_GetWeakReference(aSource);
|
||||
@ -208,8 +207,6 @@ nsPrefetchNode::OpenChannel()
|
||||
rv = mChannel->AsyncOpen(this, nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mState = nsIDOMLoadStatus::REQUESTED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -219,8 +216,6 @@ nsPrefetchNode::CancelChannel(nsresult error)
|
||||
mChannel->Cancel(error);
|
||||
mChannel = nullptr;
|
||||
|
||||
mState = nsIDOMLoadStatus::UNINITIALIZED;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -228,8 +223,7 @@ nsPrefetchNode::CancelChannel(nsresult error)
|
||||
// nsPrefetchNode::nsISupports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS6(nsPrefetchNode,
|
||||
nsIDOMLoadStatus,
|
||||
NS_IMPL_ISUPPORTS5(nsPrefetchNode,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIInterfaceRequestor,
|
||||
@ -280,8 +274,6 @@ nsPrefetchNode::OnStartRequest(nsIRequest *aRequest,
|
||||
}
|
||||
}
|
||||
|
||||
mState = nsIDOMLoadStatus::RECEIVING;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -307,8 +299,6 @@ nsPrefetchNode::OnStopRequest(nsIRequest *aRequest,
|
||||
{
|
||||
LOG(("done prefetching [status=%x]\n", aStatus));
|
||||
|
||||
mState = nsIDOMLoadStatus::LOADED;
|
||||
|
||||
if (mBytesRead == 0 && aStatus == NS_OK) {
|
||||
// we didn't need to read (because LOAD_ONLY_IF_MODIFIED was
|
||||
// specified), but the object should report loadedSize as if it
|
||||
@ -487,7 +477,7 @@ nsPrefetchService::NotifyLoadRequested(nsPrefetchNode *node)
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
|
||||
observerService->NotifyObservers(static_cast<nsIStreamListener*>(node),
|
||||
"prefetch-load-requested", nullptr);
|
||||
}
|
||||
|
||||
@ -499,7 +489,7 @@ nsPrefetchService::NotifyLoadCompleted(nsPrefetchNode *node)
|
||||
if (!observerService)
|
||||
return;
|
||||
|
||||
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
|
||||
observerService->NotifyObservers(static_cast<nsIStreamListener*>(node),
|
||||
"prefetch-load-completed", nullptr);
|
||||
}
|
||||
|
||||
@ -765,84 +755,6 @@ nsPrefetchService::EnumerateQueue(nsISimpleEnumerator **aEnumerator)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsPrefetchNode::nsIDOMLoadStatus
|
||||
//-----------------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetSource(nsIDOMNode **aSource)
|
||||
{
|
||||
*aSource = nullptr;
|
||||
nsCOMPtr<nsIDOMNode> source = do_QueryReferent(mSource);
|
||||
if (source)
|
||||
source.swap(*aSource);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetUri(nsAString &aURI)
|
||||
{
|
||||
nsAutoCString spec;
|
||||
nsresult rv = mURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
CopyUTF8toUTF16(spec, aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetTotalSize(int32_t *aTotalSize)
|
||||
{
|
||||
if (mChannel) {
|
||||
int64_t size64;
|
||||
nsresult rv = mChannel->GetContentLength(&size64);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aTotalSize = int32_t(size64); // XXX - loses precision
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aTotalSize = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetLoadedSize(int32_t *aLoadedSize)
|
||||
{
|
||||
*aLoadedSize = int32_t(mBytesRead); // XXX - loses precision
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetReadyState(uint16_t *aReadyState)
|
||||
{
|
||||
*aReadyState = mState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefetchNode::GetStatus(uint16_t *aStatus)
|
||||
{
|
||||
if (!mChannel) {
|
||||
*aStatus = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t httpStatus;
|
||||
rv = httpChannel->GetResponseStatus(&httpStatus);
|
||||
if (rv == NS_ERROR_NOT_AVAILABLE) {
|
||||
*aStatus = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aStatus = uint16_t(httpStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsPrefetchService::nsIWebProgressListener
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDOMLoadStatus.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
@ -82,15 +81,13 @@ private:
|
||||
// nsPrefetchNode
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class nsPrefetchNode MOZ_FINAL : public nsIDOMLoadStatus
|
||||
, public nsIStreamListener
|
||||
class nsPrefetchNode MOZ_FINAL : public nsIStreamListener
|
||||
, public nsIInterfaceRequestor
|
||||
, public nsIChannelEventSink
|
||||
, public nsIRedirectResultListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMLOADSTATUS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
@ -116,7 +113,6 @@ private:
|
||||
nsRefPtr<nsPrefetchService> mService;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<nsIChannel> mRedirectChannel;
|
||||
uint16_t mState;
|
||||
int64_t mBytesRead;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user