summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing
diff options
context:
space:
mode:
authornoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 15:51:09 +0000
committernoelutz@google.com <noelutz@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-22 15:51:09 +0000
commitc12236c0ad94b6bc8c0e33370cec35d4eeb35718 (patch)
treeacaebe01fcea63ed2c93803133d132821a7ad878 /chrome/browser/safe_browsing
parentb599a9f5fcc583d9bb623a874ac5ab068d326843 (diff)
downloadchromium_src-c12236c0ad94b6bc8c0e33370cec35d4eeb35718.zip
chromium_src-c12236c0ad94b6bc8c0e33370cec35d4eeb35718.tar.gz
chromium_src-c12236c0ad94b6bc8c0e33370cec35d4eeb35718.tar.bz2
Fix memory leaks in client_side_detection_host_unittest.
SAME as http://codereview.chromium.org/7473002/. BUG=89890 TEST=Ran unittest with valgrind. Review URL: http://codereview.chromium.org/7484031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r--chrome/browser/safe_browsing/client_side_detection_host_unittest.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
index d9e0a82..4584e93 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc
@@ -67,7 +67,9 @@ ACTION(QuitUIMessageLoop) {
ACTION_TEMPLATE(InvokeCallbackArgument,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_2_VALUE_PARAMS(p0, p1)) {
- return ::std::tr1::get<k>(args)->Run(p0, p1);
+ ::std::tr1::get<k>(args)->Run(p0, p1);
+ // This is an old callback, so it needs to be deleted explicitly.
+ delete ::std::tr1::get<k>(args);
}
class MockClientSideDetectionService : public ClientSideDetectionService {
@@ -284,7 +286,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneNotPhishing) {
verdict.set_is_phishing(true);
EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _))
- .WillOnce(InvokeCallbackArgument<2>(true, &verdict));
+ .WillOnce(DoAll(DeleteArg<1>(),
+ InvokeCallbackArgument<2>(true, &verdict)));
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(
Pointee(PartiallyEqualVerdict(verdict)), _))
@@ -316,7 +319,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) {
verdict.set_is_phishing(true);
EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _))
- .WillOnce(InvokeCallbackArgument<2>(true, &verdict));
+ .WillOnce(DoAll(DeleteArg<1>(),
+ InvokeCallbackArgument<2>(true, &verdict)));
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(
Pointee(PartiallyEqualVerdict(verdict)), _))
@@ -349,7 +353,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) {
verdict.set_is_phishing(true);
EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _))
- .WillOnce(InvokeCallbackArgument<2>(true, &verdict));
+ .WillOnce(DoAll(DeleteArg<1>(),
+ InvokeCallbackArgument<2>(true, &verdict)));
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(
Pointee(PartiallyEqualVerdict(verdict)), _))
@@ -409,7 +414,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneMultiplePings) {
verdict.set_is_phishing(true);
EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _))
- .WillOnce(InvokeCallbackArgument<2>(true, &verdict));
+ .WillOnce(DoAll(DeleteArg<1>(),
+ InvokeCallbackArgument<2>(true, &verdict)));
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(
Pointee(PartiallyEqualVerdict(verdict)), _))