1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/uriloader/prefetch/OfflineCacheUpdateChild.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsOfflineCacheUpdateChild_h 1.10 +#define nsOfflineCacheUpdateChild_h 1.11 + 1.12 +#include "mozilla/docshell/POfflineCacheUpdateChild.h" 1.13 +#include "nsIOfflineCacheUpdate.h" 1.14 + 1.15 +#include "nsCOMArray.h" 1.16 +#include "nsCOMPtr.h" 1.17 +#include "nsICacheService.h" 1.18 +#include "nsIDOMDocument.h" 1.19 +#include "nsIObserver.h" 1.20 +#include "nsIObserverService.h" 1.21 +#include "nsIURI.h" 1.22 +#include "nsString.h" 1.23 +#include "nsWeakReference.h" 1.24 + 1.25 +namespace mozilla { 1.26 +namespace docshell { 1.27 + 1.28 +class OfflineCacheUpdateChild : public nsIOfflineCacheUpdate 1.29 + , public POfflineCacheUpdateChild 1.30 +{ 1.31 +public: 1.32 + NS_DECL_ISUPPORTS 1.33 + NS_DECL_NSIOFFLINECACHEUPDATE 1.34 + 1.35 + virtual bool 1.36 + RecvNotifyStateEvent(const uint32_t& stateEvent, 1.37 + const uint64_t& byteProgress) MOZ_OVERRIDE; 1.38 + 1.39 + virtual bool 1.40 + RecvAssociateDocuments( 1.41 + const nsCString& cacheGroupId, 1.42 + const nsCString& cacheClientId) MOZ_OVERRIDE; 1.43 + 1.44 + virtual bool 1.45 + RecvFinish(const bool& succeeded, 1.46 + const bool& isUpgrade) MOZ_OVERRIDE; 1.47 + 1.48 + OfflineCacheUpdateChild(nsIDOMWindow* aWindow); 1.49 + ~OfflineCacheUpdateChild(); 1.50 + 1.51 + void SetDocument(nsIDOMDocument *aDocument); 1.52 + 1.53 +private: 1.54 + nsresult AssociateDocument(nsIDOMDocument *aDocument, 1.55 + nsIApplicationCache *aApplicationCache); 1.56 + void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers); 1.57 + nsresult Finish(); 1.58 + 1.59 + enum { 1.60 + STATE_UNINITIALIZED, 1.61 + STATE_INITIALIZED, 1.62 + STATE_CHECKING, 1.63 + STATE_DOWNLOADING, 1.64 + STATE_CANCELLED, 1.65 + STATE_FINISHED 1.66 + } mState; 1.67 + 1.68 + bool mIsUpgrade; 1.69 + bool mSucceeded; 1.70 + 1.71 + nsCString mUpdateDomain; 1.72 + nsCOMPtr<nsIURI> mManifestURI; 1.73 + nsCOMPtr<nsIURI> mDocumentURI; 1.74 + 1.75 + nsCOMPtr<nsIObserverService> mObserverService; 1.76 + 1.77 + uint32_t mAppID; 1.78 + bool mInBrowser; 1.79 + 1.80 + /* Clients watching this update for changes */ 1.81 + nsCOMArray<nsIWeakReference> mWeakObservers; 1.82 + nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers; 1.83 + 1.84 + /* Document that requested this update */ 1.85 + nsCOMPtr<nsIDOMDocument> mDocument; 1.86 + 1.87 + /* Keep reference to the window that owns this update to call the 1.88 + parent offline cache update construcor */ 1.89 + nsCOMPtr<nsIDOMWindow> mWindow; 1.90 + 1.91 + uint64_t mByteProgress; 1.92 +}; 1.93 + 1.94 +} 1.95 +} 1.96 + 1.97 +#endif