| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/presentation/PresentationRequest.h" | 5 #include "modules/presentation/PresentationRequest.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 ExecutionContext* executionContext, | 69 ExecutionContext* executionContext, |
| 70 const String& url, | 70 const String& url, |
| 71 ExceptionState& exceptionState) { | 71 ExceptionState& exceptionState) { |
| 72 KURL parsedUrl = KURL(executionContext->url(), url); | 72 KURL parsedUrl = KURL(executionContext->url(), url); |
| 73 if (!parsedUrl.isValid() || parsedUrl.protocolIsAbout()) { | 73 if (!parsedUrl.isValid() || parsedUrl.protocolIsAbout()) { |
| 74 exceptionState.throwTypeError("'" + url + | 74 exceptionState.throwTypeError("'" + url + |
| 75 "' can't be resolved to a valid URL."); | 75 "' can't be resolved to a valid URL."); |
| 76 return nullptr; | 76 return nullptr; |
| 77 } | 77 } |
| 78 | 78 |
| 79 PresentationRequest* request = | 79 return new PresentationRequest(executionContext, parsedUrl); |
| 80 new PresentationRequest(executionContext, parsedUrl); | |
| 81 request->suspendIfNeeded(); | |
| 82 return request; | |
| 83 } | 80 } |
| 84 | 81 |
| 85 const AtomicString& PresentationRequest::interfaceName() const { | 82 const AtomicString& PresentationRequest::interfaceName() const { |
| 86 return EventTargetNames::PresentationRequest; | 83 return EventTargetNames::PresentationRequest; |
| 87 } | 84 } |
| 88 | 85 |
| 89 ExecutionContext* PresentationRequest::getExecutionContext() const { | 86 ExecutionContext* PresentationRequest::getExecutionContext() const { |
| 90 return SuspendableObject::getExecutionContext(); | 87 return ContextLifecycleObserver::getExecutionContext(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 void PresentationRequest::addedEventListener( | 90 void PresentationRequest::addedEventListener( |
| 94 const AtomicString& eventType, | 91 const AtomicString& eventType, |
| 95 RegisteredEventListener& registeredListener) { | 92 RegisteredEventListener& registeredListener) { |
| 96 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); | 93 EventTargetWithInlineData::addedEventListener(eventType, registeredListener); |
| 97 if (eventType == EventTypeNames::connectionavailable) | 94 if (eventType == EventTypeNames::connectionavailable) |
| 98 UseCounter::count( | 95 UseCounter::count( |
| 99 getExecutionContext(), | 96 getExecutionContext(), |
| 100 UseCounter::PresentationRequestConnectionAvailableEventListener); | 97 UseCounter::PresentationRequestConnectionAvailableEventListener); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return m_availabilityProperty->promise(scriptState->world()); | 198 return m_availabilityProperty->promise(scriptState->world()); |
| 202 } | 199 } |
| 203 | 200 |
| 204 const KURL& PresentationRequest::url() const { | 201 const KURL& PresentationRequest::url() const { |
| 205 return m_url; | 202 return m_url; |
| 206 } | 203 } |
| 207 | 204 |
| 208 DEFINE_TRACE(PresentationRequest) { | 205 DEFINE_TRACE(PresentationRequest) { |
| 209 visitor->trace(m_availabilityProperty); | 206 visitor->trace(m_availabilityProperty); |
| 210 EventTargetWithInlineData::trace(visitor); | 207 EventTargetWithInlineData::trace(visitor); |
| 211 SuspendableObject::trace(visitor); | 208 ContextLifecycleObserver::trace(visitor); |
| 212 } | 209 } |
| 213 | 210 |
| 214 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, | 211 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, |
| 215 const KURL& url) | 212 const KURL& url) |
| 216 : SuspendableObject(executionContext), m_url(url) {} | 213 : ContextLifecycleObserver(executionContext), m_url(url) {} |
| 217 | 214 |
| 218 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |