Changeset 21245 in webkit
- Timestamp:
- May 3, 2007, 9:35:28 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21244 r21245 1 <<<<<<< .mine 1 2007-05-03 Brady Eidson <beidson@apple.com> 2 3 Reviewed by Oliver 4 5 Resolve an outstanding FIXME in Loader::numRequests() 6 7 Before, numRequests() would iterate through the list of requests pending load and the list of currently 8 loading requests and tally up a count matching the current DocLoader. 9 10 I noticed while studying and cleaning up the loader code that numRequests() is potentially very hot! 11 Indeed load a complex site with many resources and multiple frames, and this method gets called very often, 12 tallying up this number every time. 13 14 The FIXME was to keep a collection of Requests mapped to each DocLoader. In reality, since this map would 15 simply be used for retrieving a count, that was overkill. Keeping a request count in the DocLoader itself 16 along with maintaining that count in Loader as requests come and go is a much better way to do this. 17 18 * loader/DocLoader.cpp: 19 (WebCore::DocLoader::DocLoader): 20 (WebCore::DocLoader::incrementRequestCount): 21 (WebCore::DocLoader::decrementRequestCount): 22 (WebCore::DocLoader::requestCount): Emulate the defunct Loader::numRequests() 23 * loader/DocLoader.h: 24 25 * loader/FrameLoader.cpp: 26 (WebCore::numRequests): Call DocLoader::requestCount() directly 27 (WebCore::FrameLoader::checkCompleted): Use numRequests() 28 29 * loader/loader.cpp: 30 (WebCore::Loader::load): Increment the DocLoader's request count 31 (WebCore::Loader::servePendingRequests): If the SubresourceLoader failed to create, decrement the count 32 (WebCore::Loader::didFinishLoading): If the Request is not Multipart, decrement the count 33 (WebCore::Loader::didFail): If the Request is not Multipart, decrement the count 34 (WebCore::Loader::didReceiveResponse): If the Request becomes Multipart, decrement the count 35 (WebCore::Loader::cancelRequests): Decrement the count for the pending requests being tossed, and ASSERT the 36 count is zero after all requests have been cancelled 37 * loader/loader.h: 38 2 39 2007-05-03 Geoffrey Garen <ggaren@apple.com> 3 40 … … 19 56 * loader/FrameLoader.h: 20 57 21 =======22 58 2007-05-03 Justin Garcia <justin.garcia@apple.com> 23 59 … … 32 68 Nil-check checkAncestor and lastClosed. 33 69 34 >>>>>>> .r2124335 70 2007-05-03 Timothy Hatcher <timothy@apple.com> 36 71 -
trunk/WebCore/loader/DocLoader.cpp
r20674 r21245 46 46 , m_frame(frame) 47 47 , m_doc(doc) 48 , m_requestCount(0) 48 49 , m_autoLoadImages(true) 49 50 , m_loadInProgress(false) … … 206 207 } 207 208 208 } 209 void DocLoader::incrementRequestCount() 210 { 211 ++m_requestCount; 212 } 213 214 void DocLoader::decrementRequestCount() 215 { 216 --m_requestCount; 217 ASSERT(m_requestCount > -1); 218 } 219 220 int DocLoader::requestCount() 221 { 222 if (loadInProgress()) 223 return m_requestCount + 1; 224 return m_requestCount; 225 } 226 227 } -
trunk/WebCore/loader/DocLoader.h
r21009 r21245 89 89 #endif 90 90 91 void incrementRequestCount(); 92 void decrementRequestCount(); 93 int requestCount(); 91 94 private: 92 95 CachedResource* requestResource(CachedResource::Type, const String& url, const String* charset = 0, bool skipCanLoadCheck = false); … … 102 105 Document *m_doc; 103 106 107 int m_requestCount; 108 104 109 //29 bits left 105 110 bool m_autoLoadImages : 1; -
trunk/WebCore/loader/FrameLoader.cpp
r21244 r21245 196 196 static int numRequests(Document* document) 197 197 { 198 if (document) 199 return cache()->loader()->numRequests(document->docLoader()); 200 return 0; 198 if (!document) 199 return 0; 200 201 return document->docLoader()->requestCount(); 201 202 } 202 203 … … 1127 1128 1128 1129 // Still waiting for images/scripts? 1129 if (m_frame->document() && m_frame->document()->docLoader())1130 if ( cache()->loader()->numRequests(m_frame->document()->docLoader()))1130 if (m_frame->document()) 1131 if (numRequests(m_frame->document())) 1131 1132 return; 1132 1133 -
trunk/WebCore/loader/loader.cpp
r20299 r21245 59 59 void Loader::load(DocLoader* dl, CachedResource* object, bool incremental, bool skipCanLoadCheck) 60 60 { 61 ASSERT(dl); 61 62 Request* req = new Request(dl, object, incremental); 62 63 m_requestsPending.append(req); 64 dl->incrementRequestCount(); 63 65 servePendingRequests(skipCanLoadCheck); 64 66 } … … 71 73 // get the first pending request 72 74 Request* req = m_requestsPending.take(0); 75 DocLoader* dl = req->docLoader(); 76 dl->decrementRequestCount(); 73 77 74 78 ResourceRequest request(req->cachedResource()->url()); … … 76 80 if (!req->cachedResource()->accept().isEmpty()) 77 81 request.setHTTPAccept(req->cachedResource()->accept()); 78 if (req->docLoader()) { 79 KURL r = req->docLoader()->doc()->URL(); 80 if (r.protocol().startsWith("http") && r.path().isEmpty()) 81 r.setPath("/"); 82 request.setHTTPReferrer(r.url()); 83 DeprecatedString domain = r.host(); 84 if (req->docLoader()->doc()->isHTMLDocument()) 85 domain = static_cast<HTMLDocument*>(req->docLoader()->doc())->domain().deprecatedString(); 86 } 87 88 RefPtr<SubresourceLoader> loader = SubresourceLoader::create(req->docLoader()->doc()->frame(), this, request, skipCanLoadCheck); 89 90 if (loader) 82 83 KURL r = dl->doc()->URL(); 84 if (r.protocol().startsWith("http") && r.path().isEmpty()) 85 r.setPath("/"); 86 request.setHTTPReferrer(r.url()); 87 DeprecatedString domain = r.host(); 88 if (dl->doc()->isHTMLDocument()) 89 domain = static_cast<HTMLDocument*>(dl->doc())->domain().deprecatedString(); 90 91 RefPtr<SubresourceLoader> loader = SubresourceLoader::create(dl->doc()->frame(), this, request, skipCanLoadCheck); 92 93 if (loader) { 91 94 m_requestsLoading.add(loader.release(), req); 95 dl->incrementRequestCount(); 96 } 92 97 } 93 98 … … 100 105 Request* req = i->second; 101 106 m_requestsLoading.remove(i); 107 DocLoader* docLoader = req->docLoader(); 108 if (!req->isMultipart()) 109 docLoader->decrementRequestCount(); 102 110 103 111 CachedResource* object = req->cachedResource(); 104 DocLoader* docLoader = req->docLoader();105 112 106 113 docLoader->setLoadInProgress(true); … … 127 134 Request* req = i->second; 128 135 m_requestsLoading.remove(i); 136 DocLoader* docLoader = req->docLoader(); 137 if (!req->isMultipart()) 138 docLoader->decrementRequestCount(); 129 139 130 140 CachedResource* object = req->cachedResource(); 131 DocLoader* docLoader = req->docLoader();132 141 133 142 if (!cancelled) { … … 161 170 } else if (response.isMultipart()) { 162 171 req->setIsMultipart(true); 172 173 // We don't count multiParts in a DocLoader's request count 174 req->docLoader()->decrementRequestCount(); 175 163 176 // If we get a multipart response, we must have a handle 164 177 ASSERT(loader->handle()); … … 184 197 } 185 198 186 int Loader::numRequests(DocLoader* dl) const187 {188 // FIXME: Maybe we should keep a collection of requests by DocLoader, so we can do this instantly.189 190 int res = 0;191 192 DeprecatedPtrListIterator<Request> pIt(m_requestsPending);193 for (; pIt.current(); ++pIt) {194 if (pIt.current()->docLoader() == dl)195 res++;196 }197 198 RequestMap::const_iterator end = m_requestsLoading.end();199 for (RequestMap::const_iterator i = m_requestsLoading.begin(); !(i == end); ++i) {200 Request* r = i->second;201 res += (r->docLoader() == dl && !r->isMultipart());202 }203 204 if (dl->loadInProgress())205 res++;206 207 return res;208 }209 210 199 void Loader::cancelRequests(DocLoader* dl) 211 200 { … … 215 204 cache()->remove(pIt.current()->cachedResource()); 216 205 m_requestsPending.remove(pIt); 206 dl->decrementRequestCount(); 217 207 } else 218 208 ++pIt; … … 232 222 didFail(loader, true); 233 223 } 224 225 if (dl->loadInProgress()) 226 ASSERT(dl->requestCount() == 1); 227 else 228 ASSERT(dl->requestCount() == 0); 234 229 } 235 230 -
trunk/WebCore/loader/loader.h
r20299 r21245 52 52 void load(DocLoader*, CachedResource*, bool incremental = true, bool skipCanLoadCheck = false); 53 53 54 int numRequests(DocLoader*) const;55 54 void cancelRequests(DocLoader*); 56 57 55 private: 58 56 virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
Note:
See TracChangeset
for help on using the changeset viewer.