summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 21:24:07 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 21:24:07 +0000
commitfcf195410ee81b7444469c2863e5d2416fe1688a (patch)
tree92f61230bbe69b7a2b0fcb1b15c867003054ee8c /chrome
parent161ce86fc859484708d88e68b31af9ad28abafa6 (diff)
downloadchromium_src-fcf195410ee81b7444469c2863e5d2416fe1688a.zip
chromium_src-fcf195410ee81b7444469c2863e5d2416fe1688a.tar.gz
chromium_src-fcf195410ee81b7444469c2863e5d2416fe1688a.tar.bz2
* Breakpad on OSX now works with stock Breakpad framwork.
* We now add all the same Metadata on OS X as we do on Windows. * Made the code for logging URLs in crash dumps a little more x-platform. Remove custom Breakpad hacks so we can use an unmodified version of the Framework. Review URL: http://codereview.chromium.org/55028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad_mac.h13
-rw-r--r--chrome/app/breakpad_mac.mm90
-rw-r--r--chrome/chrome.gyp6
-rw-r--r--chrome/renderer/render_view.cc15
-rw-r--r--chrome/renderer/renderer.scons1
-rw-r--r--chrome/renderer/renderer.vcproj4
-rw-r--r--chrome/renderer/renderer_logging.h32
-rw-r--r--chrome/renderer/renderer_logging_linux.cc19
-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.cc (renamed from chrome/renderer/renderer_logging.cc)10
11 files changed, 354 insertions, 45 deletions
diff --git a/chrome/app/breakpad_mac.h b/chrome/app/breakpad_mac.h
index 0a20e12..b52e89c 100644
--- a/chrome/app/breakpad_mac.h
+++ b/chrome/app/breakpad_mac.h
@@ -16,4 +16,17 @@ bool IsCrashReporterEnabled();
// Call on clean process shutdown.
void DestructCrashReporter();
+#if __OBJC__
+
+@class NSString;
+
+// Set and clear meta information for Minidump.
+// IMPORTANT: On OS X, the key/value pairs are sent to the crash server
+// out of bounds and not recorded on disk in the minidump, this means
+// that if you look at the minidump file locally you won't see them!
+void SetCrashKeyValue(NSString* key, NSString* value);
+void ClearCrashKeyValue(NSString* key);
+
+#endif // __OBJC__
+
#endif // CHROME_APP_BREAKPAD_MAC_H_
diff --git a/chrome/app/breakpad_mac.mm b/chrome/app/breakpad_mac.mm
index 5ffc147..a301e86 100644
--- a/chrome/app/breakpad_mac.mm
+++ b/chrome/app/breakpad_mac.mm
@@ -4,27 +4,38 @@
#import "chrome/app/breakpad_mac.h"
-#import <objc/objc-class.h>
+#import <dlfcn.h>
#import <Foundation/Foundation.h>
#import "base/basictypes.h"
#import "base/logging.h"
#import "base/scoped_nsautorelease_pool.h"
+// For definition of SetActiveRendererURL().
+#import "chrome/renderer/renderer_logging.h"
+#import "googleurl/src/gurl.h"
+
+// TODO(jeremy): On Windows we store the current URL when a process crashes
+// we probably want to do the same on OS X.
+
+namespace {
+
// TODO(jeremy): Remove this block once we include the breakpad sources
// in the public tree.
-@interface GoogleBreakpadWrapper : NSObject
- +(void*)Create:(NSDictionary*) parameters;
- +(void)Release:(void*) ref;
-@end
typedef void* GoogleBreakpadRef;
-namespace {
+typedef void (*GoogleBreakpadSetKeyValuePtr) (GoogleBreakpadRef, NSString*,
+ NSString*);
+typedef void (*GoogleBreakpadRemoveKeyValuePtr) (GoogleBreakpadRef, NSString*);
+typedef GoogleBreakpadRef (*GoogleBreakPadCreatePtr) (NSDictionary*);
+typedef void (*GoogleBreakPadReleasePtr) (GoogleBreakpadRef);
-// TODO(jeremy): On Windows we store the current URL when a process crashes
-// we probably want to do the same on OS X.
GoogleBreakpadRef gBreakpadRef = NULL;
+GoogleBreakPadCreatePtr gBreakPadCreateFunc = NULL;
+GoogleBreakPadReleasePtr gBreakPadReleaseFunc = NULL;
+GoogleBreakpadSetKeyValuePtr gBreakpadSetKeyValueFunc = NULL;
+GoogleBreakpadRemoveKeyValuePtr gBreakpadRemoveKeyValueFunc = NULL;
// Did the user optin for reporting stats.
bool IsStatsReportingAllowed() {
@@ -40,8 +51,8 @@ bool IsCrashReporterEnabled() {
void DestructCrashReporter() {
if (gBreakpadRef) {
- Class breakpad_interface = objc_getClass("GoogleBreakpadWrapper");
- [breakpad_interface Release:gBreakpadRef];
+ DCHECK(gBreakPadReleaseFunc != NULL);
+ gBreakPadReleaseFunc(gBreakpadRef);
gBreakpadRef = NULL;
}
}
@@ -75,21 +86,66 @@ void InitCrashReporter() {
return;
}
- Class breakpad_interface = [breakpad_bundle
- classNamed:@"GoogleBreakpadWrapper"];
-
- if (!breakpad_interface) {
- LOG(ERROR) << "Failed to find GoogleBreakpadWrapper class.";
+ // Retrieve Breakpad interface functions.
+ gBreakPadCreateFunc = reinterpret_cast<GoogleBreakPadCreatePtr>(
+ dlsym(RTLD_DEFAULT, "GoogleBreakpadCreate"));
+ gBreakPadReleaseFunc = reinterpret_cast<GoogleBreakPadReleasePtr>(
+ dlsym(RTLD_DEFAULT, "GoogleBreakpadRelease"));
+ gBreakpadSetKeyValueFunc = reinterpret_cast<GoogleBreakpadSetKeyValuePtr>(
+ dlsym(RTLD_DEFAULT, "GoogleBreakpadSetKeyValue"));
+ gBreakpadRemoveKeyValueFunc =
+ reinterpret_cast<GoogleBreakpadRemoveKeyValuePtr>(
+ dlsym(RTLD_DEFAULT, "GoogleBreakpadRemoveKeyValue"));
+
+ if (!gBreakPadCreateFunc || !gBreakPadReleaseFunc
+ || !gBreakpadSetKeyValueFunc || !gBreakpadRemoveKeyValueFunc) {
+ LOG(ERROR) << "Failed to find Breakpad wrapper classes.";
return;
}
NSDictionary* info_dictionary = [main_bundle infoDictionary];
- GoogleBreakpadRef breakpad = 0;
- breakpad = [breakpad_interface Create:info_dictionary];
+ GoogleBreakpadRef breakpad = NULL;
+ breakpad = gBreakPadCreateFunc(info_dictionary);
if (!breakpad) {
LOG(ERROR) << "Breakpad init failed.";
return;
}
+ // TODO(jeremy): determine whether we're running in the browser or
+ // renderer processes.
+ bool is_renderer = false;
+
+ // This needs to be set before calling SetCrashKeyValue().
gBreakpadRef = breakpad;
+
+ // Set breakpad MetaData values.
+ NSString* version_str = [info_dictionary objectForKey:@"CFBundleVersion"];
+ SetCrashKeyValue(@"ver", version_str);
+ NSString* prod_name_str = [info_dictionary objectForKey:@"CFBundleExecutable"];
+ SetCrashKeyValue(@"prod", prod_name_str);
+ SetCrashKeyValue(@"plat", @"OS X");
+ NSString *product_type = is_renderer ? @"renderer" : @"browser";
+ SetCrashKeyValue(@"ptype", product_type);
+}
+
+void SetCrashKeyValue(NSString* key, NSString* value) {
+ // Comment repeated from header to prevent confusion:
+ // IMPORTANT: On OS X, the key/value pairs are sent to the crash server
+ // out of bounds and not recorded on disk in the minidump, this means
+ // that if you look at the minidump file locally you won't see them!
+ if (gBreakpadRef == NULL) {
+ return;
+ }
+
+ DCHECK(gBreakpadSetKeyValueFunc != NULL);
+ gBreakpadSetKeyValueFunc(gBreakpadRef, key, value);
+}
+
+void ClearCrashKeyValue(NSString* key) {
+ if (gBreakpadRef == NULL) {
+ return;
+ }
+
+ DCHECK(gBreakpadRemoveKeyValueFunc != NULL);
+ gBreakpadRemoveKeyValueFunc(gBreakpadRef, key);
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 9799511..13a7655 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1417,6 +1417,10 @@
'renderer/renderer_glue.cc',
'renderer/renderer_histogram_snapshots.cc',
'renderer/renderer_histogram_snapshots.h',
+ 'renderer/renderer_logging.h',
+ 'renderer/renderer_logging_linux.cc',
+ 'renderer/renderer_logging_mac.mm',
+ 'renderer/renderer_logging_win.cc',
'renderer/renderer_main.cc',
'renderer/renderer_main_platform_delegate.h',
'renderer/renderer_main_platform_delegate_linux.cc',
@@ -2031,6 +2035,7 @@
'..',
],
'sources': [
+ 'app/breakpad_mac.mm',
# All unittests in browser, common, and renderer.
'browser/autocomplete/autocomplete_unittest.cc',
'browser/autocomplete/history_contents_provider_unittest.cc',
@@ -2160,6 +2165,7 @@
'renderer/render_thread_unittest.cc',
'renderer/render_view_unittest.cc',
'renderer/render_widget_unittest.cc',
+ 'renderer/renderer_logging_mac_unittest.mm',
'renderer/renderer_main_unittest.cc',
'test/browser_with_test_window_test.cc',
'test/browser_with_test_window_test.h',
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 446a263..faf8d7c 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -36,6 +36,7 @@
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/media/audio_renderer_impl.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/webmediaplayer_delegate_impl.h"
@@ -77,18 +78,10 @@
#include "base/gfx/gdi_util.h"
#include "base/gfx/native_theme.h"
#include "chrome/common/gfx/emf.h"
-#include "chrome/renderer/renderer_logging.h"
+#include "chrome/views/controls/message_box_view.h"
#include "skia/ext/vector_canvas.h"
#endif
-#if defined(OS_WIN)
-// If true, the URL of the active renderer is logged. Logging is done in such
-// way that if the renderer crashes the URL of the active renderer is contained
-// in the dump. Currently mini-dumps are only supported on windows, so this is
-// only enabled on windows.
-#define LOG_RENDERER_URL
-#endif
-
using base::TimeDelta;
using webkit_glue::WebAccessibility;
@@ -335,11 +328,9 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
}
void RenderView::OnMessageReceived(const IPC::Message& message) {
-#ifdef LOG_RENDERER_URL
WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL;
renderer_logging::ScopedActiveRenderingURLSetter url_setter(
main_frame ? main_frame->GetURL() : GURL());
-#endif
// If this is developer tools renderer intercept tools messages first.
if (devtools_client_.get() && devtools_client_->OnMessageReceived(message))
@@ -773,9 +764,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) {
if (!webview())
return;
-#ifdef LOG_RENDERER_URL
renderer_logging::ScopedActiveRenderingURLSetter url_setter(params.url);
-#endif
AboutHandler::MaybeHandle(params.url);
diff --git a/chrome/renderer/renderer.scons b/chrome/renderer/renderer.scons
index 25d309f..a620ad6 100644
--- a/chrome/renderer/renderer.scons
+++ b/chrome/renderer/renderer.scons
@@ -123,6 +123,7 @@ if env.Bit('linux'):
# Linux-specific.
input_files.Append(
'renderer_main_platform_delegate_linux.cc',
+ 'renderer_logging_linux.cc',
)
# TODO(port): Port these to Linux
diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj
index e9e6a52..38df719 100644
--- a/chrome/renderer/renderer.vcproj
+++ b/chrome/renderer/renderer.vcproj
@@ -342,11 +342,11 @@
>
</File>
<File
- RelativePath=".\renderer_logging.cc"
+ RelativePath=".\renderer_logging.h"
>
</File>
<File
- RelativePath=".\renderer_logging.h"
+ RelativePath=".\renderer_logging_win.cc"
>
</File>
<File
diff --git a/chrome/renderer/renderer_logging.h b/chrome/renderer/renderer_logging.h
index 6be45de..d7c91a5 100644
--- a/chrome/renderer/renderer_logging.h
+++ b/chrome/renderer/renderer_logging.h
@@ -6,8 +6,7 @@
#define CHROME_RENDERER_RENDERER_LOGGING_H_
#include "base/basictypes.h"
-
-class GURL;
+#include "googleurl/src/gurl.h"
namespace renderer_logging {
@@ -19,8 +18,13 @@ void SetActiveRendererURL(const GURL& url);
// and clears the active rendering URL in the destructor.
class ScopedActiveRenderingURLSetter {
public:
- explicit ScopedActiveRenderingURLSetter(const GURL& url);
- ~ScopedActiveRenderingURLSetter();
+ explicit ScopedActiveRenderingURLSetter(const GURL& url) {
+ SetActiveRendererURL(url);
+ }
+
+ ~ScopedActiveRenderingURLSetter() {
+ SetActiveRendererURL(GURL());
+ }
private:
DISALLOW_COPY_AND_ASSIGN(ScopedActiveRenderingURLSetter);
@@ -28,4 +32,24 @@ class 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
new file mode 100644
index 0000000..a703137
--- /dev/null
+++ b/chrome/renderer/renderer_logging_linux.cc
@@ -0,0 +1,19 @@
+// 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 "base/logging.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) {
+ // TODO(port): Once breakpad is integrated we can turn this on.
+ NOTIMPLEMENTED();
+}
+
+} // namespace renderer_logging
diff --git a/chrome/renderer/renderer_logging_mac.mm b/chrome/renderer/renderer_logging_mac.mm
new file mode 100644
index 0000000..d108a85
--- /dev/null
+++ b/chrome/renderer/renderer_logging_mac.mm
@@ -0,0 +1,71 @@
+// 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 (IsCrashReporterEnabled()) {
+ 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
new file mode 100644
index 0000000..6aece64
--- /dev/null
+++ b/chrome/renderer/renderer_logging_mac_unittest.mm
@@ -0,0 +1,138 @@
+// 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.cc b/chrome/renderer/renderer_logging_win.cc
index 2c708bf..6d1b758 100644
--- a/chrome/renderer/renderer_logging.cc
+++ b/chrome/renderer/renderer_logging_win.cc
@@ -30,12 +30,4 @@ void SetActiveRendererURL(const GURL& url) {
(set_active_renderer_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str());
}
-ScopedActiveRenderingURLSetter::ScopedActiveRenderingURLSetter(const GURL& url) {
- SetActiveRendererURL(url);
-}
-
-ScopedActiveRenderingURLSetter::~ScopedActiveRenderingURLSetter() {
- SetActiveRendererURL(GURL());
-}
-
-}
+} // namespace renderer_logging