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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 787333003: Clean up render_frame_impl.cc removing unnecessary static. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (urls[i] != GURL(kSwappedOutURL)) 240 if (urls[i] != GURL(kSwappedOutURL))
241 result->push_back(urls[i]); 241 result->push_back(urls[i]);
242 else 242 else
243 result->push_back(blank_url); 243 result->push_back(blank_url);
244 } 244 }
245 } 245 }
246 246
247 // Returns the original request url. If there is no redirect, the original 247 // Returns the original request url. If there is no redirect, the original
248 // url is the same as ds->request()->url(). If the WebDataSource belongs to a 248 // url is the same as ds->request()->url(). If the WebDataSource belongs to a
249 // frame was loaded by loadData, the original url will be ds->unreachableURL() 249 // frame was loaded by loadData, the original url will be ds->unreachableURL()
250 static GURL GetOriginalRequestURL(WebDataSource* ds) { 250 GURL GetOriginalRequestURL(WebDataSource* ds) {
251 // WebDataSource has unreachable URL means that the frame is loaded through 251 // WebDataSource has unreachable URL means that the frame is loaded through
252 // blink::WebFrame::loadData(), and the base URL will be in the redirect 252 // blink::WebFrame::loadData(), and the base URL will be in the redirect
253 // chain. However, we never visited the baseURL. So in this case, we should 253 // chain. However, we never visited the baseURL. So in this case, we should
254 // use the unreachable URL as the original URL. 254 // use the unreachable URL as the original URL.
255 if (ds->hasUnreachableURL()) 255 if (ds->hasUnreachableURL())
256 return ds->unreachableURL(); 256 return ds->unreachableURL();
257 257
258 std::vector<GURL> redirects; 258 std::vector<GURL> redirects;
259 GetRedirectChain(ds, &redirects); 259 GetRedirectChain(ds, &redirects);
260 if (!redirects.empty()) 260 if (!redirects.empty())
261 return redirects.at(0); 261 return redirects.at(0);
262 262
263 return ds->originalRequest().url(); 263 return ds->originalRequest().url();
264 } 264 }
265 265
266 NOINLINE static void CrashIntentionally() { 266 NOINLINE void CrashIntentionally() {
267 // NOTE(shess): Crash directly rather than using NOTREACHED() so 267 // NOTE(shess): Crash directly rather than using NOTREACHED() so
268 // that the signature is easier to triage in crash reports. 268 // that the signature is easier to triage in crash reports.
269 volatile int* zero = NULL; 269 volatile int* zero = NULL;
270 *zero = 0; 270 *zero = 0;
271 } 271 }
272 272
273 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 273 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
274 NOINLINE static void MaybeTriggerAsanError(const GURL& url) { 274 NOINLINE void MaybeTriggerAsanError(const GURL& url) {
275 // NOTE(rogerm): We intentionally perform an invalid heap access here in 275 // NOTE(rogerm): We intentionally perform an invalid heap access here in
276 // order to trigger an Address Sanitizer (ASAN) error report. 276 // order to trigger an Address Sanitizer (ASAN) error report.
277 const char kCrashDomain[] = "crash"; 277 const char kCrashDomain[] = "crash";
278 const char kHeapOverflow[] = "/heap-overflow"; 278 const char kHeapOverflow[] = "/heap-overflow";
279 const char kHeapUnderflow[] = "/heap-underflow"; 279 const char kHeapUnderflow[] = "/heap-underflow";
280 const char kUseAfterFree[] = "/use-after-free"; 280 const char kUseAfterFree[] = "/use-after-free";
281 #if defined(SYZYASAN) 281 #if defined(SYZYASAN)
282 const char kCorruptHeapBlock[] = "/corrupt-heap-block"; 282 const char kCorruptHeapBlock[] = "/corrupt-heap-block";
283 const char kCorruptHeap[] = "/corrupt-heap"; 283 const char kCorruptHeap[] = "/corrupt-heap";
284 #endif 284 #endif
(...skipping 14 matching lines...) Expand all
299 #if defined(SYZYASAN) 299 #if defined(SYZYASAN)
300 } else if (crash_type == kCorruptHeapBlock) { 300 } else if (crash_type == kCorruptHeapBlock) {
301 base::debug::AsanCorruptHeapBlock(); 301 base::debug::AsanCorruptHeapBlock();
302 } else if (crash_type == kCorruptHeap) { 302 } else if (crash_type == kCorruptHeap) {
303 base::debug::AsanCorruptHeap(); 303 base::debug::AsanCorruptHeap();
304 #endif 304 #endif
305 } 305 }
306 } 306 }
307 #endif // ADDRESS_SANITIZER || SYZYASAN 307 #endif // ADDRESS_SANITIZER || SYZYASAN
308 308
309 static void MaybeHandleDebugURL(const GURL& url) { 309 void MaybeHandleDebugURL(const GURL& url) {
310 if (!url.SchemeIs(kChromeUIScheme)) 310 if (!url.SchemeIs(kChromeUIScheme))
311 return; 311 return;
312 if (url == GURL(kChromeUICrashURL)) { 312 if (url == GURL(kChromeUICrashURL)) {
313 CrashIntentionally(); 313 CrashIntentionally();
314 } else if (url == GURL(kChromeUIDumpURL)) { 314 } else if (url == GURL(kChromeUIDumpURL)) {
315 // This URL will only correctly create a crash dump file if content is 315 // This URL will only correctly create a crash dump file if content is
316 // hosted in a process that has correctly called 316 // hosted in a process that has correctly called
317 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation 317 // base::debug::SetDumpWithoutCrashingFunction. Refer to the documentation
318 // of base::debug::DumpWithoutCrashing for more details. 318 // of base::debug::DumpWithoutCrashing for more details.
319 base::debug::DumpWithoutCrashing(); 319 base::debug::DumpWithoutCrashing();
320 } else if (url == GURL(kChromeUIKillURL)) { 320 } else if (url == GURL(kChromeUIKillURL)) {
321 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); 321 base::KillProcess(base::GetCurrentProcessHandle(), 1, false);
322 } else if (url == GURL(kChromeUIHangURL)) { 322 } else if (url == GURL(kChromeUIHangURL)) {
323 for (;;) { 323 for (;;) {
324 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); 324 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
325 } 325 }
326 } else if (url == GURL(kChromeUIShorthangURL)) { 326 } else if (url == GURL(kChromeUIShorthangURL)) {
327 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 327 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
328 } 328 }
329 329
330 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) 330 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN)
331 MaybeTriggerAsanError(url); 331 MaybeTriggerAsanError(url);
332 #endif // ADDRESS_SANITIZER || SYZYASAN 332 #endif // ADDRESS_SANITIZER || SYZYASAN
333 } 333 }
334 334
335 // Returns false unless this is a top-level navigation. 335 // Returns false unless this is a top-level navigation.
336 static bool IsTopLevelNavigation(WebFrame* frame) { 336 bool IsTopLevelNavigation(WebFrame* frame) {
337 return frame->parent() == NULL; 337 return frame->parent() == NULL;
338 } 338 }
339 339
340 // Returns false unless this is a top-level navigation that crosses origins. 340 // Returns false unless this is a top-level navigation that crosses origins.
341 static bool IsNonLocalTopLevelNavigation(const GURL& url, 341 bool IsNonLocalTopLevelNavigation(const GURL& url,
342 WebFrame* frame, 342 WebFrame* frame,
343 WebNavigationType type, 343 WebNavigationType type,
344 bool is_form_post) { 344 bool is_form_post) {
345 if (!IsTopLevelNavigation(frame)) 345 if (!IsTopLevelNavigation(frame))
346 return false; 346 return false;
347 347
348 // Navigations initiated within Webkit are not sent out to the external host 348 // Navigations initiated within Webkit are not sent out to the external host
349 // in the following cases. 349 // in the following cases.
350 // 1. The url scheme is not http/https 350 // 1. The url scheme is not http/https
351 // 2. The origin of the url and the opener is the same in which case the 351 // 2. The origin of the url and the opener is the same in which case the
352 // opener relationship is maintained. 352 // opener relationship is maintained.
353 // 3. Reloads/form submits/back forward navigations 353 // 3. Reloads/form submits/back forward navigations
354 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme)) 354 if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme))
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 extra_data = &kEmptyData; 466 extra_data = &kEmptyData;
467 CommonNavigationParams params; 467 CommonNavigationParams params;
468 params.url = request->url(); 468 params.url = request->url();
469 params.referrer = Referrer( 469 params.referrer = Referrer(
470 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), 470 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()),
471 request->referrerPolicy()); 471 request->referrerPolicy());
472 params.transition = extra_data->transition_type(); 472 params.transition = extra_data->transition_type();
473 return params; 473 return params;
474 } 474 }
475 475
476 using CreateRenderFrameImpl = RenderFrameImpl* (*)(RenderViewImpl*, int32);
mlamouri (slow - plz ping) 2014/12/10 09:50:03 nit: I would pick a clearer name like CreateRender
dshwang 2014/12/10 10:08:31 I rename it to CreateRenderFrameImplFunction. Jame
477 CreateRenderFrameImpl g_create_render_frame_impl = nullptr;
478
476 } // namespace 479 } // namespace
477 480
478 static RenderFrameImpl* (*g_create_render_frame_impl)(RenderViewImpl*, int32) =
479 NULL;
480 481
481 // static 482 // static
482 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view, 483 RenderFrameImpl* RenderFrameImpl::Create(RenderViewImpl* render_view,
483 int32 routing_id) { 484 int32 routing_id) {
484 DCHECK(routing_id != MSG_ROUTING_NONE); 485 DCHECK(routing_id != MSG_ROUTING_NONE);
485 486
486 if (g_create_render_frame_impl) 487 if (g_create_render_frame_impl)
487 return g_create_render_frame_impl(render_view, routing_id); 488 return g_create_render_frame_impl(render_view, routing_id);
488 else 489 else
489 return new RenderFrameImpl(render_view, routing_id); 490 return new RenderFrameImpl(render_view, routing_id);
(...skipping 3779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4269 4270
4270 #if defined(ENABLE_BROWSER_CDMS) 4271 #if defined(ENABLE_BROWSER_CDMS)
4271 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 4272 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
4272 if (!cdm_manager_) 4273 if (!cdm_manager_)
4273 cdm_manager_ = new RendererCdmManager(this); 4274 cdm_manager_ = new RendererCdmManager(this);
4274 return cdm_manager_; 4275 return cdm_manager_;
4275 } 4276 }
4276 #endif // defined(ENABLE_BROWSER_CDMS) 4277 #endif // defined(ENABLE_BROWSER_CDMS)
4277 4278
4278 } // namespace content 4279 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698