diff options
5 files changed, 11 insertions, 89 deletions
diff --git a/chrome/browser/safe_browsing/client_side_detection_service.cc b/chrome/browser/safe_browsing/client_side_detection_service.cc index 8ebd9dd..25b4dbc 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service.cc +++ b/chrome/browser/safe_browsing/client_side_detection_service.cc @@ -38,6 +38,7 @@ ClientSideDetectionService::ClientSideDetectionService( : model_path_(model_path), model_status_(UNKNOWN_STATUS), model_file_(base::kInvalidPlatformFileValue), + model_fetcher_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), request_context_getter_(request_context_getter) { } @@ -47,7 +48,6 @@ ClientSideDetectionService::~ClientSideDetectionService() { STLDeleteContainerPairPointers(client_phishing_reports_.begin(), client_phishing_reports_.end()); client_phishing_reports_.clear(); - model_fetcher_.reset(); STLDeleteElements(&open_callbacks_); CloseModelFile(); } @@ -102,14 +102,17 @@ void ClientSideDetectionService::OnURLFetchComplete( int response_code, const ResponseCookies& cookies, const std::string& data) { - if (source == model_fetcher_.get()) { + if (source == model_fetcher_) { HandleModelResponse(source, url, status, response_code, cookies, data); + // The fetcher object will be invalid after this method returns. + model_fetcher_ = NULL; } else if (client_phishing_reports_.find(source) != client_phishing_reports_.end()) { HandlePhishingVerdict(source, url, status, response_code, cookies, data); } else { NOTREACHED(); } + delete source; } void ClientSideDetectionService::SetModelStatus(ModelStatus status) { @@ -136,10 +139,10 @@ void ClientSideDetectionService::OpenModelFileDone( SetModelStatus(READY_STATUS); } else if (base::PLATFORM_FILE_ERROR_NOT_FOUND == error_code) { // We need to fetch the model since it does not exist yet. - model_fetcher_.reset(URLFetcher::Create(0 /* ID is not used */, - GURL(kClientModelUrl), - URLFetcher::GET, - this)); + model_fetcher_ = URLFetcher::Create(0 /* ID is not used */, + GURL(kClientModelUrl), + URLFetcher::GET, + this); model_fetcher_->set_request_context(request_context_getter_.get()); model_fetcher_->Start(); } else { diff --git a/chrome/browser/safe_browsing/client_side_detection_service.h b/chrome/browser/safe_browsing/client_side_detection_service.h index 7b08fbb..a0c72a9 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service.h +++ b/chrome/browser/safe_browsing/client_side_detection_service.h @@ -170,7 +170,7 @@ class ClientSideDetectionService : public URLFetcher::Delegate { FilePath model_path_; ModelStatus model_status_; base::PlatformFile model_file_; - scoped_ptr<URLFetcher> model_fetcher_; + URLFetcher* model_fetcher_; scoped_ptr<std::string> tmp_model_string_; std::vector<OpenModelDoneCallback*> open_callbacks_; diff --git a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc index b9d6c44..ce5e205 100644 --- a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc @@ -161,6 +161,7 @@ TEST_F(ClientSideDetectionServiceTest, SendClientReportPhishingRequest) { // Valid thumbnail but the server returns an error. thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); ASSERT_TRUE(thumbnail.allocPixels()); + thumbnail.eraseRGB(255, 0, 0); SetClientReportPhishingResponse("", false /* fail */); EXPECT_FALSE(SendClientReportPhishingRequest(url, score, thumbnail)); diff --git a/tools/heapcheck/suppressions.txt b/tools/heapcheck/suppressions.txt index c791526..c8144a0 100644 --- a/tools/heapcheck/suppressions.txt +++ b/tools/heapcheck/suppressions.txt @@ -1053,58 +1053,3 @@ fun:testing::HandleExceptionsInMethodIfSupported fun:testing::Test::Run } -{ - bug_62943a - Heapcheck:Leak - ... - fun:FakeURLFetcherFactory::CreateURLFetcher - fun:URLFetcher::Create - fun:safe_browsing::ClientSideDetectionService::StartClientReportPhishingRequest - fun:*DispatchToMethod -} -{ - bug_62943b - Heapcheck:Leak - fun:__gnu_cxx::new_allocator::allocate - fun:std::string::_Rep::_S_create - fun:std::string::_S_construct - fun:std::string::_S_construct_aux - fun:std::string::_S_construct - fun:basic_string - ... - fun:safe_browsing::ClientSideDetectionServiceTest_SendClientReportPhishingRequest_Test::TestBody -} -{ - bug_62943c - Heapcheck:Leak - fun:__gnu_cxx::new_allocator::allocate - fun:std::string::_Rep::_S_create - fun:std::string::_Rep::_M_clone - fun:std::string::_Rep::_M_grab - fun:std::string::assign - fun:std::string::operator= - fun:URLFetcher::set_upload_data - fun:safe_browsing::ClientSideDetectionService::StartClientReportPhishingRequest -} -{ - bug_62943d - Heapcheck:Leak - fun:__gnu_cxx::new_allocator::allocate - fun:std::string::_Rep::_S_create - fun:std::string::_Rep::_M_clone - fun:std::string::reserve - fun:bool ::InitCanonical - fun:GURL - fun:safe_browsing::ClientSideDetectionService::StartClientReportPhishingRequest -} -{ - bug_62943e - Heapcheck:Leak - fun:__gnu_cxx::new_allocator::allocate - fun:std::string::_Rep::_S_create - fun:std::string::_Rep::_M_clone - fun:std::string::_Rep::_M_grab - fun:basic_string - fun:FakeURLFetcherFactory::SetFakeResponse - fun:safe_browsing::ClientSideDetectionServiceTest::SetClientReportPhishingResponse -} diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt index 3139779..71d2cf9 100644 --- a/tools/valgrind/memcheck/suppressions.txt +++ b/tools/valgrind/memcheck/suppressions.txt @@ -3278,33 +3278,6 @@ fun:clone } { - bug_62943 (Cond) - Memcheck:Cond - ... - fun:_ZN3gfx8PNGCodec6EncodeEPKhNS0_11ColorFormatEiiibPSt6vectorIhSaIhEE - fun:_ZN3gfx8PNGCodec18EncodeBGRASkBitmapERK8SkBitmapbPSt6vectorIhSaIhEE - fun:_ZN13safe_browsing26ClientSideDetectionService32StartClientReportPhishingRequestERK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS1_bEE - fun:_Z16DispatchToMethodIN13safe_browsing26ClientSideDetectionServiceEMS1_FvRK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS2_bEEES2_dS5_SA_EvPT_T0_RK6Tuple4IT1_T2_T3_T4_E -} -{ - bug_62943 (Value4) - Memcheck:Value4 - ... - fun:_ZN3gfx8PNGCodec6EncodeEPKhNS0_11ColorFormatEiiibPSt6vectorIhSaIhEE - fun:_ZN3gfx8PNGCodec18EncodeBGRASkBitmapERK8SkBitmapbPSt6vectorIhSaIhEE - fun:_ZN13safe_browsing26ClientSideDetectionService32StartClientReportPhishingRequestERK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS1_bEE - fun:_Z16DispatchToMethodIN13safe_browsing26ClientSideDetectionServiceEMS1_FvRK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS2_bEEES2_dS5_SA_EvPT_T0_RK6Tuple4IT1_T2_T3_T4_E -} -{ - bug_62943 (Leak) - Memcheck:Leak - ... - fun:_ZN21FakeURLFetcherFactory16CreateURLFetcherEiRK4GURLN10URLFetcher11RequestTypeEPNS3_8DelegateE - fun:_ZN10URLFetcher6CreateEiRK4GURLNS_11RequestTypeEPNS_8DelegateE - fun:_ZN13safe_browsing26ClientSideDetectionService32StartClientReportPhishingRequestERK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS1_bEE - fun:_Z16DispatchToMethodIN13safe_browsing26ClientSideDetectionServiceEMS1_FvRK4GURLd8SkBitmapP14CallbackRunnerI6Tuple2IS2_bEEES2_dS5_SA_EvPT_T0_RK6Tuple4IT1_T2_T3_T4_E -} -{ bug_63015 Memcheck:Addr2 fun:_ZN7WebCore18stringToLengthTypeERPKtS1_ |