OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/about_handler.h" | 5 #include "chrome/renderer/about_handler.h" |
6 | 6 |
| 7 #include "base/process_util.h" |
7 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
8 #include "chrome/common/about_handler.h" | 9 #include "chrome/common/about_handler.h" |
9 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
10 | 11 |
11 typedef void (*AboutHandlerFuncPtr)(); | 12 typedef void (*AboutHandlerFuncPtr)(); |
12 | 13 |
13 // This needs to match up with chrome_about_handler::about_urls in | 14 // This needs to match up with chrome_about_handler::about_urls in |
14 // chrome/common/about_handler.cc. | 15 // chrome/common/about_handler.cc. |
15 static const AboutHandlerFuncPtr about_urls_handlers[] = { | 16 static const AboutHandlerFuncPtr about_urls_handlers[] = { |
16 AboutHandler::AboutCrash, | 17 AboutHandler::AboutCrash, |
| 18 AboutHandler::AboutKill, |
17 AboutHandler::AboutHang, | 19 AboutHandler::AboutHang, |
18 AboutHandler::AboutShortHang, | 20 AboutHandler::AboutShortHang, |
19 NULL, | 21 NULL, |
20 }; | 22 }; |
21 | 23 |
22 // static | 24 // static |
23 bool AboutHandler::MaybeHandle(const GURL& url) { | 25 bool AboutHandler::MaybeHandle(const GURL& url) { |
24 if (url.scheme() != chrome_about_handler::kAboutScheme) | 26 if (url.scheme() != chrome_about_handler::kAboutScheme) |
25 return false; | 27 return false; |
26 | 28 |
(...skipping 10 matching lines...) Expand all Loading... |
37 return false; | 39 return false; |
38 } | 40 } |
39 | 41 |
40 // static | 42 // static |
41 void AboutHandler::AboutCrash() { | 43 void AboutHandler::AboutCrash() { |
42 int *zero = NULL; | 44 int *zero = NULL; |
43 *zero = 0; // Null pointer dereference: kaboom! | 45 *zero = 0; // Null pointer dereference: kaboom! |
44 } | 46 } |
45 | 47 |
46 // static | 48 // static |
| 49 void AboutHandler::AboutKill() { |
| 50 base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 51 } |
| 52 |
| 53 // static |
47 void AboutHandler::AboutHang() { | 54 void AboutHandler::AboutHang() { |
48 for (;;) { | 55 for (;;) { |
49 base::PlatformThread::Sleep(1000); | 56 base::PlatformThread::Sleep(1000); |
50 } | 57 } |
51 } | 58 } |
52 | 59 |
53 // static | 60 // static |
54 void AboutHandler::AboutShortHang() { | 61 void AboutHandler::AboutShortHang() { |
55 base::PlatformThread::Sleep(20000); | 62 base::PlatformThread::Sleep(20000); |
56 } | 63 } |
57 | 64 |
58 // static | 65 // static |
59 size_t AboutHandler::AboutURLHandlerSize() { | 66 size_t AboutHandler::AboutURLHandlerSize() { |
60 return arraysize(about_urls_handlers); | 67 return arraysize(about_urls_handlers); |
61 } | 68 } |
OLD | NEW |