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 3 // found in the LICENSE file. 4 5 #include "config.h" 6 #include "FetchEvent.h" 7 8 #include "modules/serviceworkers/Request.h" 9 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 10 #include "wtf/RefPtr.h" 11 12 namespace blink { 13 14 PassRefPtrWillBeRawPtr<FetchEvent> FetchEvent::create() 15 { 16 return adoptRefWillBeNoop(new FetchEvent()); 17 } 18 19 PassRefPtrWillBeRawPtr<FetchEvent> FetchEvent::create(RespondWithObserver* observer, Request* request) 20 { 21 return adoptRefWillBeNoop(new FetchEvent(observer, request)); 22 } 23 24 Request* FetchEvent::request() const 25 { 26 return m_request; 27 } 28 29 bool FetchEvent::isReload() const 30 { 31 return m_isReload; 32 } 33 34 void FetchEvent::respondWith(ScriptState* scriptState, const ScriptValue& value, ExceptionState& exceptionState) 35 { 36 m_observer->respondWith(scriptState, value, exceptionState); 37 } 38 39 const AtomicString& FetchEvent::interfaceName() const 40 { 41 return EventNames::FetchEvent; 42 } 43 44 void FetchEvent::setIsReload(bool isReload) 45 { 46 m_isReload = isReload; 47 } 48 49 FetchEvent::FetchEvent() 50 : m_isReload(false) 51 { 52 } 53 54 FetchEvent::FetchEvent(RespondWithObserver* observer, Request* request) 55 : Event(EventTypeNames::fetch, /*canBubble=*/false, /*cancelable=*/true) 56 , m_observer(observer) 57 , m_request(request) 58 , m_isReload(false) 59 { 60 } 61 62 void FetchEvent::trace(Visitor* visitor) 63 { 64 visitor->trace(m_request); 65 visitor->trace(m_observer); 66 Event::trace(visitor); 67 } 68 69 } // namespace blink 70