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

Side by Side Diff: third_party/WebKit/Source/core/loader/WorkerThreadableLoader.h

Issue 2225733002: Revert of Move ThreadableLoader to Oilpan heap (3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-threadable-loader
Patch Set: Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 namespace blink { 49 namespace blink {
50 50
51 class ResourceError; 51 class ResourceError;
52 class ResourceRequest; 52 class ResourceRequest;
53 class ResourceResponse; 53 class ResourceResponse;
54 class WorkerGlobalScope; 54 class WorkerGlobalScope;
55 class WorkerLoaderProxy; 55 class WorkerLoaderProxy;
56 struct CrossThreadResourceRequestData; 56 struct CrossThreadResourceRequestData;
57 struct CrossThreadResourceTimingInfoData; 57 struct CrossThreadResourceTimingInfoData;
58 58
59 // A WorkerThreadableLoader is a ThreadableLoader implementation intended to 59 // TODO(yhirano): Draw a diagram to illustrate the class relationship.
60 // be used in a WebWorker thread. Because Blink's ResourceFetcher and 60 // TODO(yhirano): Rename inner classes so that readers can see in which thread
61 // ResourceLoader work only in the main thread, a WorkerThreadableLoader holds 61 // they are living easily.
62 // a ThreadableLoader in the main thread and delegates tasks asynchronously
63 // to the loader.
64 //
65 // CTP: CrossThreadPersistent
66 // CTWP: CrossThreadWeakPersistent
67 //
68 // ----------------------------------------------------------------
69 // +------------------------+
70 // raw ptr | ThreadableLoaderClient |
71 // +--------> | worker thread |
72 // | +------------------------+
73 // |
74 // +----+------------------+ CTP +------------------------+
75 // + WorkerThreadableLoader|<--------+ MainThreadLoaderHolder |
76 // | worker thread +-------->| main thread |
77 // +-----------------------+ CTWP +----------------------+-+
78 // |
79 // +------------------+ | Member
80 // | ThreadableLoader | <---+
81 // | main thread |
82 // +------------------+
83 //
84 class WorkerThreadableLoader final : public ThreadableLoader { 62 class WorkerThreadableLoader final : public ThreadableLoader {
85 public: 63 public:
86 static void loadResourceSynchronously(WorkerGlobalScope&, const ResourceRequ est&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoa derOptions&); 64 static void loadResourceSynchronously(WorkerGlobalScope&, const ResourceRequ est&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoa derOptions&);
87 static WorkerThreadableLoader* create(WorkerGlobalScope& workerGlobalScope, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options, const Re sourceLoaderOptions& resourceLoaderOptions) 65 static WorkerThreadableLoader* create(WorkerGlobalScope& workerGlobalScope, ThreadableLoaderClient* client, const ThreadableLoaderOptions& options, const Re sourceLoaderOptions& resourceLoaderOptions)
88 { 66 {
89 return new WorkerThreadableLoader(workerGlobalScope, client, options, re sourceLoaderOptions, LoadAsynchronously); 67 return new WorkerThreadableLoader(workerGlobalScope, client, options, re sourceLoaderOptions, LoadAsynchronously);
90 } 68 }
91 69
92 ~WorkerThreadableLoader() override; 70 ~WorkerThreadableLoader() override;
93 71
(...skipping 22 matching lines...) Expand all
116 }; 94 };
117 class AsyncTaskForwarder; 95 class AsyncTaskForwarder;
118 struct TaskWithLocation; 96 struct TaskWithLocation;
119 class WaitableEventWithTasks; 97 class WaitableEventWithTasks;
120 class SyncTaskForwarder; 98 class SyncTaskForwarder;
121 99
122 // An instance of this class lives in the main thread. It is a 100 // An instance of this class lives in the main thread. It is a
123 // ThreadableLoaderClient for a DocumentThreadableLoader and forward 101 // ThreadableLoaderClient for a DocumentThreadableLoader and forward
124 // notifications to the associated WorkerThreadableLoader living in the 102 // notifications to the associated WorkerThreadableLoader living in the
125 // worker thread. 103 // worker thread.
126 class MainThreadLoaderHolder final : public GarbageCollectedFinalized<MainTh readLoaderHolder>, public ThreadableLoaderClient, public WorkerThreadLifecycleOb server { 104 class Peer final : public GarbageCollectedFinalized<Peer>, public Threadable LoaderClient, public WorkerThreadLifecycleObserver {
127 USING_GARBAGE_COLLECTED_MIXIN(MainThreadLoaderHolder); 105 USING_GARBAGE_COLLECTED_MIXIN(Peer);
128 public: 106 public:
129 static void createAndStart( 107 static void createAndStart(
130 WorkerThreadableLoader*, 108 WorkerThreadableLoader*,
131 PassRefPtr<WorkerLoaderProxy>, 109 PassRefPtr<WorkerLoaderProxy>,
132 WorkerThreadLifecycleContext*, 110 WorkerThreadLifecycleContext*,
133 std::unique_ptr<CrossThreadResourceRequestData>, 111 std::unique_ptr<CrossThreadResourceRequestData>,
134 const ThreadableLoaderOptions&, 112 const ThreadableLoaderOptions&,
135 const ResourceLoaderOptions&, 113 const ResourceLoaderOptions&,
136 PassRefPtr<WaitableEventWithTasks>, 114 PassRefPtr<WaitableEventWithTasks>,
137 ExecutionContext*); 115 ExecutionContext*);
138 ~MainThreadLoaderHolder() override; 116 ~Peer() override;
139 117
140 void overrideTimeout(unsigned long timeoutMillisecond); 118 void overrideTimeout(unsigned long timeoutMillisecond);
141 void cancel(); 119 void cancel();
142 120
143 void didSendData(unsigned long long bytesSent, unsigned long long totalB ytesToBeSent) override; 121 void didSendData(unsigned long long bytesSent, unsigned long long totalB ytesToBeSent) override;
144 void didReceiveResponse(unsigned long identifier, const ResourceResponse &, std::unique_ptr<WebDataConsumerHandle>) override; 122 void didReceiveResponse(unsigned long identifier, const ResourceResponse &, std::unique_ptr<WebDataConsumerHandle>) override;
145 void didReceiveData(const char*, unsigned dataLength) override; 123 void didReceiveData(const char*, unsigned dataLength) override;
146 void didDownloadData(int dataLength) override; 124 void didDownloadData(int dataLength) override;
147 void didReceiveCachedMetadata(const char*, int dataLength) override; 125 void didReceiveCachedMetadata(const char*, int dataLength) override;
148 void didFinishLoading(unsigned long identifier, double finishTime) overr ide; 126 void didFinishLoading(unsigned long identifier, double finishTime) overr ide;
149 void didFail(const ResourceError&) override; 127 void didFail(const ResourceError&) override;
150 void didFailAccessControlCheck(const ResourceError&) override; 128 void didFailAccessControlCheck(const ResourceError&) override;
151 void didFailRedirectCheck() override; 129 void didFailRedirectCheck() override;
152 void didReceiveResourceTiming(const ResourceTimingInfo&) override; 130 void didReceiveResourceTiming(const ResourceTimingInfo&) override;
153 131
154 void contextDestroyed() override; 132 void contextDestroyed() override;
155 133
156 DECLARE_TRACE(); 134 DECLARE_TRACE();
157 135
158 private: 136 private:
159 MainThreadLoaderHolder(TaskForwarder*, WorkerThreadLifecycleContext*); 137 Peer(TaskForwarder*, WorkerThreadLifecycleContext*);
160 void start(Document&, std::unique_ptr<CrossThreadResourceRequestData>, c onst ThreadableLoaderOptions&, const ResourceLoaderOptions&); 138 void start(Document&, std::unique_ptr<CrossThreadResourceRequestData>, c onst ThreadableLoaderOptions&, const ResourceLoaderOptions&);
161 139
162 Member<TaskForwarder> m_forwarder; 140 Member<TaskForwarder> m_forwarder;
163 Member<ThreadableLoader> m_mainThreadLoader; 141 Member<ThreadableLoader> m_mainThreadLoader;
164 142
165 // |*m_workerLoader| lives in the worker thread. 143 // |*m_workerLoader| lives in the worker thread.
166 CrossThreadWeakPersistent<WorkerThreadableLoader> m_workerLoader; 144 CrossThreadWeakPersistent<WorkerThreadableLoader> m_workerLoader;
167 }; 145 };
168 146
169 WorkerThreadableLoader(WorkerGlobalScope&, ThreadableLoaderClient*, const Th readableLoaderOptions&, const ResourceLoaderOptions&, BlockingBehavior); 147 WorkerThreadableLoader(WorkerGlobalScope&, ThreadableLoaderClient*, const Th readableLoaderOptions&, const ResourceLoaderOptions&, BlockingBehavior);
170 void didStart(MainThreadLoaderHolder*); 148 void didStart(Peer*);
171 149
172 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent); 150 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes ToBeSent);
173 void didReceiveResponse(unsigned long identifier, std::unique_ptr<CrossThrea dResourceResponseData>, std::unique_ptr<WebDataConsumerHandle>); 151 void didReceiveResponse(unsigned long identifier, std::unique_ptr<CrossThrea dResourceResponseData>, std::unique_ptr<WebDataConsumerHandle>);
174 void didReceiveData(std::unique_ptr<Vector<char>> data); 152 void didReceiveData(std::unique_ptr<Vector<char>> data);
175 void didReceiveCachedMetadata(std::unique_ptr<Vector<char>> data); 153 void didReceiveCachedMetadata(std::unique_ptr<Vector<char>> data);
176 void didFinishLoading(unsigned long identifier, double finishTime); 154 void didFinishLoading(unsigned long identifier, double finishTime);
177 void didFail(const ResourceError&); 155 void didFail(const ResourceError&);
178 void didFailAccessControlCheck(const ResourceError&); 156 void didFailAccessControlCheck(const ResourceError&);
179 void didFailRedirectCheck(); 157 void didFailRedirectCheck();
180 void didDownloadData(int dataLength); 158 void didDownloadData(int dataLength);
181 void didReceiveResourceTiming(std::unique_ptr<CrossThreadResourceTimingInfoD ata>); 159 void didReceiveResourceTiming(std::unique_ptr<CrossThreadResourceTimingInfoD ata>);
182 160
183 Member<WorkerGlobalScope> m_workerGlobalScope; 161 Member<WorkerGlobalScope> m_workerGlobalScope;
184 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; 162 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy;
185 ThreadableLoaderClient* m_client; 163 ThreadableLoaderClient* m_client;
186 164
187 ThreadableLoaderOptions m_threadableLoaderOptions; 165 ThreadableLoaderOptions m_threadableLoaderOptions;
188 ResourceLoaderOptions m_resourceLoaderOptions; 166 ResourceLoaderOptions m_resourceLoaderOptions;
189 BlockingBehavior m_blockingBehavior; 167 BlockingBehavior m_blockingBehavior;
190 168
191 // |*m_mainThreadLoaderHolder| lives in the main thread. 169 // |*m_peer| lives in the main thread.
192 CrossThreadPersistent<MainThreadLoaderHolder> m_mainThreadLoaderHolder; 170 CrossThreadPersistent<Peer> m_peer;
193 }; 171 };
194 172
195 } // namespace blink 173 } // namespace blink
196 174
197 #endif // WorkerThreadableLoader_h 175 #endif // WorkerThreadableLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698