WebResourceLoadScheduler.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2012 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef WebResourceLoadScheduler_h
  26. #define WebResourceLoadScheduler_h
  27. #include "WebResourceLoader.h"
  28. #include <WebCore/ResourceLoadPriority.h>
  29. #include <WebCore/ResourceLoadScheduler.h>
  30. #include <WebCore/ResourceLoader.h>
  31. #include <WebCore/RunLoop.h>
  32. #if ENABLE(NETWORK_PROCESS)
  33. namespace WebKit {
  34. class NetworkProcessConnection;
  35. typedef uint64_t ResourceLoadIdentifier;
  36. class WebResourceLoadScheduler : public WebCore::ResourceLoadScheduler {
  37. WTF_MAKE_NONCOPYABLE(WebResourceLoadScheduler); WTF_MAKE_FAST_ALLOCATED;
  38. public:
  39. WebResourceLoadScheduler();
  40. virtual ~WebResourceLoadScheduler();
  41. virtual PassRefPtr<WebCore::SubresourceLoader> scheduleSubresourceLoad(WebCore::Frame*, WebCore::CachedResource*, const WebCore::ResourceRequest&, WebCore::ResourceLoadPriority, const WebCore::ResourceLoaderOptions&) OVERRIDE;
  42. virtual PassRefPtr<WebCore::NetscapePlugInStreamLoader> schedulePluginStreamLoad(WebCore::Frame*, WebCore::NetscapePlugInStreamLoaderClient*, const WebCore::ResourceRequest&) OVERRIDE;
  43. virtual void remove(WebCore::ResourceLoader*) OVERRIDE;
  44. virtual void crossOriginRedirectReceived(WebCore::ResourceLoader*, const WebCore::KURL& redirectURL) OVERRIDE;
  45. virtual void servePendingRequests(WebCore::ResourceLoadPriority minimumPriority = WebCore::ResourceLoadPriorityVeryLow) OVERRIDE;
  46. virtual void suspendPendingRequests() OVERRIDE;
  47. virtual void resumePendingRequests() OVERRIDE;
  48. virtual void setSerialLoadingEnabled(bool) OVERRIDE;
  49. WebResourceLoader* webResourceLoaderForIdentifier(ResourceLoadIdentifier identifier) const { return m_webResourceLoaders.get(identifier); }
  50. void networkProcessCrashed();
  51. private:
  52. void scheduleLoad(WebCore::ResourceLoader*, WebCore::CachedResource*, WebCore::ResourceLoadPriority, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
  53. void scheduleInternallyFailedLoad(WebCore::ResourceLoader*);
  54. void internallyFailedLoadTimerFired();
  55. HashSet<RefPtr<WebCore::ResourceLoader>> m_internallyFailedResourceLoaders;
  56. WebCore::RunLoop::Timer<WebResourceLoadScheduler> m_internallyFailedLoadTimer;
  57. HashMap<unsigned long, RefPtr<WebResourceLoader>> m_webResourceLoaders;
  58. unsigned m_suspendPendingRequestsCount;
  59. };
  60. } // namespace WebKit
  61. #endif // ENABLE(NETWORK_PROCESS)
  62. #endif // WebResourceLoadScheduler_h