OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // 5. While ServeAsyncRequestsTask observes TestWebFrameClient to still have | 65 // 5. While ServeAsyncRequestsTask observes TestWebFrameClient to still have |
66 // loads in progress, it posts itself back to the run loop. | 66 // loads in progress, it posts itself back to the run loop. |
67 // 6. When ServeAsyncRequestsTask notices there are no more loads in progress, | 67 // 6. When ServeAsyncRequestsTask notices there are no more loads in progress, |
68 // it exits the run loop. | 68 // it exits the run loop. |
69 // 7. At this point, all parsing, resource loads, and layout should be finished. | 69 // 7. At this point, all parsing, resource loads, and layout should be finished. |
70 TestWebFrameClient* testClientForFrame(WebFrame* frame) | 70 TestWebFrameClient* testClientForFrame(WebFrame* frame) |
71 { | 71 { |
72 return static_cast<TestWebFrameClient*>(toWebLocalFrameImpl(frame)->client()
); | 72 return static_cast<TestWebFrameClient*>(toWebLocalFrameImpl(frame)->client()
); |
73 } | 73 } |
74 | 74 |
75 class ServeAsyncRequestsTask : public WebThread::Task { | 75 class ServeAsyncRequestsTask : public WebTaskRunner::Task { |
76 public: | 76 public: |
77 explicit ServeAsyncRequestsTask(TestWebFrameClient* client) | 77 explicit ServeAsyncRequestsTask(TestWebFrameClient* client) |
78 : m_client(client) | 78 : m_client(client) |
79 { | 79 { |
80 } | 80 } |
81 | 81 |
82 void run() override | 82 void run() override |
83 { | 83 { |
84 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); | 84 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); |
85 if (m_client->isLoading()) | 85 if (m_client->isLoading()) |
86 Platform::current()->currentThread()->postTask(FROM_HERE, new ServeA
syncRequestsTask(m_client)); | 86 Platform::current()->currentThread()->defaultTaskRunner()->postTask(
FROM_HERE, new ServeAsyncRequestsTask(m_client)); |
87 else | 87 else |
88 Platform::current()->unitTestSupport()->exitRunLoop(); | 88 Platform::current()->unitTestSupport()->exitRunLoop(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 TestWebFrameClient* const m_client; | 92 TestWebFrameClient* const m_client; |
93 }; | 93 }; |
94 | 94 |
95 void pumpPendingRequests(WebFrame* frame) | 95 void pumpPendingRequests(WebFrame* frame) |
96 { | 96 { |
97 Platform::current()->currentThread()->postTask(FROM_HERE, new ServeAsyncRequ
estsTask(testClientForFrame(frame))); | 97 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new ServeAsyncRequestsTask(testClientForFrame(frame))); |
98 Platform::current()->unitTestSupport()->enterRunLoop(); | 98 Platform::current()->unitTestSupport()->enterRunLoop(); |
99 } | 99 } |
100 | 100 |
101 class LoadTask : public WebThread::Task { | 101 class LoadTask : public WebTaskRunner::Task { |
102 public: | 102 public: |
103 LoadTask(WebFrame* frame, const WebURLRequest& request) | 103 LoadTask(WebFrame* frame, const WebURLRequest& request) |
104 : m_frame(frame) | 104 : m_frame(frame) |
105 , m_request(request) | 105 , m_request(request) |
106 { | 106 { |
107 } | 107 } |
108 | 108 |
109 void run() override | 109 void run() override |
110 { | 110 { |
111 m_frame->loadRequest(m_request); | 111 m_frame->loadRequest(m_request); |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 WebFrame* const m_frame; | 115 WebFrame* const m_frame; |
116 const WebURLRequest m_request; | 116 const WebURLRequest m_request; |
117 }; | 117 }; |
118 | 118 |
119 class LoadHTMLStringTask : public WebThread::Task { | 119 class LoadHTMLStringTask : public WebTaskRunner::Task { |
120 public: | 120 public: |
121 LoadHTMLStringTask(WebFrame* frame, const std::string& html, const WebURL& b
aseURL) | 121 LoadHTMLStringTask(WebFrame* frame, const std::string& html, const WebURL& b
aseURL) |
122 : m_frame(frame) | 122 : m_frame(frame) |
123 , m_html(html) | 123 , m_html(html) |
124 , m_baseURL(baseURL) | 124 , m_baseURL(baseURL) |
125 { | 125 { |
126 } | 126 } |
127 | 127 |
128 void run() override | 128 void run() override |
129 { | 129 { |
130 m_frame->loadHTMLString(WebData(m_html.data(), m_html.size()), m_baseURL
); | 130 m_frame->loadHTMLString(WebData(m_html.data(), m_html.size()), m_baseURL
); |
131 } | 131 } |
132 | 132 |
133 private: | 133 private: |
134 WebFrame* const m_frame; | 134 WebFrame* const m_frame; |
135 const std::string m_html; | 135 const std::string m_html; |
136 const WebURL m_baseURL; | 136 const WebURL m_baseURL; |
137 }; | 137 }; |
138 | 138 |
139 class LoadHistoryItemTask : public WebThread::Task { | 139 class LoadHistoryItemTask : public WebTaskRunner::Task { |
140 public: | 140 public: |
141 LoadHistoryItemTask(WebFrame* frame, const WebHistoryItem& item, WebHistoryL
oadType loadType, WebURLRequest::CachePolicy cachePolicy) | 141 LoadHistoryItemTask(WebFrame* frame, const WebHistoryItem& item, WebHistoryL
oadType loadType, WebURLRequest::CachePolicy cachePolicy) |
142 : m_frame(frame) | 142 : m_frame(frame) |
143 , m_item(item) | 143 , m_item(item) |
144 , m_loadType(loadType) | 144 , m_loadType(loadType) |
145 , m_cachePolicy(cachePolicy) | 145 , m_cachePolicy(cachePolicy) |
146 { | 146 { |
147 } | 147 } |
148 | 148 |
149 void run() override | 149 void run() override |
150 { | 150 { |
151 m_frame->loadHistoryItem(m_item, m_loadType, m_cachePolicy); | 151 m_frame->loadHistoryItem(m_item, m_loadType, m_cachePolicy); |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 WebFrame* const m_frame; | 155 WebFrame* const m_frame; |
156 const WebHistoryItem m_item; | 156 const WebHistoryItem m_item; |
157 const WebHistoryLoadType m_loadType; | 157 const WebHistoryLoadType m_loadType; |
158 const WebURLRequest::CachePolicy m_cachePolicy; | 158 const WebURLRequest::CachePolicy m_cachePolicy; |
159 }; | 159 }; |
160 | 160 |
161 class ReloadTask : public WebThread::Task { | 161 class ReloadTask : public WebTaskRunner::Task { |
162 public: | 162 public: |
163 ReloadTask(WebFrame* frame, bool ignoreCache) | 163 ReloadTask(WebFrame* frame, bool ignoreCache) |
164 : m_frame(frame) | 164 : m_frame(frame) |
165 , m_ignoreCache(ignoreCache) | 165 , m_ignoreCache(ignoreCache) |
166 { | 166 { |
167 } | 167 } |
168 | 168 |
169 void run() override | 169 void run() override |
170 { | 170 { |
171 m_frame->reload(m_ignoreCache); | 171 m_frame->reload(m_ignoreCache); |
(...skipping 17 matching lines...) Expand all Loading... |
189 } | 189 } |
190 | 190 |
191 } // namespace | 191 } // namespace |
192 | 192 |
193 void loadFrame(WebFrame* frame, const std::string& url) | 193 void loadFrame(WebFrame* frame, const std::string& url) |
194 { | 194 { |
195 WebURLRequest urlRequest; | 195 WebURLRequest urlRequest; |
196 urlRequest.initialize(); | 196 urlRequest.initialize(); |
197 urlRequest.setURL(URLTestHelpers::toKURL(url)); | 197 urlRequest.setURL(URLTestHelpers::toKURL(url)); |
198 | 198 |
199 Platform::current()->currentThread()->postTask(FROM_HERE, new LoadTask(frame
, urlRequest)); | 199 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new LoadTask(frame, urlRequest)); |
200 pumpPendingRequests(frame); | 200 pumpPendingRequests(frame); |
201 } | 201 } |
202 | 202 |
203 void loadHTMLString(WebFrame* frame, const std::string& html, const WebURL& base
URL) | 203 void loadHTMLString(WebFrame* frame, const std::string& html, const WebURL& base
URL) |
204 { | 204 { |
205 Platform::current()->currentThread()->postTask(FROM_HERE, new LoadHTMLString
Task(frame, html, baseURL)); | 205 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new LoadHTMLStringTask(frame, html, baseURL)); |
206 pumpPendingRequests(frame); | 206 pumpPendingRequests(frame); |
207 } | 207 } |
208 | 208 |
209 void loadHistoryItem(WebFrame* frame, const WebHistoryItem& item, WebHistoryLoad
Type loadType, WebURLRequest::CachePolicy cachePolicy) | 209 void loadHistoryItem(WebFrame* frame, const WebHistoryItem& item, WebHistoryLoad
Type loadType, WebURLRequest::CachePolicy cachePolicy) |
210 { | 210 { |
211 Platform::current()->currentThread()->postTask(FROM_HERE, new LoadHistoryIte
mTask(frame, item, loadType, cachePolicy)); | 211 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new LoadHistoryItemTask(frame, item, loadType, cachePolicy)); |
212 pumpPendingRequests(frame); | 212 pumpPendingRequests(frame); |
213 } | 213 } |
214 | 214 |
215 void reloadFrame(WebFrame* frame) | 215 void reloadFrame(WebFrame* frame) |
216 { | 216 { |
217 Platform::current()->currentThread()->postTask(FROM_HERE, new ReloadTask(fra
me, false)); | 217 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new ReloadTask(frame, false)); |
218 pumpPendingRequests(frame); | 218 pumpPendingRequests(frame); |
219 } | 219 } |
220 | 220 |
221 void reloadFrameIgnoringCache(WebFrame* frame) | 221 void reloadFrameIgnoringCache(WebFrame* frame) |
222 { | 222 { |
223 Platform::current()->currentThread()->postTask(FROM_HERE, new ReloadTask(fra
me, true)); | 223 Platform::current()->currentThread()->defaultTaskRunner()->postTask(FROM_HER
E, new ReloadTask(frame, true)); |
224 pumpPendingRequests(frame); | 224 pumpPendingRequests(frame); |
225 } | 225 } |
226 | 226 |
227 void pumpPendingRequestsDoNotUse(WebFrame* frame) | 227 void pumpPendingRequestsDoNotUse(WebFrame* frame) |
228 { | 228 { |
229 pumpPendingRequests(frame); | 229 pumpPendingRequests(frame); |
230 } | 230 } |
231 | 231 |
232 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) | 232 WebViewHelper::WebViewHelper(SettingOverrider* settingOverrider) |
233 : m_webView(0) | 233 : m_webView(0) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 void TestWebViewClient::initializeLayerTreeView() | 341 void TestWebViewClient::initializeLayerTreeView() |
342 { | 342 { |
343 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->createLay
erTreeViewForTesting()); | 343 m_layerTreeView = adoptPtr(Platform::current()->unitTestSupport()->createLay
erTreeViewForTesting()); |
344 ASSERT(m_layerTreeView); | 344 ASSERT(m_layerTreeView); |
345 } | 345 } |
346 | 346 |
347 } // namespace FrameTestHelpers | 347 } // namespace FrameTestHelpers |
348 } // namespace blink | 348 } // namespace blink |
OLD | NEW |