OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ForeignFetchEvent.h" | 5 #include "modules/serviceworkers/ForeignFetchEvent.h" |
6 | 6 |
7 #include "bindings/core/v8/ToV8.h" | 7 #include "bindings/core/v8/ToV8.h" |
8 #include "bindings/core/v8/V8HiddenValue.h" | 8 #include "bindings/core/v8/V8PrivateProperty.h" |
9 #include "modules/fetch/Request.h" | 9 #include "modules/fetch/Request.h" |
10 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" | 10 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" |
11 #include "wtf/RefPtr.h" | 11 #include "wtf/RefPtr.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 ForeignFetchEvent* ForeignFetchEvent::create( | 15 ForeignFetchEvent* ForeignFetchEvent::create( |
16 ScriptState* scriptState, | 16 ScriptState* scriptState, |
17 const AtomicString& type, | 17 const AtomicString& type, |
18 const ForeignFetchEventInit& initializer) { | 18 const ForeignFetchEventInit& initializer) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (event.IsEmpty()) { | 69 if (event.IsEmpty()) { |
70 // |toV8| can return an empty handle when the worker is terminating. | 70 // |toV8| can return an empty handle when the worker is terminating. |
71 // We don't want the renderer to crash in such cases. | 71 // We don't want the renderer to crash in such cases. |
72 // TODO(yhirano): Replace this branch with an assertion when the | 72 // TODO(yhirano): Replace this branch with an assertion when the |
73 // graceful shutdown mechanism is introduced. | 73 // graceful shutdown mechanism is introduced. |
74 return; | 74 return; |
75 } | 75 } |
76 DCHECK(event->IsObject()); | 76 DCHECK(event->IsObject()); |
77 // Sets a hidden value in order to teach V8 the dependency from | 77 // Sets a hidden value in order to teach V8 the dependency from |
78 // the event to the request. | 78 // the event to the request. |
79 V8HiddenValue::setHiddenValue( | 79 V8PrivateProperty::getFetchEventRequest(scriptState->isolate()) |
80 scriptState, event.As<v8::Object>(), | 80 .set(event.As<v8::Object>(), request); |
81 V8HiddenValue::requestInFetchEvent(scriptState->isolate()), request); | |
82 // From the same reason as above, setHiddenValue can return false. | 81 // From the same reason as above, setHiddenValue can return false. |
83 // TODO(yhirano): Add an assertion that it returns true once the | 82 // TODO(yhirano): Add an assertion that it returns true once the |
84 // graceful shutdown mechanism is introduced. | 83 // graceful shutdown mechanism is introduced. |
85 } | 84 } |
86 } | 85 } |
87 | 86 |
88 DEFINE_TRACE(ForeignFetchEvent) { | 87 DEFINE_TRACE(ForeignFetchEvent) { |
89 visitor->trace(m_observer); | 88 visitor->trace(m_observer); |
90 visitor->trace(m_request); | 89 visitor->trace(m_request); |
91 ExtendableEvent::trace(visitor); | 90 ExtendableEvent::trace(visitor); |
92 } | 91 } |
93 | 92 |
94 } // namespace blink | 93 } // namespace blink |
OLD | NEW |