| 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 "public/platform/WebURLResponse.h" | 16 #include "public/platform/WebURLResponse.h" |
| 17 #include "public/platform/modules/serviceworker/WebServiceWorkerError.h" | 17 #include "public/platform/modules/serviceworker/WebServiceWorkerError.h" |
| 18 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 19 #include "wtf/RefPtr.h" | 19 #include "wtf/RefPtr.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 if (event.IsEmpty()) { | 90 if (event.IsEmpty()) { |
| 91 // |toV8| can return an empty handle when the worker is terminating. | 91 // |toV8| can return an empty handle when the worker is terminating. |
| 92 // We don't want the renderer to crash in such cases. | 92 // We don't want the renderer to crash in such cases. |
| 93 // TODO(yhirano): Replace this branch with an assertion when the | 93 // TODO(yhirano): Replace this branch with an assertion when the |
| 94 // graceful shutdown mechanism is introduced. | 94 // graceful shutdown mechanism is introduced. |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 DCHECK(event->IsObject()); | 97 DCHECK(event->IsObject()); |
| 98 // Sets a hidden value in order to teach V8 the dependency from | 98 // Sets a hidden value in order to teach V8 the dependency from |
| 99 // the event to the request. | 99 // the event to the request. |
| 100 V8HiddenValue::setHiddenValue( | 100 V8PrivateProperty::getFetchEventRequest(scriptState->isolate()) |
| 101 scriptState, event.As<v8::Object>(), | 101 .set(event.As<v8::Object>(), request); |
| 102 V8HiddenValue::requestInFetchEvent(scriptState->isolate()), request); | |
| 103 // From the same reason as above, setHiddenValue can return false. | 102 // From the same reason as above, setHiddenValue can return false. |
| 104 // TODO(yhirano): Add an assertion that it returns true once the | 103 // TODO(yhirano): Add an assertion that it returns true once the |
| 105 // graceful shutdown mechanism is introduced. | 104 // graceful shutdown mechanism is introduced. |
| 106 } | 105 } |
| 107 } | 106 } |
| 108 | 107 |
| 109 void FetchEvent::onNavigationPreloadResponse( | 108 void FetchEvent::onNavigationPreloadResponse( |
| 110 ScriptState* scriptState, | 109 ScriptState* scriptState, |
| 111 std::unique_ptr<WebURLResponse> response, | 110 std::unique_ptr<WebURLResponse> response, |
| 112 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { | 111 std::unique_ptr<WebDataConsumerHandle> dataConsumeHandle) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 145 } |
| 147 | 146 |
| 148 DEFINE_TRACE(FetchEvent) { | 147 DEFINE_TRACE(FetchEvent) { |
| 149 visitor->trace(m_observer); | 148 visitor->trace(m_observer); |
| 150 visitor->trace(m_request); | 149 visitor->trace(m_request); |
| 151 visitor->trace(m_preloadResponseProperty); | 150 visitor->trace(m_preloadResponseProperty); |
| 152 ExtendableEvent::trace(visitor); | 151 ExtendableEvent::trace(visitor); |
| 153 } | 152 } |
| 154 | 153 |
| 155 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |