| 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 28 matching lines...) Expand all Loading... |
| 39 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class ResourceRequest; | 43 class ResourceRequest; |
| 44 class ResourceResponse; | 44 class ResourceResponse; |
| 45 class ExecutionContext; | 45 class ExecutionContext; |
| 46 class TextResourceDecoder; | 46 class TextResourceDecoder; |
| 47 class WorkerScriptLoaderClient; | 47 class WorkerScriptLoaderClient; |
| 48 | 48 |
| 49 class WorkerScriptLoader FINAL : public RefCounted<WorkerScriptLoader>, publ
ic ThreadableLoaderClient { | 49 class WorkerScriptLoader final : public RefCounted<WorkerScriptLoader>, publ
ic ThreadableLoaderClient { |
| 50 WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_FAST_ALLOCATED; |
| 51 public: | 51 public: |
| 52 static PassRefPtr<WorkerScriptLoader> create() | 52 static PassRefPtr<WorkerScriptLoader> create() |
| 53 { | 53 { |
| 54 return adoptRef(new WorkerScriptLoader()); | 54 return adoptRef(new WorkerScriptLoader()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void loadSynchronously(ExecutionContext&, const KURL&, CrossOriginReques
tPolicy); | 57 void loadSynchronously(ExecutionContext&, const KURL&, CrossOriginReques
tPolicy); |
| 58 void loadAsynchronously(ExecutionContext&, const KURL&, CrossOriginReque
stPolicy, WorkerScriptLoaderClient*); | 58 void loadAsynchronously(ExecutionContext&, const KURL&, CrossOriginReque
stPolicy, WorkerScriptLoaderClient*); |
| 59 | 59 |
| 60 void notifyError(); | 60 void notifyError(); |
| 61 | 61 |
| 62 // This will immediately lead to notifyFinished() if loadAsynchronously | 62 // This will immediately lead to notifyFinished() if loadAsynchronously |
| 63 // is in progress. | 63 // is in progress. |
| 64 void cancel(); | 64 void cancel(); |
| 65 | 65 |
| 66 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } | 66 void setClient(WorkerScriptLoaderClient* client) { m_client = client; } |
| 67 | 67 |
| 68 String script(); | 68 String script(); |
| 69 const KURL& url() const { return m_url; } | 69 const KURL& url() const { return m_url; } |
| 70 const KURL& responseURL() const; | 70 const KURL& responseURL() const; |
| 71 bool failed() const { return m_failed; } | 71 bool failed() const { return m_failed; } |
| 72 unsigned long identifier() const { return m_identifier; } | 72 unsigned long identifier() const { return m_identifier; } |
| 73 | 73 |
| 74 virtual void didReceiveResponse(unsigned long /*identifier*/, const Reso
urceResponse&) OVERRIDE; | 74 virtual void didReceiveResponse(unsigned long /*identifier*/, const Reso
urceResponse&) override; |
| 75 virtual void didReceiveData(const char* data, unsigned dataLength) OVERR
IDE; | 75 virtual void didReceiveData(const char* data, unsigned dataLength) overr
ide; |
| 76 virtual void didFinishLoading(unsigned long identifier, double) OVERRIDE
; | 76 virtual void didFinishLoading(unsigned long identifier, double) override
; |
| 77 virtual void didFail(const ResourceError&) OVERRIDE; | 77 virtual void didFail(const ResourceError&) override; |
| 78 virtual void didFailRedirectCheck() OVERRIDE; | 78 virtual void didFailRedirectCheck() override; |
| 79 | 79 |
| 80 void setRequestContext(blink::WebURLRequest::RequestContext requestConte
xt) { m_requestContext = requestContext; } | 80 void setRequestContext(blink::WebURLRequest::RequestContext requestConte
xt) { m_requestContext = requestContext; } |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 friend class WTF::RefCounted<WorkerScriptLoader>; | 83 friend class WTF::RefCounted<WorkerScriptLoader>; |
| 84 | 84 |
| 85 WorkerScriptLoader(); | 85 WorkerScriptLoader(); |
| 86 virtual ~WorkerScriptLoader(); | 86 virtual ~WorkerScriptLoader(); |
| 87 | 87 |
| 88 PassOwnPtr<ResourceRequest> createResourceRequest(); | 88 PassOwnPtr<ResourceRequest> createResourceRequest(); |
| 89 void notifyFinished(); | 89 void notifyFinished(); |
| 90 | 90 |
| 91 WorkerScriptLoaderClient* m_client; | 91 WorkerScriptLoaderClient* m_client; |
| 92 RefPtr<ThreadableLoader> m_threadableLoader; | 92 RefPtr<ThreadableLoader> m_threadableLoader; |
| 93 String m_responseEncoding; | 93 String m_responseEncoding; |
| 94 OwnPtr<TextResourceDecoder> m_decoder; | 94 OwnPtr<TextResourceDecoder> m_decoder; |
| 95 StringBuilder m_script; | 95 StringBuilder m_script; |
| 96 KURL m_url; | 96 KURL m_url; |
| 97 KURL m_responseURL; | 97 KURL m_responseURL; |
| 98 bool m_failed; | 98 bool m_failed; |
| 99 unsigned long m_identifier; | 99 unsigned long m_identifier; |
| 100 bool m_finishing; | 100 bool m_finishing; |
| 101 blink::WebURLRequest::RequestContext m_requestContext; | 101 blink::WebURLRequest::RequestContext m_requestContext; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace blink | 104 } // namespace blink |
| 105 | 105 |
| 106 #endif // WorkerScriptLoader_h | 106 #endif // WorkerScriptLoader_h |
| OLD | NEW |