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

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

Issue 31063004: Have Frame::loader() return a reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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/loader/DocumentThreadableLoader.cpp ('k') | Source/core/loader/FrameLoader.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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 void FrameFetchContext::reportLocalLoadFailed(const KURL& url) 51 void FrameFetchContext::reportLocalLoadFailed(const KURL& url)
52 { 52 {
53 FrameLoader::reportLocalLoadFailed(m_frame, url.elidedString()); 53 FrameLoader::reportLocalLoadFailed(m_frame, url.elidedString());
54 } 54 }
55 55
56 void FrameFetchContext::addAdditionalRequestHeaders(Document& document, Resource Request& request, Resource::Type type) 56 void FrameFetchContext::addAdditionalRequestHeaders(Document& document, Resource Request& request, Resource::Type type)
57 { 57 {
58 bool isMainResource = type == Resource::MainResource; 58 bool isMainResource = type == Resource::MainResource;
59 59
60 FrameLoader* frameLoader = m_frame->loader(); 60 FrameLoader& frameLoader = m_frame->loader();
61 61
62 if (!isMainResource) { 62 if (!isMainResource) {
63 String outgoingReferrer; 63 String outgoingReferrer;
64 String outgoingOrigin; 64 String outgoingOrigin;
65 if (request.httpReferrer().isNull()) { 65 if (request.httpReferrer().isNull()) {
66 outgoingReferrer = frameLoader->outgoingReferrer(); 66 outgoingReferrer = frameLoader.outgoingReferrer();
67 outgoingOrigin = frameLoader->outgoingOrigin(); 67 outgoingOrigin = frameLoader.outgoingOrigin();
68 } else { 68 } else {
69 outgoingReferrer = request.httpReferrer(); 69 outgoingReferrer = request.httpReferrer();
70 outgoingOrigin = SecurityOrigin::createFromString(outgoingReferrer)- >toString(); 70 outgoingOrigin = SecurityOrigin::createFromString(outgoingReferrer)- >toString();
71 } 71 }
72 72
73 outgoingReferrer = SecurityPolicy::generateReferrerHeader(document.refer rerPolicy(), request.url(), outgoingReferrer); 73 outgoingReferrer = SecurityPolicy::generateReferrerHeader(document.refer rerPolicy(), request.url(), outgoingReferrer);
74 if (outgoingReferrer.isEmpty()) 74 if (outgoingReferrer.isEmpty())
75 request.clearHTTPReferrer(); 75 request.clearHTTPReferrer();
76 else if (!request.httpReferrer()) 76 else if (!request.httpReferrer())
77 request.setHTTPReferrer(outgoingReferrer); 77 request.setHTTPReferrer(outgoingReferrer);
78 78
79 FrameLoader::addHTTPOriginIfNeeded(request, outgoingOrigin); 79 FrameLoader::addHTTPOriginIfNeeded(request, outgoingOrigin);
80 } 80 }
81 81
82 frameLoader->addExtraFieldsToRequest(request); 82 frameLoader.addExtraFieldsToRequest(request);
83 } 83 }
84 84
85 CachePolicy FrameFetchContext::cachePolicy(Resource::Type type) const 85 CachePolicy FrameFetchContext::cachePolicy(Resource::Type type) const
86 { 86 {
87 if (type != Resource::MainResource) 87 if (type != Resource::MainResource)
88 return m_frame->loader()->subresourceCachePolicy(); 88 return m_frame->loader().subresourceCachePolicy();
89 89
90 if (m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin || m_fram e->loader()->loadType() == FrameLoadTypeReload) 90 if (m_frame->loader().loadType() == FrameLoadTypeReloadFromOrigin || m_frame ->loader().loadType() == FrameLoadTypeReload)
91 return CachePolicyReload; 91 return CachePolicyReload;
92 return CachePolicyVerify; 92 return CachePolicyVerify;
93 93
94 } 94 }
95 95
96 // FIXME(http://crbug.com/274173): 96 // FIXME(http://crbug.com/274173):
97 // |loader| can be null if the resource is loaded from imported document. 97 // |loader| can be null if the resource is loaded from imported document.
98 // This means inspector, which uses DocumentLoader as an grouping entity, 98 // This means inspector, which uses DocumentLoader as an grouping entity,
99 // cannot see imported documents. 99 // cannot see imported documents.
100 inline DocumentLoader* FrameFetchContext::ensureLoader(DocumentLoader* loader) 100 inline DocumentLoader* FrameFetchContext::ensureLoader(DocumentLoader* loader)
101 { 101 {
102 return loader ? loader : m_frame->loader()->activeDocumentLoader(); 102 return loader ? loader : m_frame->loader().activeDocumentLoader();
103 } 103 }
104 104
105 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi er, ResourceLoadPriority loadPriority) 105 void FrameFetchContext::dispatchDidChangeResourcePriority(unsigned long identifi er, ResourceLoadPriority loadPriority)
106 { 106 {
107 m_frame->loader()->client()->dispatchDidChangeResourcePriority(identifier, l oadPriority); 107 m_frame->loader().client()->dispatchDidChangeResourcePriority(identifier, lo adPriority);
108 } 108 }
109 109
110 void FrameFetchContext::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResp onse, const FetchInitiatorInfo& initiatorInfo) 110 void FrameFetchContext::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResp onse, const FetchInitiatorInfo& initiatorInfo)
111 { 111 {
112 m_frame->loader()->applyUserAgent(request); 112 m_frame->loader().applyUserAgent(request);
113 m_frame->loader()->client()->dispatchWillSendRequest(loader, identifier, req uest, redirectResponse); 113 m_frame->loader().client()->dispatchWillSendRequest(loader, identifier, requ est, redirectResponse);
114 InspectorInstrumentation::willSendRequest(m_frame, identifier, ensureLoader( loader), request, redirectResponse, initiatorInfo); 114 InspectorInstrumentation::willSendRequest(m_frame, identifier, ensureLoader( loader), request, redirectResponse, initiatorInfo);
115 } 115 }
116 116
117 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const ResourceReq uest& request, const ResourceResponse& response) 117 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(const ResourceReq uest& request, const ResourceResponse& response)
118 { 118 {
119 m_frame->loader()->client()->dispatchDidLoadResourceFromMemoryCache(request, response); 119 m_frame->loader().client()->dispatchDidLoadResourceFromMemoryCache(request, response);
120 } 120 }
121 121
122 void FrameFetchContext::dispatchDidReceiveResponse(DocumentLoader* loader, unsig ned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader) 122 void FrameFetchContext::dispatchDidReceiveResponse(DocumentLoader* loader, unsig ned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader)
123 { 123 {
124 if (Page* page = m_frame->page()) 124 if (Page* page = m_frame->page())
125 page->progress().incrementProgress(identifier, r); 125 page->progress().incrementProgress(identifier, r);
126 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv eResourceResponse(m_frame, identifier, r); 126 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv eResourceResponse(m_frame, identifier, r);
127 m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r); 127 m_frame->loader().client()->dispatchDidReceiveResponse(loader, identifier, r );
128 InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, ens ureLoader(loader), r, resourceLoader); 128 InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, ens ureLoader(loader), r, resourceLoader);
129 } 129 }
130 130
131 void FrameFetchContext::dispatchDidReceiveData(DocumentLoader*, unsigned long id entifier, const char* data, int dataLength, int encodedDataLength) 131 void FrameFetchContext::dispatchDidReceiveData(DocumentLoader*, unsigned long id entifier, const char* data, int dataLength, int encodedDataLength)
132 { 132 {
133 if (Page* page = m_frame->page()) 133 if (Page* page = m_frame->page())
134 page->progress().incrementProgress(identifier, data, dataLength); 134 page->progress().incrementProgress(identifier, data, dataLength);
135 InspectorInstrumentation::didReceiveData(m_frame, identifier, data, dataLeng th, encodedDataLength); 135 InspectorInstrumentation::didReceiveData(m_frame, identifier, data, dataLeng th, encodedDataLength);
136 } 136 }
137 137
138 void FrameFetchContext::dispatchDidFinishLoading(DocumentLoader* loader, unsigne d long identifier, double finishTime) 138 void FrameFetchContext::dispatchDidFinishLoading(DocumentLoader* loader, unsigne d long identifier, double finishTime)
139 { 139 {
140 if (Page* page = m_frame->page()) 140 if (Page* page = m_frame->page())
141 page->progress().completeProgress(identifier); 141 page->progress().completeProgress(identifier);
142 m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier); 142 m_frame->loader().client()->dispatchDidFinishLoading(loader, identifier);
143 143
144 InspectorInstrumentation::didFinishLoading(m_frame, identifier, ensureLoader (loader), finishTime); 144 InspectorInstrumentation::didFinishLoading(m_frame, identifier, ensureLoader (loader), finishTime);
145 } 145 }
146 146
147 void FrameFetchContext::dispatchDidFail(DocumentLoader* loader, unsigned long id entifier, const ResourceError& error) 147 void FrameFetchContext::dispatchDidFail(DocumentLoader* loader, unsigned long id entifier, const ResourceError& error)
148 { 148 {
149 if (Page* page = m_frame->page()) 149 if (Page* page = m_frame->page())
150 page->progress().completeProgress(identifier); 150 page->progress().completeProgress(identifier);
151 InspectorInstrumentation::didFailLoading(m_frame, identifier, ensureLoader(l oader), error); 151 InspectorInstrumentation::didFailLoading(m_frame, identifier, ensureLoader(l oader), error);
152 } 152 }
153 153
154 void FrameFetchContext::sendRemainingDelegateMessages(DocumentLoader* loader, un signed long identifier, const ResourceResponse& response, const char* data, int dataLength, int encodedDataLength, const ResourceError& error) 154 void FrameFetchContext::sendRemainingDelegateMessages(DocumentLoader* loader, un signed long identifier, const ResourceResponse& response, const char* data, int dataLength, int encodedDataLength, const ResourceError& error)
155 { 155 {
156 if (!response.isNull()) 156 if (!response.isNull())
157 dispatchDidReceiveResponse(ensureLoader(loader), identifier, response); 157 dispatchDidReceiveResponse(ensureLoader(loader), identifier, response);
158 158
159 if (dataLength > 0) 159 if (dataLength > 0)
160 dispatchDidReceiveData(ensureLoader(loader), identifier, data, dataLengt h, encodedDataLength); 160 dispatchDidReceiveData(ensureLoader(loader), identifier, data, dataLengt h, encodedDataLength);
161 161
162 if (error.isNull()) 162 if (error.isNull())
163 dispatchDidFinishLoading(ensureLoader(loader), identifier, 0); 163 dispatchDidFinishLoading(ensureLoader(loader), identifier, 0);
164 else 164 else
165 dispatchDidFail(ensureLoader(loader), identifier, error); 165 dispatchDidFail(ensureLoader(loader), identifier, error);
166 } 166 }
167 167
168 } // namespace WebCore 168 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/DocumentThreadableLoader.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698