diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 22:27:04 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 22:27:04 +0000 |
commit | 4e3b09245c1d668ec94316865a9d749b08feeab8 (patch) | |
tree | 779ab0a38f8c945adbeaaa64e324e27875095b84 /chrome/renderer | |
parent | 883fd6284db5ba9abe08b8433c8efabe18af139f (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/renderer/renderer.vcproj | 8 | ||||
-rw-r--r-- | chrome/renderer/renderer_logging.cc | 41 | ||||
-rw-r--r-- | chrome/renderer/renderer_logging.h | 31 |
3 files changed, 80 insertions, 0 deletions
diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj index a566716f..4f15e7f 100644 --- a/chrome/renderer/renderer.vcproj +++ b/chrome/renderer/renderer.vcproj @@ -298,6 +298,14 @@ > </File> <File + RelativePath=".\renderer_logging.cc" + > + </File> + <File + RelativePath=".\renderer_logging.h" + > + </File> + <File RelativePath=".\render_process.cc" > </File> 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()); +} + +} diff --git a/chrome/renderer/renderer_logging.h b/chrome/renderer/renderer_logging.h new file mode 100644 index 0000000..6be45de --- /dev/null +++ b/chrome/renderer/renderer_logging.h @@ -0,0 +1,31 @@ +// 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. + +#ifndef CHROME_RENDERER_RENDERER_LOGGING_H_ +#define CHROME_RENDERER_RENDERER_LOGGING_H_ + +#include "base/basictypes.h" + +class GURL; + +namespace renderer_logging { + +// Sets the URL that is logged if the renderer crashes. Use GURL() to clear +// the URL. +void SetActiveRendererURL(const GURL& url); + +// Simple wrapper class that sets the active rendering URL in it's constructor +// and clears the active rendering URL in the destructor. +class ScopedActiveRenderingURLSetter { + public: + explicit ScopedActiveRenderingURLSetter(const GURL& url); + ~ScopedActiveRenderingURLSetter(); + + private: + DISALLOW_COPY_AND_ASSIGN(ScopedActiveRenderingURLSetter); +}; + +} // namespace renderer_logging + +#endif // CHROME_RENDERER_RENDERER_LOGGING_H_ |