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

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

Issue 19574002: Refactoring: Introduce ResouceLoaderHost interface for unloading ResourceLoader. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Another attempt Created 7 years, 5 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/css/CSSFontSelector.cpp ('k') | Source/core/loader/ResourceLoader.h » ('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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (document() && document()->hasActiveParser()) 295 if (document() && document()->hasActiveParser())
296 return true; 296 return true;
297 297
298 return isLoadingMainResource() || !m_resourceLoaders.isEmpty(); 298 return isLoadingMainResource() || !m_resourceLoaders.isEmpty();
299 } 299 }
300 300
301 void DocumentLoader::notifyFinished(CachedResource* resource) 301 void DocumentLoader::notifyFinished(CachedResource* resource)
302 { 302 {
303 ASSERT_UNUSED(resource, m_mainResource == resource); 303 ASSERT_UNUSED(resource, m_mainResource == resource);
304 ASSERT(m_mainResource); 304 ASSERT(m_mainResource);
305
306 RefPtr<DocumentLoader> protect(this);
307
305 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 308 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
306 finishedLoading(m_mainResource->loadFinishTime()); 309 finishedLoading(m_mainResource->loadFinishTime());
307 return; 310 return;
308 } 311 }
309 312
310 mainReceivedError(m_mainResource->resourceError()); 313 mainReceivedError(m_mainResource->resourceError());
311 } 314 }
312 315
313 void DocumentLoader::finishedLoading(double finishTime) 316 void DocumentLoader::finishedLoading(double finishTime)
314 { 317 {
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 const KURL& DocumentLoader::unreachableURL() const 866 const KURL& DocumentLoader::unreachableURL() const
864 { 867 {
865 return m_substituteData.failingURL(); 868 return m_substituteData.failingURL();
866 } 869 }
867 870
868 void DocumentLoader::setDefersLoading(bool defers) 871 void DocumentLoader::setDefersLoading(bool defers)
869 { 872 {
870 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes, 873 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes,
871 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only 874 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only
872 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly. 875 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly.
873 if (mainResourceLoader() && mainResourceLoader()->documentLoader() == this) 876 if (mainResourceLoader() && mainResourceLoader()->isLoadedBy(m_cachedResourc eLoader.get()))
874 mainResourceLoader()->setDefersLoading(defers); 877 mainResourceLoader()->setDefersLoading(defers);
875 878
876 setAllDefersLoading(m_resourceLoaders, defers); 879 setAllDefersLoading(m_resourceLoaders, defers);
877 } 880 }
878 881
879 void DocumentLoader::stopLoadingSubresources() 882 void DocumentLoader::stopLoadingSubresources()
880 { 883 {
881 cancelAll(m_resourceLoaders); 884 cancelAll(m_resourceLoaders);
882 } 885 }
883 886
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt) 1068 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt)
1066 { 1069 {
1067 m_frame->loader()->stopAllLoaders(); 1070 m_frame->loader()->stopAllLoaders();
1068 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : "", m_writer ? m_writer->encod ingWasChosenByUser() : false, true); 1071 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : "", m_writer ? m_writer->encod ingWasChosenByUser() : false, true);
1069 if (!source.isNull()) 1072 if (!source.isNull())
1070 m_writer->appendReplacingData(source); 1073 m_writer->appendReplacingData(source);
1071 endWriting(m_writer.get()); 1074 endWriting(m_writer.get());
1072 } 1075 }
1073 1076
1074 } // namespace WebCore 1077 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontSelector.cpp ('k') | Source/core/loader/ResourceLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698