| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "core/loader/DocumentLoader.h" | 44 #include "core/loader/DocumentLoader.h" |
| 45 #include "core/loader/FrameLoader.h" | 45 #include "core/loader/FrameLoader.h" |
| 46 #include "core/loader/appcache/ApplicationCache.h" | 46 #include "core/loader/appcache/ApplicationCache.h" |
| 47 #include "core/page/FrameTree.h" | 47 #include "core/page/FrameTree.h" |
| 48 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
| 49 #include "platform/exported/WrappedResourceRequest.h" | 49 #include "platform/exported/WrappedResourceRequest.h" |
| 50 #include "platform/exported/WrappedResourceResponse.h" | 50 #include "platform/exported/WrappedResourceResponse.h" |
| 51 #include "platform/weborigin/SecurityOrigin.h" | 51 #include "platform/weborigin/SecurityOrigin.h" |
| 52 #include "public/platform/WebURL.h" | 52 #include "public/platform/WebURL.h" |
| 53 #include "public/platform/WebURLError.h" | 53 #include "public/platform/WebURLError.h" |
| 54 #include "public/platform/WebURLRequest.h" |
| 54 #include "public/platform/WebURLResponse.h" | 55 #include "public/platform/WebURLResponse.h" |
| 55 #include "public/platform/WebVector.h" | 56 #include "public/platform/WebVector.h" |
| 56 | 57 |
| 57 namespace blink { | 58 namespace blink { |
| 58 | 59 |
| 59 // We provide a custom implementation of this class that calls out to the | 60 // We provide a custom implementation of this class that calls out to the |
| 60 // embedding application instead of using WebCore's built in appcache system. | 61 // embedding application instead of using WebCore's built in appcache system. |
| 61 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. | 62 // This file replaces webcore/appcache/ApplicationCacheHost.cpp in our build. |
| 62 | 63 |
| 63 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) | 64 ApplicationCacheHost::ApplicationCacheHost(DocumentLoader* documentLoader) |
| 64 : m_domApplicationCache(nullptr), | 65 : m_domApplicationCache(nullptr), |
| 65 m_documentLoader(documentLoader), | 66 m_documentLoader(documentLoader), |
| 66 m_defersEvents(true) { | 67 m_defersEvents(true) { |
| 67 DCHECK(m_documentLoader); | 68 DCHECK(m_documentLoader); |
| 68 } | 69 } |
| 69 | 70 |
| 70 ApplicationCacheHost::~ApplicationCacheHost() { | 71 ApplicationCacheHost::~ApplicationCacheHost() { |
| 71 // Verify that detachFromDocumentLoader() has been performed already. | 72 // Verify that detachFromDocumentLoader() has been performed already. |
| 72 DCHECK(!m_host); | 73 DCHECK(!m_host); |
| 73 } | 74 } |
| 74 | 75 |
| 76 void ApplicationCacheHost::willStartLoading(ResourceRequest& request) { |
| 77 if (!isApplicationCacheEnabled()) |
| 78 return; |
| 79 |
| 80 if (request.frameType() == WebURLRequest::FrameTypeTopLevel || |
| 81 request.frameType() == WebURLRequest::FrameTypeNested) { |
| 82 willStartLoadingMainResource(request); |
| 83 } else { |
| 84 willStartLoadingResource(request); |
| 85 } |
| 86 } |
| 87 |
| 75 void ApplicationCacheHost::willStartLoadingMainResource( | 88 void ApplicationCacheHost::willStartLoadingMainResource( |
| 76 ResourceRequest& request) { | 89 ResourceRequest& request) { |
| 77 // We defer creating the outer host object to avoid spurious | 90 // We defer creating the outer host object to avoid spurious |
| 78 // creation/destruction around creating empty documents. At this point, we're | 91 // creation/destruction around creating empty documents. At this point, we're |
| 79 // initiating a main resource load for the document, so its for real. | 92 // initiating a main resource load for the document, so its for real. |
| 80 | 93 |
| 81 if (!isApplicationCacheEnabled()) | 94 DCHECK(isApplicationCacheEnabled()); |
| 82 return; | |
| 83 | 95 |
| 84 DCHECK(m_documentLoader->frame()); | 96 DCHECK(m_documentLoader->frame()); |
| 85 LocalFrame& frame = *m_documentLoader->frame(); | 97 LocalFrame& frame = *m_documentLoader->frame(); |
| 86 m_host = frame.loader().client()->createApplicationCacheHost(this); | 98 m_host = frame.loader().client()->createApplicationCacheHost(this); |
| 87 if (!m_host) | 99 if (!m_host) |
| 88 return; | 100 return; |
| 89 | 101 |
| 90 WrappedResourceRequest wrapped(request); | 102 WrappedResourceRequest wrapped(request); |
| 91 | 103 |
| 92 const WebApplicationCacheHost* spawningHost = nullptr; | 104 const WebApplicationCacheHost* spawningHost = nullptr; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 notifyApplicationCache(kErrorEvent, 0, 0, reason, url.string(), status, | 345 notifyApplicationCache(kErrorEvent, 0, 0, reason, url.string(), status, |
| 334 message); | 346 message); |
| 335 } | 347 } |
| 336 | 348 |
| 337 DEFINE_TRACE(ApplicationCacheHost) { | 349 DEFINE_TRACE(ApplicationCacheHost) { |
| 338 visitor->trace(m_domApplicationCache); | 350 visitor->trace(m_domApplicationCache); |
| 339 visitor->trace(m_documentLoader); | 351 visitor->trace(m_documentLoader); |
| 340 } | 352 } |
| 341 | 353 |
| 342 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |