Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / content / browser / frame_host / debug_urls.cc
blob4e9d49d32a3d7be43ab7cb5b882f1cfd17c3d0d7
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
3 // found in the LICENSE file.
5 #include "content/browser/frame_host/debug_urls.h"
7 #include <vector>
9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
11 #include "content/browser/ppapi_plugin_process_host.h"
12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/common/content_constants.h"
14 #include "content/public/common/url_constants.h"
15 #include "ppapi/proxy/ppapi_messages.h"
16 #include "url/gurl.h"
18 namespace content {
20 namespace {
22 void HandlePpapiFlashDebugURL(const GURL& url) {
23 #if defined(ENABLE_PLUGINS)
24 bool crash = url == GURL(kChromeUIPpapiFlashCrashURL);
26 std::vector<PpapiPluginProcessHost*> hosts;
27 PpapiPluginProcessHost::FindByName(
28 base::UTF8ToUTF16(kFlashPluginName), &hosts);
29 for (std::vector<PpapiPluginProcessHost*>::iterator iter = hosts.begin();
30 iter != hosts.end(); ++iter) {
31 if (crash)
32 (*iter)->Send(new PpapiMsg_Crash());
33 else
34 (*iter)->Send(new PpapiMsg_Hang());
36 #endif
39 } // namespace
41 bool HandleDebugURL(const GURL& url, PageTransition transition) {
42 // Ensure that the user explicitly navigated to this URL.
43 if (!(transition & PAGE_TRANSITION_FROM_ADDRESS_BAR))
44 return false;
46 if (url.host() == kChromeUIBrowserCrashHost) {
47 // Induce an intentional crash in the browser process.
48 CHECK(false);
49 return true;
52 if (url == GURL(kChromeUIGpuCleanURL)) {
53 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
54 if (shim)
55 shim->SimulateRemoveAllContext();
56 return true;
59 if (url == GURL(kChromeUIGpuCrashURL)) {
60 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
61 if (shim)
62 shim->SimulateCrash();
63 return true;
66 if (url == GURL(kChromeUIGpuHangURL)) {
67 GpuProcessHostUIShim* shim = GpuProcessHostUIShim::GetOneInstance();
68 if (shim)
69 shim->SimulateHang();
70 return true;
73 if (url == GURL(kChromeUIPpapiFlashCrashURL) ||
74 url == GURL(kChromeUIPpapiFlashHangURL)) {
75 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
76 base::Bind(&HandlePpapiFlashDebugURL, url));
77 return true;
80 return false;
83 bool IsRendererDebugURL(const GURL& url) {
84 if (!url.is_valid())
85 return false;
87 if (url.SchemeIs(kJavaScriptScheme))
88 return true;
90 return url == GURL(kChromeUICrashURL) ||
91 url == GURL(kChromeUIKillURL) ||
92 url == GURL(kChromeUIHangURL) ||
93 url == GURL(kChromeUIShorthangURL);
96 } // namespace content