summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 18:31:20 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 18:31:20 +0000
commitbd11ba32a3a9844a15ed2a0c2cf6a4140c2853ae (patch)
tree32c018c626c1b6580224fdd8ff7b2cc7aeadcbab /chrome/renderer
parent6f65cc3b4114080938c42bc1f3f55c0188f27163 (diff)
downloadchromium_src-bd11ba32a3a9844a15ed2a0c2cf6a4140c2853ae.zip
chromium_src-bd11ba32a3a9844a15ed2a0c2cf6a4140c2853ae.tar.gz
chromium_src-bd11ba32a3a9844a15ed2a0c2cf6a4140c2853ae.tar.bz2
Add the page url to plugin crashes to aid debugging.
Review URL: http://codereview.chromium.org/149305 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc6
-rw-r--r--chrome/renderer/renderer_logging.h55
-rw-r--r--chrome/renderer/renderer_logging_linux.cc24
-rw-r--r--chrome/renderer/renderer_logging_mac.mm71
-rw-r--r--chrome/renderer/renderer_logging_mac_unittest.mm138
-rw-r--r--chrome/renderer/renderer_logging_win.cc33
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc17
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h5
8 files changed, 18 insertions, 331 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index c960798..d94f484 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -23,6 +23,7 @@
#include "base/string_util.h"
#include "build/build_config.h"
#include "chrome/common/bindings_policy.h"
+#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/jstemplate_builder.h"
@@ -42,7 +43,6 @@
#include "chrome/renderer/navigation_state.h"
#include "chrome/renderer/print_web_view_helper.h"
#include "chrome/renderer/render_process.h"
-#include "chrome/renderer/renderer_logging.h"
#include "chrome/renderer/user_script_slave.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "chrome/renderer/webplugin_delegate_proxy.h"
@@ -325,7 +325,7 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
void RenderView::OnMessageReceived(const IPC::Message& message) {
WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL;
- renderer_logging::ScopedActiveRenderingURLSetter url_setter(
+ child_process_logging::ScopedActiveURLSetter url_setter(
main_frame ? main_frame->GetURL() : GURL());
// If this is developer tools renderer intercept tools messages first.
@@ -626,7 +626,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) {
if (!webview())
return;
- renderer_logging::ScopedActiveRenderingURLSetter url_setter(params.url);
+ child_process_logging::ScopedActiveURLSetter url_setter(params.url);
AboutHandler::MaybeHandle(params.url);
diff --git a/chrome/renderer/renderer_logging.h b/chrome/renderer/renderer_logging.h
deleted file mode 100644
index d7c91a5..0000000
--- a/chrome/renderer/renderer_logging.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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"
-#include "googleurl/src/gurl.h"
-
-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) {
- SetActiveRendererURL(url);
- }
-
- ~ScopedActiveRenderingURLSetter() {
- SetActiveRendererURL(GURL());
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScopedActiveRenderingURLSetter);
-};
-
-} // namespace renderer_logging
-
-#if defined(OS_MACOSX) && __OBJC__
-// Exported for testing purposes.
-
-@class NSString;
-
-typedef void (*SetCrashKeyValueFuncPtr)(NSString*, NSString*);
-typedef void (*ClearCrashKeyValueFuncPtr)(NSString*);
-
-namespace renderer_logging {
-void SetActiveRendererURLImpl(const GURL& url,
- SetCrashKeyValueFuncPtr set_key_func,
- ClearCrashKeyValueFuncPtr clear_key_func);
-
-extern const int kMaxNumCrashURLChunks;
-extern const int kMaxNumURLChunkValueLength;
-extern const char *kUrlChunkFormatStr;
-} // namespace renderer_logging
-
-#endif // defined(OS_MACOSX) && __OBJC__
-
-#endif // CHROME_RENDERER_RENDERER_LOGGING_H_
diff --git a/chrome/renderer/renderer_logging_linux.cc b/chrome/renderer/renderer_logging_linux.cc
deleted file mode 100644
index 7812da1..0000000
--- a/chrome/renderer/renderer_logging_linux.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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 <string>
-
-#include "base/logging.h"
-#include "googleurl/src/gurl.h"
-
-namespace renderer_logging {
-
-// We use a static string to hold the most recent active url. If we crash, the
-// crash handler code will send the contents of this string to the browser.
-std::string active_url;
-
-// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
-// the URL.
-void SetActiveRendererURL(const GURL& url) {
- active_url = url.possibly_invalid_spec();
-}
-
-} // namespace renderer_logging
diff --git a/chrome/renderer/renderer_logging_mac.mm b/chrome/renderer/renderer_logging_mac.mm
deleted file mode 100644
index bb0ea92..0000000
--- a/chrome/renderer/renderer_logging_mac.mm
+++ /dev/null
@@ -1,71 +0,0 @@
-// 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"
-
-#import <Foundation/Foundation.h>
-
-#include "base/string_util.h"
-#include "googleurl/src/gurl.h"
-#import "chrome/app/breakpad_mac.h"
-
-namespace renderer_logging {
-
-const int kMaxNumCrashURLChunks = 8;
-const int kMaxNumURLChunkValueLength = 255;
-const char *kUrlChunkFormatStr = "url-chunk-%d";
-
-void SetActiveRendererURLImpl(const GURL& url,
- SetCrashKeyValueFuncPtr set_key_func,
- ClearCrashKeyValueFuncPtr clear_key_func) {
-
- NSString *kUrlChunkFormatStr_utf8 = [NSString
- stringWithUTF8String:kUrlChunkFormatStr];
-
- // First remove any old url chunks we might have lying around.
- for (int i = 0; i < kMaxNumCrashURLChunks; i++) {
- // On Windows the url-chunk items are 1-based, so match that.
- NSString *key = [NSString stringWithFormat:kUrlChunkFormatStr_utf8, i+1];
- clear_key_func(key);
- }
-
- const std::string& raw_url_utf8 = url.possibly_invalid_spec();
- NSString *raw_url = [NSString stringWithUTF8String:raw_url_utf8.c_str()];
- size_t raw_url_length = [raw_url length];
-
- // Bail on zero-length URLs.
- if (raw_url_length == 0) {
- return;
- }
-
- // Parcel the URL up into up to 8, 255 byte segments.
- size_t start_ofs = 0;
- for (int i = 0;
- i < kMaxNumCrashURLChunks && start_ofs < raw_url_length;
- ++i) {
-
- // On Windows the url-chunk items are 1-based, so match that.
- NSString *key = [NSString stringWithFormat:kUrlChunkFormatStr_utf8, i+1];
- NSRange range;
- range.location = start_ofs;
- range.length = std::min((size_t)kMaxNumURLChunkValueLength,
- raw_url_length - start_ofs);
- NSString *value = [raw_url substringWithRange:range];
- set_key_func(key, value);
-
- // Next chunk.
- start_ofs += kMaxNumURLChunkValueLength;
- }
-}
-
-void SetActiveRendererURL(const GURL& url) {
- // If Breakpad isn't initialized then bail.
- if (IsCrashReporterDisabled()) {
- return;
- }
-
- SetActiveRendererURLImpl(url, SetCrashKeyValue, ClearCrashKeyValue);
-}
-
-} // namespace renderer_logging
diff --git a/chrome/renderer/renderer_logging_mac_unittest.mm b/chrome/renderer/renderer_logging_mac_unittest.mm
deleted file mode 100644
index 6aece64..0000000
--- a/chrome/renderer/renderer_logging_mac_unittest.mm
+++ /dev/null
@@ -1,138 +0,0 @@
-// 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"
-
-#import <Foundation/Foundation.h>
-
-#include "base/logging.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/platform_test.h"
-
-typedef PlatformTest RendererLoggingTest;
-
-namespace {
-
-// Class to mock breakpad's setkeyvalue/clearkeyvalue functions needed for
-// SetActiveRendererURLImpl.
-// The Keys are stored in a static dictionary and methods are provided to
-// verify correctness.
-class MockBreakpadKeyValueStore {
- public:
- MockBreakpadKeyValueStore() {
- // Only one of these objects can be active at once.
- DCHECK(dict == NULL);
- dict = [[NSMutableDictionary alloc] init];
- }
-
- ~MockBreakpadKeyValueStore() {
- // Only one of these objects can be active at once.
- DCHECK(dict != NULL);
- [dict release];
- dict = NULL;
- }
-
- static void SetKeyValue(NSString* key, NSString* value) {
- DCHECK(dict != NULL);
- [dict setObject:value forKey:key];
- }
-
- static void ClearKeyValue(NSString *key) {
- DCHECK(dict != NULL);
- [dict removeObjectForKey:key];
- }
-
- int CountDictionaryEntries() {
- return [dict count];
- }
-
- bool VerifyDictionaryContents(const std::string &url) {
- using renderer_logging::kMaxNumCrashURLChunks;
- using renderer_logging::kMaxNumURLChunkValueLength;
- using renderer_logging::kUrlChunkFormatStr;
-
- int num_url_chunks = CountDictionaryEntries();
- EXPECT_TRUE(num_url_chunks <= kMaxNumCrashURLChunks);
-
- NSString *kUrlChunkFormatStr_utf8 = [NSString
- stringWithUTF8String:kUrlChunkFormatStr];
-
- NSString *accumulated_url = @"";
- for (int i = 0; i < num_url_chunks; ++i) {
- // URL chunk names are 1-based.
- NSString *key = [NSString stringWithFormat:kUrlChunkFormatStr_utf8, i+1];
- EXPECT_TRUE(key != NULL);
- NSString *value = [dict objectForKey:key];
- EXPECT_TRUE([value length] > 0);
- EXPECT_TRUE([value length] <= (unsigned)kMaxNumURLChunkValueLength);
- accumulated_url = [accumulated_url stringByAppendingString:value];
- }
-
- NSString *expected_url = [NSString stringWithUTF8String:url.c_str()];
- return([accumulated_url isEqualToString:expected_url]);
- }
-
- private:
- static NSMutableDictionary* dict;
- DISALLOW_COPY_AND_ASSIGN(MockBreakpadKeyValueStore);
-};
-
-} // namespace
-
-// Call through to SetActiveRendererURLImpl using the functions from
-// MockBreakpadKeyValueStore.
-void SetActiveRendererURLWithMock(const GURL& url) {
- using renderer_logging::SetActiveRendererURLImpl;
-
- SetCrashKeyValueFuncPtr setFunc = MockBreakpadKeyValueStore::SetKeyValue;
- ClearCrashKeyValueFuncPtr clearFunc =
- MockBreakpadKeyValueStore::ClearKeyValue;
-
- SetActiveRendererURLImpl(url, setFunc, clearFunc);
-}
-
-TEST_F(RendererLoggingTest, TestUrlSplitting) {
- using renderer_logging::kMaxNumCrashURLChunks;
- using renderer_logging::kMaxNumURLChunkValueLength;
-
- const std::string short_url("http://abc/");
- std::string long_url("http://");
- std::string overflow_url("http://");
-
- long_url += std::string(kMaxNumURLChunkValueLength * 2, 'a');
- long_url += "/";
-
- int max_num_chars_stored_in_dump = kMaxNumURLChunkValueLength *
- kMaxNumCrashURLChunks;
- overflow_url += std::string(max_num_chars_stored_in_dump + 1, 'a');
- overflow_url += "/";
-
- // Check that Clearing NULL URL works.
- MockBreakpadKeyValueStore mock;
- SetActiveRendererURLWithMock(GURL());
- EXPECT_EQ(mock.CountDictionaryEntries(), 0);
-
- // Check that we can set a URL.
- SetActiveRendererURLWithMock(GURL(short_url.c_str()));
- EXPECT_TRUE(mock.VerifyDictionaryContents(short_url));
- EXPECT_EQ(mock.CountDictionaryEntries(), 1);
- SetActiveRendererURLWithMock(GURL());
- EXPECT_EQ(mock.CountDictionaryEntries(), 0);
-
- // Check that we can replace a long url with a short url.
- SetActiveRendererURLWithMock(GURL(long_url.c_str()));
- EXPECT_TRUE(mock.VerifyDictionaryContents(long_url));
- SetActiveRendererURLWithMock(GURL(short_url.c_str()));
- EXPECT_TRUE(mock.VerifyDictionaryContents(short_url));
- SetActiveRendererURLWithMock(GURL());
- EXPECT_EQ(mock.CountDictionaryEntries(), 0);
-
-
- // Check that overflow works correctly.
- SetActiveRendererURLWithMock(GURL(overflow_url.c_str()));
- EXPECT_TRUE(mock.VerifyDictionaryContents(
- overflow_url.substr(0, max_num_chars_stored_in_dump)));
- SetActiveRendererURLWithMock(GURL());
- EXPECT_EQ(mock.CountDictionaryEntries(), 0);
-}
diff --git a/chrome/renderer/renderer_logging_win.cc b/chrome/renderer/renderer_logging_win.cc
deleted file mode 100644
index 6d1b758..0000000
--- a/chrome/renderer/renderer_logging_win.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// 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());
-}
-
-} // namespace renderer_logging
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index ad70db1..e7650a7 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -19,6 +19,7 @@
#include "base/gfx/size.h"
#include "base/gfx/native_widget_types.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/common/child_process_logging.h"
#include "chrome/common/plugin_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/plugin/npobject_proxy.h"
@@ -26,7 +27,6 @@
#include "chrome/plugin/npobject_util.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_view.h"
-#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "net/base/mime_util.h"
#include "printing/native_metafile.h"
@@ -170,7 +170,8 @@ WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type,
window_script_object_(NULL),
sad_plugin_(NULL),
invalidate_pending_(false),
- transparent_(false) {
+ transparent_(false),
+ page_url_(render_view_->webview()->GetMainFrame()->GetURL()) {
}
WebPluginDelegateProxy::~WebPluginDelegateProxy() {
@@ -245,6 +246,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn,
PluginMsg_Init_Params params;
params.containing_window = render_view_->host_window();
params.url = url;
+ params.page_url = page_url_;
for (int i = 0; i < argc; ++i) {
params.arg_names.push_back(argn[i]);
params.arg_values.push_back(argv[i]);
@@ -329,6 +331,8 @@ void WebPluginDelegateProxy::InstallMissingPlugin() {
}
void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) {
+ child_process_logging::ScopedActiveURLSetter url_setter(page_url_);
+
IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg)
IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow)
#if defined(OS_LINUX)
@@ -608,7 +612,7 @@ NPObject* WebPluginDelegateProxy::GetPluginScriptableObject() {
npobject_ = NPObjectProxy::Create(
channel_host_.get(), route_id, npobject_ptr,
- render_view_->modal_dialog_event());
+ render_view_->modal_dialog_event(), page_url_);
return NPN_RetainObject(npobject_);
}
@@ -698,7 +702,7 @@ void WebPluginDelegateProxy::OnGetWindowScriptNPObject(
// otherwise when the channel is closed.
NPObjectStub* stub = new NPObjectStub(
npobject, channel_host_.get(), route_id,
- render_view_->modal_dialog_event());
+ render_view_->modal_dialog_event(), page_url_);
window_script_object_ = stub;
window_script_object_->set_proxy(this);
*success = true;
@@ -718,7 +722,7 @@ void WebPluginDelegateProxy::OnGetPluginElement(
// otherwise when the channel is closed.
new NPObjectStub(
npobject, channel_host_.get(), route_id,
- render_view_->modal_dialog_event());
+ render_view_->modal_dialog_event(), page_url_);
*success = true;
*npobject_ptr = reinterpret_cast<intptr_t>(npobject);
}
@@ -809,7 +813,8 @@ void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object,
for (size_t i = 0; i < arraysize(results); ++i) {
values->push_back(NPVariant_Param());
- CreateNPVariantParam(results[i], NULL, &values->back(), false, NULL);
+ CreateNPVariantParam(
+ results[i], NULL, &values->back(), false, NULL, page_url_);
}
*success = true;
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index e720815..b665015 100644
--- a/chrome/renderer/webplugin_delegate_proxy.h
+++ b/chrome/renderer/webplugin_delegate_proxy.h
@@ -14,11 +14,11 @@
#include "base/ref_counted.h"
#include "chrome/common/ipc_message.h"
#include "chrome/renderer/plugin_channel_host.h"
+#include "googleurl/src/gurl.h"
#include "skia/ext/platform_canvas.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webplugin_delegate.h"
-class GURL;
struct NPObject;
class NPObjectStub;
struct NPVariant_Param;
@@ -204,6 +204,9 @@ class WebPluginDelegateProxy : public WebPluginDelegate,
// This lets us know which portion of the backing store has been painted into.
gfx::Rect backing_store_painted_;
+ // The url of the main frame hosting the plugin.
+ GURL page_url_;
+
DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy);
};