uriloader/prefetch/OfflineCacheUpdateGlue.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/uriloader/prefetch/OfflineCacheUpdateGlue.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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 nsOfflineCacheUpdateGlue_h
    1.10 +#define nsOfflineCacheUpdateGlue_h
    1.11 +
    1.12 +#include "nsIOfflineCacheUpdate.h"
    1.13 +
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsAutoPtr.h"
    1.16 +#include "nsString.h"
    1.17 +#include "nsWeakReference.h"
    1.18 +#include "mozilla/Attributes.h"
    1.19 +
    1.20 +class nsOfflineCacheUpdate;
    1.21 +
    1.22 +namespace mozilla {
    1.23 +namespace docshell {
    1.24 +
    1.25 +// Like FORWARD_SAFE except methods:
    1.26 +//    Schedule
    1.27 +//    Init
    1.28 +#define NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(_to) \
    1.29 +  NS_IMETHOD GetStatus(uint16_t *aStatus) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetStatus(aStatus); } \
    1.30 +  NS_IMETHOD GetPartial(bool *aPartial) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetPartial(aPartial); } \
    1.31 +  NS_IMETHOD GetIsUpgrade(bool *aIsUpgrade) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsUpgrade(aIsUpgrade); } \
    1.32 +  NS_IMETHOD GetUpdateDomain(nsACString & aUpdateDomain) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetUpdateDomain(aUpdateDomain); } \
    1.33 +  NS_IMETHOD GetManifestURI(nsIURI **aManifestURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetManifestURI(aManifestURI); } \
    1.34 +  NS_IMETHOD GetSucceeded(bool *aSucceeded) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetSucceeded(aSucceeded); } \
    1.35 +  NS_IMETHOD InitPartial(nsIURI *aManifestURI, const nsACString & aClientID, nsIURI *aDocumentURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitPartial(aManifestURI, aClientID, aDocumentURI); } \
    1.36 +  NS_IMETHOD InitForUpdateCheck(nsIURI *aManifestURI, uint32_t aAppID, bool aInBrowser, nsIObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->InitForUpdateCheck(aManifestURI, aAppID, aInBrowser, aObserver); } \
    1.37 +  NS_IMETHOD AddDynamicURI(nsIURI *aURI) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddDynamicURI(aURI); } \
    1.38 +  NS_IMETHOD AddObserver(nsIOfflineCacheUpdateObserver *aObserver, bool aHoldWeak) { return !_to ? NS_ERROR_NULL_POINTER : _to->AddObserver(aObserver, aHoldWeak); } \
    1.39 +  NS_IMETHOD RemoveObserver(nsIOfflineCacheUpdateObserver *aObserver) { return !_to ? NS_ERROR_NULL_POINTER : _to->RemoveObserver(aObserver); } \
    1.40 +  NS_IMETHOD GetByteProgress(uint64_t * _result) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetByteProgress(_result); } \
    1.41 +  NS_IMETHOD Cancel() { return !_to ? NS_ERROR_NULL_POINTER : _to->Cancel(); }
    1.42 +
    1.43 +class OfflineCacheUpdateGlue MOZ_FINAL : public nsSupportsWeakReference
    1.44 +                                       , public nsIOfflineCacheUpdate
    1.45 +                                       , public nsIOfflineCacheUpdateObserver
    1.46 +{
    1.47 +public:
    1.48 +    NS_DECL_ISUPPORTS
    1.49 +
    1.50 +private:
    1.51 +    nsIOfflineCacheUpdate* EnsureUpdate();
    1.52 +
    1.53 +public:
    1.54 +    NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
    1.55 +    NS_IMETHOD Schedule(void);
    1.56 +    NS_IMETHOD Init(nsIURI *aManifestURI, 
    1.57 +                    nsIURI *aDocumentURI,
    1.58 +                    nsIDOMDocument *aDocument,
    1.59 +                    nsIFile *aCustomProfileDir,
    1.60 +                    uint32_t aAppID,
    1.61 +                    bool aInBrowser);
    1.62 +
    1.63 +    NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
    1.64 +
    1.65 +    OfflineCacheUpdateGlue();
    1.66 +    ~OfflineCacheUpdateGlue();
    1.67 +
    1.68 +    void SetDocument(nsIDOMDocument *aDocument);
    1.69 +
    1.70 +private:
    1.71 +    nsRefPtr<nsOfflineCacheUpdate> mUpdate;
    1.72 +
    1.73 +    /* Document that requested this update */
    1.74 +    nsCOMPtr<nsIDOMDocument> mDocument;
    1.75 +    nsCOMPtr<nsIURI> mDocumentURI;
    1.76 +};
    1.77 +
    1.78 +}
    1.79 +}
    1.80 +
    1.81 +#endif

mercurial