FrameLoader::icon() should return a reference.
<https://webkit.org/b/120993>

Reviewed by Antti Koivisto.

This function never returns null. Make it return a reference!


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155300 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index caa6079..e0ddcc4 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,5 +1,14 @@
 2013-09-08  Andreas Kling  <akling@apple.com>
 
+        FrameLoader::icon() should return a reference.
+        <https://webkit.org/b/120993>
+
+        Reviewed by Antti Koivisto.
+
+        This function never returns null. Make it return a reference!
+
+2013-09-08  Andreas Kling  <akling@apple.com>
+
         Remove unused Scrollbar tickmark stuff.
         <https://webkit.org/b/121000>
 
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index ca6b214..6e02538 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -2396,7 +2396,7 @@
     // ramifications, and we need to decide what is the Right Thing To Do(tm)
     Frame* f = frame();
     if (f) {
-        f->loader().icon()->startLoader();
+        f->loader().icon().startLoader();
         f->animation().startAnimationsIfNotSuspended(this);
     }
 
diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp
index 9c7672f..373ca5d 100644
--- a/Source/WebCore/inspector/InspectorResourceAgent.cpp
+++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp
@@ -201,7 +201,7 @@
     if (type == InspectorPageAgent::OtherResource) {
         if (m_loadingXHRSynchronously)
             type = InspectorPageAgent::XHRResource;
-        else if (equalIgnoringFragmentIdentifier(request.url(), loader->frameLoader()->icon()->url()))
+        else if (equalIgnoringFragmentIdentifier(request.url(), loader->frameLoader()->icon().url()))
             type = InspectorPageAgent::ImageResource;
         else if (equalIgnoringFragmentIdentifier(request.url(), loader->url()) && !loader->isCommitted())
             type = InspectorPageAgent::DocumentResource;
diff --git a/Source/WebCore/loader/DocumentLoader.cpp b/Source/WebCore/loader/DocumentLoader.cpp
index 01abc53..de92970 100644
--- a/Source/WebCore/loader/DocumentLoader.cpp
+++ b/Source/WebCore/loader/DocumentLoader.cpp
@@ -1467,7 +1467,7 @@
 void DocumentLoader::iconLoadDecisionAvailable()
 {
     if (m_frame)
-        m_frame->loader().icon()->loadDecisionReceived(iconDatabase().synchronousLoadDecisionForIconURL(frameLoader()->icon()->url(), this));
+        m_frame->loader().icon().loadDecisionReceived(iconDatabase().synchronousLoadDecisionForIconURL(frameLoader()->icon().url(), this));
 }
 
 static void iconLoadDecisionCallback(IconLoadDecision decision, void* context)
@@ -1488,7 +1488,7 @@
     ASSERT(m_iconLoadDecisionCallback);
     m_iconLoadDecisionCallback = 0;
     if (m_frame)
-        m_frame->loader().icon()->continueLoadWithDecision(decision);
+        m_frame->loader().icon().continueLoadWithDecision(decision);
 }
 
 static void iconDataCallback(SharedBuffer*, void*)
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 43b0f21..10edecf 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -485,7 +485,7 @@
         parser->finish();
     }
     
-    icon()->stopLoader();
+    icon().stopLoader();
 }
 
 void FrameLoader::willTransitionToCommitted()
diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h
index 69e4e62..f57e5ef 100644
--- a/Source/WebCore/loader/FrameLoader.h
+++ b/Source/WebCore/loader/FrameLoader.h
@@ -96,7 +96,7 @@
     HistoryController& history() const { return *m_history; }
     ResourceLoadNotifier* notifier() const { return &m_notifer; }
     SubframeLoader& subframeLoader() const { return *m_subframeLoader; }
-    IconController* icon() const { return m_icon.get(); }
+    IconController& icon() const { return *m_icon; }
     MixedContentChecker& mixedContentChecker() const { return m_mixedContentChecker; }
 
     void prepareForHistoryNavigation();
@@ -391,7 +391,7 @@
     mutable ResourceLoadNotifier m_notifer;
     const OwnPtr<SubframeLoader> m_subframeLoader;
     mutable FrameLoaderStateMachine m_stateMachine;
-    OwnPtr<IconController> m_icon;
+    const OwnPtr<IconController> m_icon;
     mutable MixedContentChecker m_mixedContentChecker;
 
     class FrameProgressTracker;
diff --git a/Source/WebCore/loader/icon/IconLoader.cpp b/Source/WebCore/loader/icon/IconLoader.cpp
index c32d1bc..7883869 100644
--- a/Source/WebCore/loader/icon/IconLoader.cpp
+++ b/Source/WebCore/loader/icon/IconLoader.cpp
@@ -63,7 +63,7 @@
     if (m_resource || !m_frame->document())
         return;
 
-    CachedResourceRequest request(ResourceRequest(m_frame->loader().icon()->url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForAnyCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType));
+    CachedResourceRequest request(ResourceRequest(m_frame->loader().icon().url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForAnyCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType));
 
 #if PLATFORM(BLACKBERRY)
     request.mutableResourceRequest().setTargetType(ResourceRequest::TargetIsFavicon);
@@ -75,7 +75,7 @@
     if (m_resource)
         m_resource->addClient(this);
     else
-        LOG_ERROR("Failed to start load for icon at url %s", m_frame->loader().icon()->url().string().ascii().data());
+        LOG_ERROR("Failed to start load for icon at url %s", m_frame->loader().icon().url().string().ascii().data());
 }
 
 void IconLoader::stopLoading()
@@ -105,7 +105,7 @@
     }
 
     LOG(IconDatabase, "IconLoader::finishLoading() - Committing iconURL %s to database", resource->url().string().ascii().data());
-    m_frame->loader().icon()->commitToDatabase(resource->url());
+    m_frame->loader().icon().commitToDatabase(resource->url());
     // Setting the icon data only after committing to the database ensures that the data is
     // kept in memory (so it does not have to be read from the database asynchronously), since
     // there is a page URL referencing it.