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 "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,
|
2015-03-21 19:28:04 +03:00
|
|
|
const uint64_t& byteProgress) override;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
RecvAssociateDocuments(
|
|
|
|
const nsCString& cacheGroupId,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsCString& cacheClientId) override;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
virtual bool
|
2014-01-16 00:20:33 +04:00
|
|
|
RecvFinish(const bool& succeeded,
|
2015-03-21 19:28:04 +03:00
|
|
|
const bool& isUpgrade) override;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
2014-09-03 16:10:55 +04:00
|
|
|
explicit OfflineCacheUpdateChild(nsIDOMWindow* aWindow);
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
void SetDocument(nsIDOMDocument *aDocument);
|
|
|
|
|
|
|
|
private:
|
2014-06-23 22:49:09 +04:00
|
|
|
~OfflineCacheUpdateChild();
|
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
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();
|
|
|
|
|
|
|
|
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;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
nsCString mUpdateDomain;
|
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2015-10-02 19:13:52 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace docshell
|
|
|
|
} // namespace mozilla
|
2010-10-20 21:12:32 +04:00
|
|
|
|
|
|
|
#endif
|