| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/serviceworkers/FetchEvent.h" | 5 #include "modules/serviceworkers/FetchEvent.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/ToV8.h" | 8 #include "bindings/core/v8/ToV8.h" |
| 9 #include "bindings/core/v8/V8HiddenValue.h" | 9 #include "bindings/core/v8/V8PrivateProperty.h" |
| 10 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" | 10 #include "modules/fetch/BytesConsumerForDataConsumerHandle.h" |
| 11 #include "modules/fetch/Request.h" | 11 #include "modules/fetch/Request.h" |
| 12 #include "modules/fetch/Response.h" | 12 #include "modules/fetch/Response.h" |
| 13 #include "modules/serviceworkers/FetchRespondWithObserver.h" | 13 #include "modules/serviceworkers/FetchRespondWithObserver.h" |
| 14 #include "modules/serviceworkers/ServiceWorkerError.h" | 14 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 15 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 15 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" |
| 16 #include "platform/network/NetworkUtils.h" | 16 #include "platform/network/NetworkUtils.h" |
| 17 #include "public/platform/WebURLResponse.h" | 17 #include "public/platform/WebURLResponse.h" |
| 18 #include "public/platform/modules/serviceworker/WebServiceWorkerError.h" | 18 #include "public/platform/modules/serviceworker/WebServiceWorkerError.h" |
| 19 #include "wtf/PtrUtil.h" | 19 #include "wtf/PtrUtil.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (event.IsEmpty()) { | 91 if (event.IsEmpty()) { |
| 92 // |toV8| can return an empty handle when the worker is terminating. | 92 // |toV8| can return an empty handle when the worker is terminating. |
| 93 // We don't want the renderer to crash in such cases. | 93 // We don't want the renderer to crash in such cases. |
| 94 // TODO(yhirano): Replace this branch with an assertion when the | 94 // TODO(yhirano): Replace this branch with an assertion when the |
| 95 // graceful shutdown mechanism is introduced. | 95 // graceful shutdown mechanism is introduced. |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 DCHECK(event->IsObject()); | 98 DCHECK(event->IsObject()); |
| 99 // Sets a hidden value in order to teach V8 the dependency from | 99 // Sets a hidden value in order to teach V8 the dependency from |
| 100 // the event to the request. | 100 // the event to the request. |
| 101 V8HiddenValue::setHiddenValue( | 101 V8PrivateProperty::getFetchEventRequest(scriptState->isolate()) |
| 102 scriptState, event.As<v8::Object>(), | 102 .set(event.As<v8::Object>(), request); |
| 103 V8HiddenValue::requestInFetchEvent(scriptState->isolate()), request); | |
| 104 // From the same reason as above, setHiddenValue can return false. | 103 // From the same reason as above, setHiddenValue can return false. |
| 105 // TODO(yhirano): Add an assertion that it returns true once the | 104 // TODO(yhirano): Add an assertion that it returns true once the |
| 106 // graceful shutdown mechanism is introduced. | 105 // graceful shutdown mechanism is introduced. |
| 107 } | 106 } |
| 108 } | 107 } |
| 109 | 108 |
| 110 void FetchEvent::onNavigationPreloadResponse( | 109 void FetchEvent::onNavigationPreloadResponse( |
| 111 ScriptState* scriptState, | 110 ScriptState* scriptState, |
| 112 std::unique_ptr<WebURLResponse> response, | 111 std::unique_ptr<WebURLResponse> response, |
| 113 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { | 112 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 151 } |
| 153 | 152 |
| 154 DEFINE_TRACE(FetchEvent) { | 153 DEFINE_TRACE(FetchEvent) { |
| 155 visitor->trace(m_observer); | 154 visitor->trace(m_observer); |
| 156 visitor->trace(m_request); | 155 visitor->trace(m_request); |
| 157 visitor->trace(m_preloadResponseProperty); | 156 visitor->trace(m_preloadResponseProperty); |
| 158 ExtendableEvent::trace(visitor); | 157 ExtendableEvent::trace(visitor); |
| 159 } | 158 } |
| 160 | 159 |
| 161 } // namespace blink | 160 } // namespace blink |
| OLD | NEW |