From 6565395c162774ed5321a32ed9ef62455e021e8e Mon Sep 17 00:00:00 2001 From: "benwells@chromium.org" <benwells@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Tue, 26 Jul 2011 02:30:40 +0000 Subject: Fixed memory problem in ProtocolHandlerRegistry unit tests. This memory problem only occurred in tests. It happens because the shell worker, which does stuff on the file thread and is held onto by message loops, was outliving the delegate which it used. Fix is to not pass in a delegate but the only piece of information it needs (whether to fake failure or not). BUG=90248 TEST=Automated tests and valgrind bots Review URL: http://codereview.chromium.org/7461060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94023 0039d316-1c4b-4281-b951-d872f2087c98 --- .../custom_handlers/protocol_handler_registry_unittest.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'chrome/browser/custom_handlers') diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc index 7e8b9ed..f18de6c 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc @@ -110,13 +110,13 @@ class FakeProtocolClientWorker public: FakeProtocolClientWorker(ShellIntegration::DefaultWebClientObserver* observer, const std::string& protocol, - FakeDelegate* registry_delegate) + bool force_failure) : ShellIntegration::DefaultProtocolClientWorker(observer, protocol), - delegate_(registry_delegate) {} + force_failure_(force_failure) {} private: virtual ShellIntegration::DefaultWebClientState CheckIsDefault() { - if (delegate_->force_os_failure()) { + if (force_failure_) { return ShellIntegration::NOT_DEFAULT_WEB_CLIENT; } else { return ShellIntegration::IS_DEFAULT_WEB_CLIENT; @@ -126,7 +126,7 @@ class FakeProtocolClientWorker virtual void SetAsDefault() {} private: - FakeDelegate* delegate_; + bool force_failure_; }; ProtocolHandlerRegistry::DefaultClientObserver* @@ -137,7 +137,7 @@ ProtocolHandlerRegistry::DefaultClientObserver* ShellIntegration::DefaultProtocolClientWorker* FakeDelegate::CreateShellWorker( ShellIntegration::DefaultWebClientObserver* observer, const std::string& protocol) { - return new FakeProtocolClientWorker(observer, protocol, this); + return new FakeProtocolClientWorker(observer, protocol, force_os_failure_); } class NotificationCounter : public NotificationObserver { -- cgit v1.1