ServiceWorkerScriptCache.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_workers_ServiceWorkerScriptCache_h
  6. #define mozilla_dom_workers_ServiceWorkerScriptCache_h
  7. #include "nsString.h"
  8. class nsILoadGroup;
  9. class nsIPrincipal;
  10. namespace mozilla {
  11. namespace dom {
  12. namespace workers {
  13. class ServiceWorkerRegistrationInfo;
  14. namespace serviceWorkerScriptCache {
  15. nsresult
  16. PurgeCache(nsIPrincipal* aPrincipal, const nsAString& aCacheName);
  17. nsresult
  18. GenerateCacheName(nsAString& aName);
  19. class CompareCallback
  20. {
  21. public:
  22. /*
  23. * If there is an error, ignore aInCacheAndEqual and aNewCacheName.
  24. * On success, if the cached result and network result matched,
  25. * aInCacheAndEqual will be true and no new cache name is passed, otherwise
  26. * use the new cache name to load the ServiceWorker.
  27. */
  28. virtual void
  29. ComparisonResult(nsresult aStatus,
  30. bool aInCacheAndEqual,
  31. const nsAString& aNewCacheName,
  32. const nsACString& aMaxScope) = 0;
  33. NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
  34. NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
  35. };
  36. nsresult
  37. Compare(ServiceWorkerRegistrationInfo* aRegistration,
  38. nsIPrincipal* aPrincipal, const nsAString& aCacheName,
  39. const nsAString& aURL, CompareCallback* aCallback, nsILoadGroup* aLoadGroup);
  40. } // namespace serviceWorkerScriptCache
  41. } // namespace workers
  42. } // namespace dom
  43. } // namespace mozilla
  44. #endif // mozilla_dom_workers_ServiceWorkerScriptCache_h