2007-07-25 09:35:39 +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/. */
|
2007-07-25 09:35:39 +04:00
|
|
|
|
|
|
|
#ifndef nsOfflineCacheUpdate_h__
|
|
|
|
#define nsOfflineCacheUpdate_h__
|
|
|
|
|
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIChannelEventSink.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2008-09-30 22:34:23 +04:00
|
|
|
#include "nsIMutableArray.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIObserverService.h"
|
2008-08-27 03:09:02 +04:00
|
|
|
#include "nsIApplicationCache.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
#include "nsIRequestObserver.h"
|
2007-07-25 10:31:27 +04:00
|
|
|
#include "nsIRunnable.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsIWebProgressListener.h"
|
2008-01-17 00:54:33 +03:00
|
|
|
#include "nsClassHashtable.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWeakReference.h"
|
2008-01-29 10:54:54 +03:00
|
|
|
#include "nsICryptoHash.h"
|
2012-06-13 07:53:09 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-02-06 18:16:41 +04:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2013-11-20 02:15:59 +04:00
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2007-07-25 09:35:39 +04:00
|
|
|
|
|
|
|
class nsOfflineCacheUpdate;
|
|
|
|
|
2013-12-18 19:11:54 +04:00
|
|
|
class nsOfflineCacheUpdateItem : public nsIStreamListener
|
2007-07-25 10:31:27 +04:00
|
|
|
, public nsIRunnable
|
2007-07-25 09:35:39 +04:00
|
|
|
, public nsIInterfaceRequestor
|
|
|
|
, public nsIChannelEventSink
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2007-07-25 10:31:27 +04:00
|
|
|
NS_DECL_NSIRUNNABLE
|
2007-07-25 09:35:39 +04:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_NSICHANNELEVENTSINK
|
|
|
|
|
2012-06-04 18:12:23 +04:00
|
|
|
nsOfflineCacheUpdateItem(nsIURI *aURI,
|
2007-07-25 09:35:39 +04:00
|
|
|
nsIURI *aReferrerURI,
|
2015-10-02 19:13:52 +03:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2012-06-04 18:12:24 +04:00
|
|
|
nsIApplicationCache *aApplicationCache,
|
2008-08-27 03:09:02 +04:00
|
|
|
nsIApplicationCache *aPreviousApplicationCache,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aType);
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2015-10-02 19:13:52 +03:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
nsCOMPtr<nsIURI> mReferrerURI;
|
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
2012-06-04 18:12:24 +04:00
|
|
|
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
2008-08-27 03:09:02 +04:00
|
|
|
nsCOMPtr<nsIApplicationCache> mPreviousApplicationCache;
|
2015-10-02 19:13:52 +03:00
|
|
|
nsCString mCacheKey;
|
|
|
|
uint32_t mItemType;
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2012-06-04 18:12:23 +04:00
|
|
|
nsresult OpenChannel(nsOfflineCacheUpdate *aUpdate);
|
2007-07-25 09:35:39 +04:00
|
|
|
nsresult Cancel();
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult GetRequestSucceeded(bool * succeeded);
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2012-06-04 18:12:23 +04:00
|
|
|
bool IsInProgress();
|
|
|
|
bool IsScheduled();
|
|
|
|
bool IsCompleted();
|
|
|
|
|
2013-12-18 19:11:54 +04:00
|
|
|
nsresult GetStatus(uint16_t *aStatus);
|
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
private:
|
2015-01-21 16:35:19 +03:00
|
|
|
enum LoadStatus : uint16_t {
|
2013-12-18 19:11:54 +04:00
|
|
|
UNINITIALIZED = 0U,
|
|
|
|
REQUESTED = 1U,
|
|
|
|
RECEIVING = 2U,
|
|
|
|
LOADED = 3U
|
|
|
|
};
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsOfflineCacheUpdate> mUpdate;
|
2007-07-25 09:35:39 +04:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mState;
|
2008-01-17 00:54:33 +03:00
|
|
|
|
|
|
|
protected:
|
2014-06-23 22:49:09 +04:00
|
|
|
virtual ~nsOfflineCacheUpdateItem();
|
|
|
|
|
2012-10-22 21:51:07 +04:00
|
|
|
int64_t mBytesRead;
|
2007-07-25 09:35:39 +04:00
|
|
|
};
|
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
|
|
|
|
class nsOfflineManifestItem : public nsOfflineCacheUpdateItem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
|
2012-06-04 18:12:23 +04:00
|
|
|
nsOfflineManifestItem(nsIURI *aURI,
|
2008-01-17 00:54:33 +03:00
|
|
|
nsIURI *aReferrerURI,
|
2015-10-02 19:13:52 +03:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2012-06-04 18:12:24 +04:00
|
|
|
nsIApplicationCache *aApplicationCache,
|
2012-07-11 22:20:17 +04:00
|
|
|
nsIApplicationCache *aPreviousApplicationCache);
|
2008-01-17 00:54:33 +03:00
|
|
|
virtual ~nsOfflineManifestItem();
|
|
|
|
|
|
|
|
nsCOMArray<nsIURI> &GetExplicitURIs() { return mExplicitURIs; }
|
2008-09-30 22:34:23 +04:00
|
|
|
nsCOMArray<nsIURI> &GetFallbackURIs() { return mFallbackURIs; }
|
|
|
|
|
|
|
|
nsTArray<nsCString> &GetOpportunisticNamespaces()
|
|
|
|
{ return mOpportunisticNamespaces; }
|
|
|
|
nsIArray *GetNamespaces()
|
|
|
|
{ return mNamespaces.get(); }
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ParseSucceeded()
|
2008-01-17 00:54:33 +03:00
|
|
|
{ return (mParserState != PARSE_INIT && mParserState != PARSE_ERROR); }
|
2011-09-29 10:19:26 +04:00
|
|
|
bool NeedsUpdate() { return mParserState != PARSE_INIT && mNeedsUpdate; }
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2008-11-06 03:01:07 +03:00
|
|
|
void GetManifestHash(nsCString &aManifestHash)
|
|
|
|
{ aManifestHash = mManifestHashValue; }
|
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
private:
|
|
|
|
static NS_METHOD ReadManifest(nsIInputStream *aInputStream,
|
|
|
|
void *aClosure,
|
|
|
|
const char *aFromSegment,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aOffset,
|
|
|
|
uint32_t aCount,
|
|
|
|
uint32_t *aBytesConsumed);
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult AddNamespace(uint32_t namespaceType,
|
2008-09-30 22:34:23 +04:00
|
|
|
const nsCString &namespaceSpec,
|
|
|
|
const nsCString &data);
|
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
nsresult HandleManifestLine(const nsCString::const_iterator &aBegin,
|
|
|
|
const nsCString::const_iterator &aEnd);
|
|
|
|
|
2008-01-29 10:54:54 +03:00
|
|
|
/**
|
|
|
|
* Saves "offline-manifest-hash" meta data from the old offline cache
|
|
|
|
* token to mOldManifestHashValue member to be compared on
|
|
|
|
* successfull load.
|
|
|
|
*/
|
|
|
|
nsresult GetOldManifestContentHash(nsIRequest *aRequest);
|
|
|
|
/**
|
2011-10-17 18:59:28 +04:00
|
|
|
* This method setups the mNeedsUpdate to false when hash value
|
2008-01-29 10:54:54 +03:00
|
|
|
* of the just downloaded manifest file is the same as stored in cache's
|
|
|
|
* "offline-manifest-hash" meta data. Otherwise stores the new value
|
|
|
|
* to this meta data.
|
|
|
|
*/
|
|
|
|
nsresult CheckNewManifestContentHash(nsIRequest *aRequest);
|
|
|
|
|
2008-09-30 22:34:23 +04:00
|
|
|
void ReadStrictFileOriginPolicyPref();
|
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
enum {
|
|
|
|
PARSE_INIT,
|
|
|
|
PARSE_CACHE_ENTRIES,
|
|
|
|
PARSE_FALLBACK_ENTRIES,
|
2008-09-30 22:34:23 +04:00
|
|
|
PARSE_BYPASS_ENTRIES,
|
2012-07-14 13:52:35 +04:00
|
|
|
PARSE_UNKNOWN_SECTION,
|
2008-01-17 00:54:33 +03:00
|
|
|
PARSE_ERROR
|
|
|
|
} mParserState;
|
|
|
|
|
|
|
|
nsCString mReadBuf;
|
2008-09-30 22:34:23 +04:00
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
nsCOMArray<nsIURI> mExplicitURIs;
|
2008-09-30 22:34:23 +04:00
|
|
|
nsCOMArray<nsIURI> mFallbackURIs;
|
|
|
|
|
|
|
|
// All opportunistic caching namespaces. Used to decide whether
|
|
|
|
// to include previously-opportunistically-cached entries.
|
|
|
|
nsTArray<nsCString> mOpportunisticNamespaces;
|
|
|
|
|
|
|
|
// Array of nsIApplicationCacheNamespace objects specified by the
|
|
|
|
// manifest.
|
|
|
|
nsCOMPtr<nsIMutableArray> mNamespaces;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mNeedsUpdate;
|
|
|
|
bool mStrictFileOriginPolicy;
|
2008-01-29 10:54:54 +03:00
|
|
|
|
|
|
|
// manifest hash data
|
|
|
|
nsCOMPtr<nsICryptoHash> mManifestHash;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mManifestHashInitialized;
|
2008-11-06 03:01:07 +03:00
|
|
|
nsCString mManifestHashValue;
|
2008-01-29 10:54:54 +03:00
|
|
|
nsCString mOldManifestHashValue;
|
2008-01-17 00:54:33 +03:00
|
|
|
};
|
|
|
|
|
2009-02-22 22:09:10 +03:00
|
|
|
class nsOfflineCacheUpdateOwner
|
2014-02-06 18:16:41 +04:00
|
|
|
: public mozilla::SupportsWeakPtr<nsOfflineCacheUpdateOwner>
|
2009-02-22 22:09:10 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-04-24 19:43:01 +03:00
|
|
|
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsOfflineCacheUpdateOwner)
|
2014-02-06 18:16:41 +04:00
|
|
|
virtual ~nsOfflineCacheUpdateOwner() {}
|
2009-02-22 22:09:10 +03:00
|
|
|
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) = 0;
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsOfflineCacheUpdate final : public nsIOfflineCacheUpdate
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsIOfflineCacheUpdateObserver
|
|
|
|
, public nsIRunnable
|
|
|
|
, public nsOfflineCacheUpdateOwner
|
2007-07-25 09:35:39 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATE
|
2010-10-20 21:12:32 +04:00
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
|
2012-06-04 18:12:23 +04:00
|
|
|
NS_DECL_NSIRUNNABLE
|
2007-07-25 09:35:39 +04:00
|
|
|
|
|
|
|
nsOfflineCacheUpdate();
|
|
|
|
|
2008-08-27 03:09:02 +04:00
|
|
|
static nsresult GetCacheKey(nsIURI *aURI, nsACString &aKey);
|
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
nsresult Begin();
|
|
|
|
|
2012-06-04 18:12:23 +04:00
|
|
|
void LoadCompleted(nsOfflineCacheUpdateItem *aItem);
|
2008-11-06 03:01:07 +03:00
|
|
|
void ManifestCheckCompleted(nsresult aStatus,
|
|
|
|
const nsCString &aManifestHash);
|
2010-10-20 21:12:32 +04:00
|
|
|
void StickDocument(nsIURI *aDocumentURI);
|
2008-11-04 13:20:27 +03:00
|
|
|
|
2009-02-22 22:09:10 +03:00
|
|
|
void SetOwner(nsOfflineCacheUpdateOwner *aOwner);
|
|
|
|
|
2012-07-31 10:36:00 +04:00
|
|
|
bool IsForGroupID(const nsCSubstring &groupID);
|
2014-07-16 18:16:30 +04:00
|
|
|
bool IsForProfile(nsIFile* aCustomProfileDir);
|
2012-07-31 10:36:00 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) override;
|
2009-02-22 22:09:10 +03:00
|
|
|
|
2012-05-23 00:12:40 +04:00
|
|
|
protected:
|
2014-06-23 22:49:09 +04:00
|
|
|
~nsOfflineCacheUpdate();
|
|
|
|
|
2012-05-23 00:12:40 +04:00
|
|
|
friend class nsOfflineCacheUpdateItem;
|
2012-08-22 19:56:38 +04:00
|
|
|
void OnByteProgress(uint64_t byteIncrement);
|
2012-05-23 00:12:40 +04:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
private:
|
2015-10-02 19:13:52 +03:00
|
|
|
nsresult InitInternal(nsIURI *aManifestURI, nsIPrincipal* aPrincipal);
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult HandleManifest(bool *aDoUpdate);
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult AddURI(nsIURI *aURI, uint32_t aItemType);
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
nsresult ProcessNextURI();
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2008-09-30 22:34:23 +04:00
|
|
|
// Adds items from the previous cache witha type matching aType.
|
|
|
|
// If namespaceFilter is non-null, only items matching the
|
|
|
|
// specified namespaces will be added.
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult AddExistingItems(uint32_t aType,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTArray<nsCString>* namespaceFilter = nullptr);
|
2010-10-20 21:12:32 +04:00
|
|
|
nsresult ScheduleImplicit();
|
2012-08-14 13:10:42 +04:00
|
|
|
void AssociateDocuments(nsIApplicationCache* cache);
|
2012-10-02 17:55:00 +04:00
|
|
|
bool CheckUpdateAvailability();
|
|
|
|
void NotifyUpdateAvailability(bool updateAvailable);
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2012-08-14 13:10:42 +04:00
|
|
|
void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers);
|
|
|
|
void NotifyState(uint32_t state);
|
2007-07-25 09:35:39 +04:00
|
|
|
nsresult Finish();
|
2010-10-20 21:12:32 +04:00
|
|
|
nsresult FinishNoNotify();
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2013-05-10 18:16:56 +04:00
|
|
|
void AsyncFinishWithError();
|
|
|
|
|
2012-03-31 04:52:06 +04:00
|
|
|
// Find one non-pinned cache group and evict it.
|
2012-04-01 02:18:08 +04:00
|
|
|
nsresult EvictOneNonPinned();
|
2012-03-31 04:52:06 +04:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
enum {
|
|
|
|
STATE_UNINITIALIZED,
|
|
|
|
STATE_INITIALIZED,
|
2008-01-17 00:54:33 +03:00
|
|
|
STATE_CHECKING,
|
|
|
|
STATE_DOWNLOADING,
|
2007-07-25 09:35:39 +04:00
|
|
|
STATE_CANCELLED,
|
|
|
|
STATE_FINISHED
|
|
|
|
} mState;
|
|
|
|
|
2014-02-06 18:16:41 +04:00
|
|
|
mozilla::WeakPtr<nsOfflineCacheUpdateOwner> mOwner;
|
2009-02-22 22:09:10 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mAddedItems;
|
|
|
|
bool mPartialUpdate;
|
2012-10-02 17:55:00 +04:00
|
|
|
bool mOnlyCheckUpdate;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mSucceeded;
|
|
|
|
bool mObsolete;
|
2008-11-04 21:59:12 +03:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
nsCString mUpdateDomain;
|
2012-07-31 10:36:00 +04:00
|
|
|
nsCString mGroupID;
|
2008-01-17 00:54:33 +03:00
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2015-10-02 19:13:52 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
2012-06-06 06:08:30 +04:00
|
|
|
nsCOMPtr<nsIFile> mCustomProfileDir;
|
2012-10-26 15:02:47 +04:00
|
|
|
|
2012-10-02 17:55:00 +04:00
|
|
|
nsCOMPtr<nsIObserver> mUpdateAvailableObserver;
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2008-08-27 03:09:02 +04:00
|
|
|
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
|
|
|
nsCOMPtr<nsIApplicationCache> mPreviousApplicationCache;
|
2007-07-25 10:31:27 +04:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
nsCOMPtr<nsIObserverService> mObserverService;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsOfflineManifestItem> mManifestItem;
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
/* Items being updated */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mItemsInProgress;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsOfflineCacheUpdateItem> > mItems;
|
2007-07-25 09:35:39 +04:00
|
|
|
|
|
|
|
/* Clients watching this update for changes */
|
|
|
|
nsCOMArray<nsIWeakReference> mWeakObservers;
|
|
|
|
nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers;
|
2008-11-04 13:20:27 +03:00
|
|
|
|
|
|
|
/* Documents that requested this update */
|
2010-10-20 21:12:32 +04:00
|
|
|
nsCOMArray<nsIURI> mDocumentURIs;
|
2008-11-06 03:01:07 +03:00
|
|
|
|
|
|
|
/* Reschedule count. When an update is rescheduled due to
|
|
|
|
* mismatched manifests, the reschedule count will be increased. */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mRescheduleCount;
|
2009-02-22 22:09:10 +03:00
|
|
|
|
2012-03-31 04:52:06 +04:00
|
|
|
/* Whena an entry for a pinned app is retried, retries count is
|
|
|
|
* increaded. */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mPinnedEntryRetriesCount;
|
2012-03-31 04:52:06 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsOfflineCacheUpdate> mImplicitUpdate;
|
2012-03-31 04:52:06 +04:00
|
|
|
|
|
|
|
bool mPinned;
|
2012-05-23 00:12:40 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t mByteProgress;
|
2007-07-25 09:35:39 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsOfflineCacheUpdateService final : public nsIOfflineCacheUpdateService
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsIObserver
|
|
|
|
, public nsOfflineCacheUpdateOwner
|
|
|
|
, public nsSupportsWeakReference
|
2007-07-25 09:35:39 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATESERVICE
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsOfflineCacheUpdateService();
|
|
|
|
|
|
|
|
nsresult Init();
|
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
nsresult ScheduleUpdate(nsOfflineCacheUpdate *aUpdate);
|
|
|
|
nsresult FindUpdate(nsIURI *aManifestURI,
|
2016-01-18 22:20:08 +03:00
|
|
|
nsACString const &aOriginSuffix,
|
2014-07-16 18:16:30 +04:00
|
|
|
nsIFile *aCustomProfileDir,
|
2010-10-20 21:12:32 +04:00
|
|
|
nsOfflineCacheUpdate **aUpdate);
|
|
|
|
|
2008-11-04 13:20:27 +03:00
|
|
|
nsresult Schedule(nsIURI *aManifestURI,
|
|
|
|
nsIURI *aDocumentURI,
|
2015-10-02 19:13:52 +03:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2008-11-04 13:20:27 +03:00
|
|
|
nsIDOMDocument *aDocument,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* aWindow,
|
2012-06-06 06:08:30 +04:00
|
|
|
nsIFile* aCustomProfileDir,
|
2008-11-04 13:20:27 +03:00
|
|
|
nsIOfflineCacheUpdate **aUpdate);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) override;
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2007-11-09 08:12:59 +03:00
|
|
|
/**
|
|
|
|
* Returns the singleton nsOfflineCacheUpdateService without an addref, or
|
2012-07-30 18:20:58 +04:00
|
|
|
* nullptr if the service couldn't be created.
|
2007-11-09 08:12:59 +03:00
|
|
|
*/
|
|
|
|
static nsOfflineCacheUpdateService *EnsureService();
|
2007-07-25 09:35:39 +04:00
|
|
|
|
2007-11-09 08:12:59 +03:00
|
|
|
/** Addrefs and returns the singleton nsOfflineCacheUpdateService. */
|
|
|
|
static nsOfflineCacheUpdateService *GetInstance();
|
2008-11-04 13:20:27 +03:00
|
|
|
|
2012-03-31 04:52:06 +04:00
|
|
|
static nsresult OfflineAppPinnedForURI(nsIURI *aDocumentURI,
|
|
|
|
nsIPrefBranch *aPrefBranch,
|
|
|
|
bool *aPinned);
|
|
|
|
|
2013-11-20 02:15:59 +04:00
|
|
|
static nsTHashtable<nsCStringHashKey>* AllowedDomains();
|
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
private:
|
2014-06-23 22:49:09 +04:00
|
|
|
~nsOfflineCacheUpdateService();
|
|
|
|
|
2007-07-25 09:35:39 +04:00
|
|
|
nsresult ProcessNextUpdate();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsOfflineCacheUpdate> > mUpdates;
|
2013-11-20 02:15:59 +04:00
|
|
|
static nsTHashtable<nsCStringHashKey>* mAllowedDomains;
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mDisabled;
|
|
|
|
bool mUpdateRunning;
|
2013-05-10 18:16:56 +04:00
|
|
|
bool mLowFreeSpace;
|
2007-07-25 09:35:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|