| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 * | 25 * |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef WorkerScriptLoader_h | 28 #ifndef WorkerScriptLoader_h |
| 29 #define WorkerScriptLoader_h | 29 #define WorkerScriptLoader_h |
| 30 | 30 |
| 31 #include "core/loader/ThreadableLoader.h" | 31 #include "core/loader/ThreadableLoader.h" |
| 32 #include "core/loader/ThreadableLoaderClient.h" | 32 #include "core/loader/ThreadableLoaderClient.h" |
| 33 #include "heap/Handle.h" |
| 33 #include "platform/network/ResourceRequest.h" | 34 #include "platform/network/ResourceRequest.h" |
| 34 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
| 35 #include "wtf/FastAllocBase.h" | 36 #include "wtf/FastAllocBase.h" |
| 36 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 37 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 38 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
| 39 | 40 |
| 40 namespace WebCore { | 41 namespace WebCore { |
| 41 | 42 |
| 42 class ResourceRequest; | 43 class ResourceRequest; |
| 43 class ResourceResponse; | 44 class ResourceResponse; |
| 44 class ExecutionContext; | 45 class ExecutionContext; |
| 45 class TextResourceDecoder; | 46 class TextResourceDecoder; |
| 46 class WorkerScriptLoaderClient; | 47 class WorkerScriptLoaderClient; |
| 47 | 48 |
| 48 class WorkerScriptLoader FINAL : public RefCounted<WorkerScriptLoader>, publ
ic ThreadableLoaderClient { | 49 class WorkerScriptLoader FINAL : public RefCountedWillBeGarbageCollectedFina
lized<WorkerScriptLoader>, public ThreadableLoaderClient { |
| 49 WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 51 DECLARE_GC_INFO; |
| 50 public: | 52 public: |
| 51 static PassRefPtr<WorkerScriptLoader> create() | 53 static PassRefPtrWillBeRawPtr<WorkerScriptLoader> create() |
| 52 { | 54 { |
| 53 return adoptRef(new WorkerScriptLoader()); | 55 return adoptRefWillBeNoop(new WorkerScriptLoader()); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void loadSynchronously(ExecutionContext*, const KURL&, CrossOriginReques
tPolicy); | 58 void loadSynchronously(ExecutionContext*, const KURL&, CrossOriginReques
tPolicy); |
| 57 void loadAsynchronously(ExecutionContext*, const KURL&, CrossOriginReque
stPolicy, WorkerScriptLoaderClient*); | 59 void loadAsynchronously(ExecutionContext*, const KURL&, CrossOriginReque
stPolicy, WorkerScriptLoaderClient*); |
| 58 | 60 |
| 59 void notifyError(); | 61 void notifyError(); |
| 60 | 62 |
| 61 // This will immediately lead to notifyFinished() if loadAsynchronously | 63 // This will immediately lead to notifyFinished() if loadAsynchronously |
| 62 // is in progress. | 64 // is in progress. |
| 63 void cancel(); | 65 void cancel(); |
| 64 | 66 |
| 65 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } | 67 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } |
| 66 | 68 |
| 67 String script(); | 69 String script(); |
| 68 const KURL& url() const { return m_url; } | 70 const KURL& url() const { return m_url; } |
| 69 const KURL& responseURL() const; | 71 const KURL& responseURL() const; |
| 70 bool failed() const { return m_failed; } | 72 bool failed() const { return m_failed; } |
| 71 unsigned long identifier() const { return m_identifier; } | 73 unsigned long identifier() const { return m_identifier; } |
| 72 | 74 |
| 73 virtual void didReceiveResponse(unsigned long /*identifier*/, const Reso
urceResponse&) OVERRIDE; | 75 virtual void didReceiveResponse(unsigned long /*identifier*/, const Reso
urceResponse&) OVERRIDE; |
| 74 virtual void didReceiveData(const char* data, int dataLength) OVERRIDE; | 76 virtual void didReceiveData(const char* data, int dataLength) OVERRIDE; |
| 75 virtual void didFinishLoading(unsigned long identifier, double) OVERRIDE
; | 77 virtual void didFinishLoading(unsigned long identifier, double) OVERRIDE
; |
| 76 virtual void didFail(const ResourceError&) OVERRIDE; | 78 virtual void didFail(const ResourceError&) OVERRIDE; |
| 77 virtual void didFailRedirectCheck() OVERRIDE; | 79 virtual void didFailRedirectCheck() OVERRIDE; |
| 78 | 80 |
| 79 void setTargetType(ResourceRequest::TargetType targetType) { m_targetTyp
e = targetType; } | 81 void setTargetType(ResourceRequest::TargetType targetType) { m_targetTyp
e = targetType; } |
| 80 | 82 |
| 83 void trace(Visitor*) { } |
| 84 |
| 81 private: | 85 private: |
| 82 friend class WTF::RefCounted<WorkerScriptLoader>; | 86 friend class RefCountedWillBeGarbageCollectedFinalized<WorkerScriptLoade
r>; |
| 83 | 87 |
| 84 WorkerScriptLoader(); | 88 WorkerScriptLoader(); |
| 85 virtual ~WorkerScriptLoader(); | 89 virtual ~WorkerScriptLoader(); |
| 86 | 90 |
| 87 PassOwnPtr<ResourceRequest> createResourceRequest(); | 91 PassOwnPtr<ResourceRequest> createResourceRequest(); |
| 88 void notifyFinished(); | 92 void notifyFinished(); |
| 89 | 93 |
| 90 WorkerScriptLoaderClient* m_client; | 94 WorkerScriptLoaderClient* m_client; |
| 91 RefPtr<ThreadableLoader> m_threadableLoader; | 95 RefPtr<ThreadableLoader> m_threadableLoader; |
| 92 String m_responseEncoding; | 96 String m_responseEncoding; |
| 93 OwnPtr<TextResourceDecoder> m_decoder; | 97 OwnPtr<TextResourceDecoder> m_decoder; |
| 94 StringBuilder m_script; | 98 StringBuilder m_script; |
| 95 KURL m_url; | 99 KURL m_url; |
| 96 KURL m_responseURL; | 100 KURL m_responseURL; |
| 97 bool m_failed; | 101 bool m_failed; |
| 98 unsigned long m_identifier; | 102 unsigned long m_identifier; |
| 99 bool m_finishing; | 103 bool m_finishing; |
| 100 ResourceRequest::TargetType m_targetType; | 104 ResourceRequest::TargetType m_targetType; |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 } // namespace WebCore | 107 } // namespace WebCore |
| 104 | 108 |
| 105 #endif // WorkerScriptLoader_h | 109 #endif // WorkerScriptLoader_h |
| OLD | NEW |