Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: Source/core/workers/WorkerScriptLoader.h

Issue 1190133002: Remove WorkerScriptLoaderClient and inheritances (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review #6 and #7 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/core/workers/WorkerScriptLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #ifndef WorkerScriptLoader_h 28 #ifndef WorkerScriptLoader_h
29 #define WorkerScriptLoader_h 29 #define WorkerScriptLoader_h
30 30
31 #include "core/CoreExport.h" 31 #include "core/CoreExport.h"
32 #include "core/loader/ThreadableLoader.h" 32 #include "core/loader/ThreadableLoader.h"
33 #include "core/loader/ThreadableLoaderClient.h" 33 #include "core/loader/ThreadableLoaderClient.h"
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/Functional.h"
38 #include "wtf/PassRefPtr.h" 39 #include "wtf/PassRefPtr.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 ContentSecurityPolicy;
45 class ResourceRequest; 45 class ResourceRequest;
46 class ResourceResponse; 46 class ResourceResponse;
47 class ExecutionContext; 47 class ExecutionContext;
48 class TextResourceDecoder; 48 class TextResourceDecoder;
49 class WorkerScriptLoaderClient;
50 49
51 class CORE_EXPORT WorkerScriptLoader final : public RefCounted<WorkerScriptLoade r>, public ThreadableLoaderClient { 50 class CORE_EXPORT WorkerScriptLoader final : public ThreadableLoaderClient {
52 WTF_MAKE_FAST_ALLOCATED(WorkerScriptLoader); 51 WTF_MAKE_FAST_ALLOCATED(WorkerScriptLoader);
53 public: 52 public:
54 static PassRefPtr<WorkerScriptLoader> create() 53 WorkerScriptLoader();
55 { 54 ~WorkerScriptLoader() override;
56 return adoptRef(new WorkerScriptLoader());
57 }
58 55
59 void loadSynchronously(ExecutionContext&, const KURL&, CrossOriginRequestPol icy); 56 void loadSynchronously(ExecutionContext&, const KURL&, CrossOriginRequestPol icy);
60 void loadAsynchronously(ExecutionContext&, const KURL&, CrossOriginRequestPo licy, WorkerScriptLoaderClient*); 57 // TODO: finishedCallback is not currently guaranteed to be invoked if used
58 // from worker context and the worker shuts down in the middle of an
59 // operation. This will cause leaks when we support nested workers.
60 void loadAsynchronously(ExecutionContext&, const KURL&, CrossOriginRequestPo licy, PassOwnPtr<Closure> responseCallback, PassOwnPtr<Closure> finishedCallback );
61 61
62 void notifyError(); 62 void notifyError();
63 63
64 // This will immediately lead to notifyFinished() if loadAsynchronously 64 // This will immediately lead to notifyFinished() if loadAsynchronously
65 // is in progress. 65 // is in progress.
66 void cancel(); 66 void cancel();
67 67
68 void setClient(WorkerScriptLoaderClient* client) { m_client = client; }
69
70 String script(); 68 String script();
71 const KURL& url() const { return m_url; } 69 const KURL& url() const { return m_url; }
72 const KURL& responseURL() const; 70 const KURL& responseURL() const;
73 bool failed() const { return m_failed; } 71 bool failed() const { return m_failed; }
74 unsigned long identifier() const { return m_identifier; } 72 unsigned long identifier() const { return m_identifier; }
73 long long appCacheID() const { return m_appCacheID; }
74
75 PassOwnPtr<Vector<char>> releaseCachedMetadata() { return m_cachedMetadata.r elease(); } 75 PassOwnPtr<Vector<char>> releaseCachedMetadata() { return m_cachedMetadata.r elease(); }
76 const Vector<char>* cachedMetadata() const { return m_cachedMetadata.get(); } 76 const Vector<char>* cachedMetadata() const { return m_cachedMetadata.get(); }
77 77
78 void setContentSecurityPolicy(PassRefPtr<ContentSecurityPolicy> policy) { m_ contentSecurityPolicy = policy; };
79 PassRefPtr<ContentSecurityPolicy> contentSecurityPolicy() { return m_content SecurityPolicy; } 78 PassRefPtr<ContentSecurityPolicy> contentSecurityPolicy() { return m_content SecurityPolicy; }
80 PassRefPtr<ContentSecurityPolicy> releaseContentSecurityPolicy() { return m_ contentSecurityPolicy.release(); } 79 PassRefPtr<ContentSecurityPolicy> releaseContentSecurityPolicy() { return m_ contentSecurityPolicy.release(); }
81 80
82 // ThreadableLoaderClient 81 // ThreadableLoaderClient
83 void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse &, PassOwnPtr<WebDataConsumerHandle>) override; 82 void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse &, PassOwnPtr<WebDataConsumerHandle>) override;
84 void didReceiveData(const char* data, unsigned dataLength) override; 83 void didReceiveData(const char* data, unsigned dataLength) override;
85 void didReceiveCachedMetadata(const char*, int /*dataLength*/) override; 84 void didReceiveCachedMetadata(const char*, int /*dataLength*/) override;
86 void didFinishLoading(unsigned long identifier, double) override; 85 void didFinishLoading(unsigned long identifier, double) override;
87 void didFail(const ResourceError&) override; 86 void didFail(const ResourceError&) override;
88 void didFailRedirectCheck() override; 87 void didFailRedirectCheck() override;
89 88
90 void setRequestContext(WebURLRequest::RequestContext requestContext) { m_req uestContext = requestContext; } 89 void setRequestContext(WebURLRequest::RequestContext requestContext) { m_req uestContext = requestContext; }
91 90
92 private: 91 private:
93 friend class WTF::RefCounted<WorkerScriptLoader>;
94
95 WorkerScriptLoader();
96 ~WorkerScriptLoader() override;
97
98 PassOwnPtr<ResourceRequest> createResourceRequest(); 92 PassOwnPtr<ResourceRequest> createResourceRequest();
99 void notifyFinished(); 93 void notifyFinished();
100 94
101 void processContentSecurityPolicy(const ResourceResponse&); 95 void processContentSecurityPolicy(const ResourceResponse&);
102 96
103 WorkerScriptLoaderClient* m_client; 97 // Callbacks for loadAsynchronously().
98 OwnPtr<Closure> m_responseCallback;
99 OwnPtr<Closure> m_finishedCallback;
100
104 RefPtr<ThreadableLoader> m_threadableLoader; 101 RefPtr<ThreadableLoader> m_threadableLoader;
105 String m_responseEncoding; 102 String m_responseEncoding;
106 OwnPtr<TextResourceDecoder> m_decoder; 103 OwnPtr<TextResourceDecoder> m_decoder;
107 StringBuilder m_script; 104 StringBuilder m_script;
108 KURL m_url; 105 KURL m_url;
109 KURL m_responseURL; 106 KURL m_responseURL;
110 bool m_failed; 107 bool m_failed;
111 unsigned long m_identifier; 108 unsigned long m_identifier;
109 long long m_appCacheID;
112 bool m_finishing; 110 bool m_finishing;
113 OwnPtr<Vector<char>> m_cachedMetadata; 111 OwnPtr<Vector<char>> m_cachedMetadata;
114 WebURLRequest::RequestContext m_requestContext; 112 WebURLRequest::RequestContext m_requestContext;
115 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy; 113 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy;
116 }; 114 };
117 115
118 } // namespace blink 116 } // namespace blink
119 117
120 #endif // WorkerScriptLoader_h 118 #endif // WorkerScriptLoader_h
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.cpp ('k') | Source/core/workers/WorkerScriptLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698