summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/renderer_logging.cc
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 22:27:04 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-09 22:27:04 +0000
commit4e3b09245c1d668ec94316865a9d749b08feeab8 (patch)
tree779ab0a38f8c945adbeaaa64e324e27875095b84 /chrome/renderer/renderer_logging.cc
parent883fd6284db5ba9abe08b8433c8efabe18af139f (diff)
downloadchromium_src-4e3b09245c1d668ec94316865a9d749b08feeab8.zip
chromium_src-4e3b09245c1d668ec94316865a9d749b08feeab8.tar.gz
chromium_src-4e3b09245c1d668ec94316865a9d749b08feeab8.tar.bz2
Adds the ability to log the URL of the renderer if the renderer
crashes. This is the code to set and maintain the URL, but we're not using it anywhere yet. BUG=none TEST=none Review URL: http://codereview.chromium.org/39202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/renderer_logging.cc')
-rw-r--r--chrome/renderer/renderer_logging.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/chrome/renderer/renderer_logging.cc b/chrome/renderer/renderer_logging.cc
new file mode 100644
index 0000000..2c708bf
--- /dev/null
+++ b/chrome/renderer/renderer_logging.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/renderer_logging.h"
+
+#include <windows.h>
+
+#include "base/string_util.h"
+#include "chrome/common/chrome_constants.h"
+#include "googleurl/src/gurl.h"
+
+namespace renderer_logging {
+
+typedef void (__cdecl *MainSetActiveRendererURL)(const wchar_t*);
+
+// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
+// the URL.
+void SetActiveRendererURL(const GURL& url) {
+ HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
+ if (!exe_module)
+ return;
+
+ MainSetActiveRendererURL set_active_renderer_url =
+ reinterpret_cast<MainSetActiveRendererURL>(
+ GetProcAddress(exe_module, "SetActiveRendererURL"));
+ if (!set_active_renderer_url)
+ return;
+
+ (set_active_renderer_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str());
+}
+
+ScopedActiveRenderingURLSetter::ScopedActiveRenderingURLSetter(const GURL& url) {
+ SetActiveRendererURL(url);
+}
+
+ScopedActiveRenderingURLSetter::~ScopedActiveRenderingURLSetter() {
+ SetActiveRendererURL(GURL());
+}
+
+}