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

Side by Side Diff: Source/core/loader/PingLoader.cpp

Issue 1311433008: Migrate PingLoader to be a LocalFrameLifecycleObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix style. Created 5 years, 3 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
« no previous file with comments | « Source/core/loader/PingLoader.h ('k') | Source/web/tests/WebFrameTest.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 { 127 {
128 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) 128 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url()))
129 return; 129 return;
130 130
131 // Leak the ping loader, since it will kill itself as soon as it receives a response. 131 // Leak the ping loader, since it will kill itself as soon as it receives a response.
132 RefPtrWillBeRawPtr<PingLoader> loader = adoptRefWillBeNoop(new PingLoader(fr ame, request, initiatorInfo, credentialsAllowed)); 132 RefPtrWillBeRawPtr<PingLoader> loader = adoptRefWillBeNoop(new PingLoader(fr ame, request, initiatorInfo, credentialsAllowed));
133 loader->ref(); 133 loader->ref();
134 } 134 }
135 135
136 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed) 136 PingLoader::PingLoader(LocalFrame* frame, ResourceRequest& request, const FetchI nitiatorInfo& initiatorInfo, StoredCredentials credentialsAllowed)
137 : PageLifecycleObserver(frame->page()) 137 : LocalFrameLifecycleObserver(frame)
138 , m_timeout(this, &PingLoader::timeout) 138 , m_timeout(this, &PingLoader::timeout)
139 , m_url(request.url()) 139 , m_url(request.url())
140 , m_identifier(createUniqueIdentifier()) 140 , m_identifier(createUniqueIdentifier())
141 { 141 {
142 frame->loader().client()->didDispatchPingLoader(request.url()); 142 frame->loader().client()->didDispatchPingLoader(request.url());
143 143
144 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT _SCOPE_THREAD, "data", InspectorSendRequestEvent::data(m_identifier, frame, requ est)); 144 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT _SCOPE_THREAD, "data", InspectorSendRequestEvent::data(m_identifier, frame, requ est));
145 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader ().documentLoader(), request, ResourceResponse(), initiatorInfo); 145 InspectorInstrumentation::willSendRequest(frame, m_identifier, frame->loader ().documentLoader(), request, ResourceResponse(), initiatorInfo);
146 146
147 m_loader = adoptPtr(Platform::current()->createURLLoader()); 147 m_loader = adoptPtr(Platform::current()->createURLLoader());
(...skipping 17 matching lines...) Expand all
165 { 165 {
166 if (m_loader) { 166 if (m_loader) {
167 m_loader->cancel(); 167 m_loader->cancel();
168 m_loader = nullptr; 168 m_loader = nullptr;
169 } 169 }
170 deref(); 170 deref();
171 } 171 }
172 172
173 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons e) 173 void PingLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& respons e)
174 { 174 {
175 if (Page* page = this->page()) { 175 if (LocalFrame* frame = this->frame()) {
176 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ; 176 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ;
177 const ResourceResponse& resourceResponse = response.toResourceResponse() ; 177 const ResourceResponse& resourceResponse = response.toResourceResponse() ;
178 InspectorInstrumentation::didReceiveResourceResponse(page->deprecatedLoc alMainFrame(), m_identifier, 0, resourceResponse, 0); 178 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier , 0, resourceResponse, 0);
179 didFailLoading(page); 179 didFailLoading(frame);
180 } 180 }
181 dispose(); 181 dispose();
182 } 182 }
183 183
184 void PingLoader::didReceiveData(WebURLLoader*, const char*, int, int) 184 void PingLoader::didReceiveData(WebURLLoader*, const char*, int, int)
185 { 185 {
186 if (Page* page = this->page()) { 186 if (LocalFrame* frame = this->frame()) {
187 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ; 187 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ;
188 didFailLoading(page); 188 didFailLoading(frame);
189 } 189 }
190 dispose(); 190 dispose();
191 } 191 }
192 192
193 void PingLoader::didFinishLoading(WebURLLoader*, double, int64_t) 193 void PingLoader::didFinishLoading(WebURLLoader*, double, int64_t)
194 { 194 {
195 if (Page* page = this->page()) { 195 if (LocalFrame* frame = this->frame()) {
196 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ; 196 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ;
197 didFailLoading(page); 197 didFailLoading(frame);
198 } 198 }
199 dispose(); 199 dispose();
200 } 200 }
201 201
202 void PingLoader::didFail(WebURLLoader*, const WebURLError& resourceError) 202 void PingLoader::didFail(WebURLLoader*, const WebURLError& resourceError)
203 { 203 {
204 if (Page* page = this->page()) { 204 if (LocalFrame* frame = this->frame()) {
205 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ; 205 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ;
206 didFailLoading(page); 206 didFailLoading(frame);
207 } 207 }
208 dispose(); 208 dispose();
209 } 209 }
210 210
211 void PingLoader::timeout(Timer<PingLoader>*) 211 void PingLoader::timeout(Timer<PingLoader>*)
212 { 212 {
213 if (Page* page = this->page()) { 213 if (LocalFrame* frame = this->frame()) {
214 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ; 214 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)) ;
215 didFailLoading(page); 215 didFailLoading(frame);
216 } 216 }
217 dispose(); 217 dispose();
218 } 218 }
219 219
220 void PingLoader::didFailLoading(Page* page) 220 void PingLoader::didFailLoading(LocalFrame* frame)
221 { 221 {
222 LocalFrame* frame = page->deprecatedLocalMainFrame();
223 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError: :cancelledError(m_url)); 222 InspectorInstrumentation::didFailLoading(frame, m_identifier, ResourceError: :cancelledError(m_url));
224 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError( m_url)); 223 frame->console().didFailLoading(m_identifier, ResourceError::cancelledError( m_url));
225 } 224 }
226 225
227 DEFINE_TRACE(PingLoader) 226 DEFINE_TRACE(PingLoader)
228 { 227 {
229 PageLifecycleObserver::trace(visitor); 228 LocalFrameLifecycleObserver::trace(visitor);
230 } 229 }
231 230
232 } // namespace blink 231 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/PingLoader.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698