| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform/network/ResourceRequest.h" | 34 #include "platform/network/ResourceRequest.h" |
| 35 #include "platform/weborigin/KURL.h" | 35 #include "platform/weborigin/KURL.h" |
| 36 #include "public/platform/WebURLRequest.h" | 36 #include "public/platform/WebURLRequest.h" |
| 37 #include "wtf/FastAllocBase.h" | 37 #include "wtf/FastAllocBase.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
| 40 #include "wtf/text/StringBuilder.h" | 40 #include "wtf/text/StringBuilder.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class ContentSecurityPolicy; |
| 44 class ResourceRequest; | 45 class ResourceRequest; |
| 45 class ResourceResponse; | 46 class ResourceResponse; |
| 46 class ExecutionContext; | 47 class ExecutionContext; |
| 47 class TextResourceDecoder; | 48 class TextResourceDecoder; |
| 48 class WorkerScriptLoaderClient; | 49 class WorkerScriptLoaderClient; |
| 49 | 50 |
| 50 class CORE_EXPORT WorkerScriptLoader final : public RefCounted<WorkerScriptLoade
r>, public ThreadableLoaderClient { | 51 class CORE_EXPORT WorkerScriptLoader final : public RefCounted<WorkerScriptLoade
r>, public ThreadableLoaderClient { |
| 51 WTF_MAKE_FAST_ALLOCATED(WorkerScriptLoader); | 52 WTF_MAKE_FAST_ALLOCATED(WorkerScriptLoader); |
| 52 public: | 53 public: |
| 53 static PassRefPtr<WorkerScriptLoader> create() | 54 static PassRefPtr<WorkerScriptLoader> create() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 67 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } | 68 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } |
| 68 | 69 |
| 69 String script(); | 70 String script(); |
| 70 const KURL& url() const { return m_url; } | 71 const KURL& url() const { return m_url; } |
| 71 const KURL& responseURL() const; | 72 const KURL& responseURL() const; |
| 72 bool failed() const { return m_failed; } | 73 bool failed() const { return m_failed; } |
| 73 unsigned long identifier() const { return m_identifier; } | 74 unsigned long identifier() const { return m_identifier; } |
| 74 PassOwnPtr<Vector<char>> releaseCachedMetadata() { return m_cachedMetadata.r
elease(); } | 75 PassOwnPtr<Vector<char>> releaseCachedMetadata() { return m_cachedMetadata.r
elease(); } |
| 75 const Vector<char>* cachedMetadata() const { return m_cachedMetadata.get();
} | 76 const Vector<char>* cachedMetadata() const { return m_cachedMetadata.get();
} |
| 76 | 77 |
| 77 virtual void didReceiveResponse(unsigned long /*identifier*/, const Resource
Response&, PassOwnPtr<WebDataConsumerHandle>) override; | 78 void setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy> policy) { m_
contentSecurityPolicy = policy; }; |
| 78 virtual void didReceiveData(const char* data, unsigned dataLength) override; | 79 PassRefPtr<ContentSecurityPolicy> contentSecurityPolicy() { return m_content
SecurityPolicy; } |
| 79 virtual void didReceiveCachedMetadata(const char*, int /*dataLength*/) overr
ide; | 80 PassRefPtr<ContentSecurityPolicy> releaseContentSecurityPolicy() { return m_
contentSecurityPolicy.release(); } |
| 80 virtual void didFinishLoading(unsigned long identifier, double) override; | 81 |
| 81 virtual void didFail(const ResourceError&) override; | 82 // ThreadableLoaderClient |
| 82 virtual void didFailRedirectCheck() override; | 83 void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse
&, PassOwnPtr<WebDataConsumerHandle>) override; |
| 84 void didReceiveData(const char* data, unsigned dataLength) override; |
| 85 void didReceiveCachedMetadata(const char*, int /*dataLength*/) override; |
| 86 void didFinishLoading(unsigned long identifier, double) override; |
| 87 void didFail(const ResourceError&) override; |
| 88 void didFailRedirectCheck() override; |
| 83 | 89 |
| 84 void setRequestContext(WebURLRequest::RequestContext requestContext) { m_req
uestContext = requestContext; } | 90 void setRequestContext(WebURLRequest::RequestContext requestContext) { m_req
uestContext = requestContext; } |
| 85 | 91 |
| 86 private: | 92 private: |
| 87 friend class WTF::RefCounted<WorkerScriptLoader>; | 93 friend class WTF::RefCounted<WorkerScriptLoader>; |
| 88 | 94 |
| 89 WorkerScriptLoader(); | 95 WorkerScriptLoader(); |
| 90 virtual ~WorkerScriptLoader(); | 96 ~WorkerScriptLoader() override; |
| 91 | 97 |
| 92 PassOwnPtr<ResourceRequest> createResourceRequest(); | 98 PassOwnPtr<ResourceRequest> createResourceRequest(); |
| 93 void notifyFinished(); | 99 void notifyFinished(); |
| 94 | 100 |
| 101 void processContentSecurityPolicy(const ResourceResponse&); |
| 102 |
| 95 WorkerScriptLoaderClient* m_client; | 103 WorkerScriptLoaderClient* m_client; |
| 96 RefPtr<ThreadableLoader> m_threadableLoader; | 104 RefPtr<ThreadableLoader> m_threadableLoader; |
| 97 String m_responseEncoding; | 105 String m_responseEncoding; |
| 98 OwnPtr<TextResourceDecoder> m_decoder; | 106 OwnPtr<TextResourceDecoder> m_decoder; |
| 99 StringBuilder m_script; | 107 StringBuilder m_script; |
| 100 KURL m_url; | 108 KURL m_url; |
| 101 KURL m_responseURL; | 109 KURL m_responseURL; |
| 102 bool m_failed; | 110 bool m_failed; |
| 103 unsigned long m_identifier; | 111 unsigned long m_identifier; |
| 104 bool m_finishing; | 112 bool m_finishing; |
| 105 OwnPtr<Vector<char>> m_cachedMetadata; | 113 OwnPtr<Vector<char>> m_cachedMetadata; |
| 106 WebURLRequest::RequestContext m_requestContext; | 114 WebURLRequest::RequestContext m_requestContext; |
| 115 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy; |
| 107 }; | 116 }; |
| 108 | 117 |
| 109 } // namespace blink | 118 } // namespace blink |
| 110 | 119 |
| 111 #endif // WorkerScriptLoader_h | 120 #endif // WorkerScriptLoader_h |
| OLD | NEW |