2010-10-20 21:12:32 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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/. */
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
#ifndef nsOfflineCacheUpdateChild_h
|
|
|
|
#define nsOfflineCacheUpdateChild_h
|
|
|
|
|
|
|
|
#include "mozilla/docshell/POfflineCacheUpdateChild.h"
|
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
|
|
|
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsICacheService.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace docshell {
|
|
|
|
|
|
|
|
class OfflineCacheUpdateChild : public nsIOfflineCacheUpdate
|
2012-05-23 00:12:40 +04:00
|
|
|
, public POfflineCacheUpdateChild
|
2010-10-20 21:12:32 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATE
|
|
|
|
|
|
|
|
virtual bool
|
2012-08-22 19:56:38 +04:00
|
|
|
RecvNotifyStateEvent(const uint32_t& stateEvent,
|
|
|
|
const uint64_t& byteProgress);
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvAssociateDocuments(
|
|
|
|
const nsCString& cacheGroupId,
|
|
|
|
const nsCString& cacheClientId);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvFinish(const bool& succeded,
|
|
|
|
const bool& isUpgrade);
|
|
|
|
|
|
|
|
OfflineCacheUpdateChild(nsIDOMWindow* aWindow);
|
|
|
|
~OfflineCacheUpdateChild();
|
|
|
|
|
|
|
|
void SetDocument(nsIDOMDocument *aDocument);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult AssociateDocument(nsIDOMDocument *aDocument,
|
|
|
|
nsIApplicationCache *aApplicationCache);
|
2012-08-14 13:10:42 +04:00
|
|
|
void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers);
|
2010-10-20 21:12:32 +04:00
|
|
|
nsresult Finish();
|
|
|
|
|
|
|
|
void RefcountHitZero();
|
|
|
|
|
|
|
|
enum {
|
|
|
|
STATE_UNINITIALIZED,
|
|
|
|
STATE_INITIALIZED,
|
|
|
|
STATE_CHECKING,
|
|
|
|
STATE_DOWNLOADING,
|
|
|
|
STATE_CANCELLED,
|
|
|
|
STATE_FINISHED
|
|
|
|
} mState;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsUpgrade;
|
|
|
|
bool mSucceeded;
|
|
|
|
bool mIPCActivated;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
nsCString mUpdateDomain;
|
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> mObserverService;
|
2012-10-26 15:02:47 +04:00
|
|
|
|
|
|
|
uint32_t mAppID;
|
|
|
|
bool mInBrowser;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
/* Clients watching this update for changes */
|
|
|
|
nsCOMArray<nsIWeakReference> mWeakObservers;
|
|
|
|
nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers;
|
|
|
|
|
|
|
|
/* Document that requested this update */
|
|
|
|
nsCOMPtr<nsIDOMDocument> mDocument;
|
|
|
|
|
|
|
|
/* Keep reference to the window that owns this update to call the
|
|
|
|
parent offline cache update construcor */
|
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2012-05-23 00:12:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mByteProgress;
|
2010-10-20 21:12:32 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|