OLD | NEW |
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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 390 } |
391 | 391 |
392 bool IsBrowserInitiated(NavigationParams* pending) { | 392 bool IsBrowserInitiated(NavigationParams* pending) { |
393 // A navigation resulting from loading a javascript URL should not be treated | 393 // A navigation resulting from loading a javascript URL should not be treated |
394 // as a browser initiated event. Instead, we want it to look as if the page | 394 // as a browser initiated event. Instead, we want it to look as if the page |
395 // initiated any load resulting from JS execution. | 395 // initiated any load resulting from JS execution. |
396 return pending && | 396 return pending && |
397 !pending->common_params.url.SchemeIs(url::kJavaScriptScheme); | 397 !pending->common_params.url.SchemeIs(url::kJavaScriptScheme); |
398 } | 398 } |
399 | 399 |
| 400 NOINLINE void ExhaustMemory() { |
| 401 volatile void* ptr = nullptr; |
| 402 do { |
| 403 ptr = malloc(0x10000000); |
| 404 } while (ptr); |
| 405 } |
| 406 |
400 NOINLINE void CrashIntentionally() { | 407 NOINLINE void CrashIntentionally() { |
401 // NOTE(shess): Crash directly rather than using NOTREACHED() so | 408 // NOTE(shess): Crash directly rather than using NOTREACHED() so |
402 // that the signature is easier to triage in crash reports. | 409 // that the signature is easier to triage in crash reports. |
403 // | 410 // |
404 // Linker's ICF feature may merge this function with other functions with the | 411 // Linker's ICF feature may merge this function with other functions with the |
405 // same definition and it may confuse the crash report processing system. | 412 // same definition and it may confuse the crash report processing system. |
406 static int static_variable_to_make_this_function_unique = 0; | 413 static int static_variable_to_make_this_function_unique = 0; |
407 base::debug::Alias(&static_variable_to_make_this_function_unique); | 414 base::debug::Alias(&static_variable_to_make_this_function_unique); |
408 | 415 |
409 volatile int* zero = nullptr; | 416 volatile int* zero = nullptr; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } else if (url == GURL(kChromeUIHangURL)) { | 506 } else if (url == GURL(kChromeUIHangURL)) { |
500 LOG(ERROR) << "Intentionally hanging ourselves with sleep infinite loop" | 507 LOG(ERROR) << "Intentionally hanging ourselves with sleep infinite loop" |
501 << " because user navigated to " << url.spec(); | 508 << " because user navigated to " << url.spec(); |
502 for (;;) { | 509 for (;;) { |
503 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); | 510 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
504 } | 511 } |
505 } else if (url == GURL(kChromeUIShorthangURL)) { | 512 } else if (url == GURL(kChromeUIShorthangURL)) { |
506 LOG(ERROR) << "Intentionally sleeping renderer for 20 seconds" | 513 LOG(ERROR) << "Intentionally sleeping renderer for 20 seconds" |
507 << " because user navigated to " << url.spec(); | 514 << " because user navigated to " << url.spec(); |
508 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); | 515 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 516 } else if (url == GURL(kChromeUIMemoryExhaustURL)) { |
| 517 LOG(ERROR) |
| 518 << "Intentionally exhausting renderer memory because user navigated to " |
| 519 << url.spec(); |
| 520 ExhaustMemory(); |
509 } | 521 } |
510 | 522 |
511 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) | 523 #if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) |
512 MaybeTriggerAsanError(url); | 524 MaybeTriggerAsanError(url); |
513 #endif // ADDRESS_SANITIZER || SYZYASAN | 525 #endif // ADDRESS_SANITIZER || SYZYASAN |
514 } | 526 } |
515 | 527 |
516 // Returns false unless this is a top-level navigation. | 528 // Returns false unless this is a top-level navigation. |
517 bool IsTopLevelNavigation(WebFrame* frame) { | 529 bool IsTopLevelNavigation(WebFrame* frame) { |
518 return frame->parent() == NULL; | 530 return frame->parent() == NULL; |
(...skipping 5817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 // event target. Potentially a Pepper plugin will receive the event. | 6348 // event target. Potentially a Pepper plugin will receive the event. |
6337 // In order to tell whether a plugin gets the last mouse event and which it | 6349 // In order to tell whether a plugin gets the last mouse event and which it |
6338 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6350 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6339 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6351 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6340 // |pepper_last_mouse_event_target_|. | 6352 // |pepper_last_mouse_event_target_|. |
6341 pepper_last_mouse_event_target_ = nullptr; | 6353 pepper_last_mouse_event_target_ = nullptr; |
6342 #endif | 6354 #endif |
6343 } | 6355 } |
6344 | 6356 |
6345 } // namespace content | 6357 } // namespace content |
OLD | NEW |