Skip to content
Snippets Groups Projects
Commit e0f95f27 authored by noelutz@google.com's avatar noelutz@google.com
Browse files

Fix Valgrind errors that occurred during testing.

BUG=62943
TEST=ClientSideDetectionServiceTest

Review URL: http://codereview.chromium.org/4808003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66157 0039d316-1c4b-4281-b951-d872f2087c98
parent 7fac888e
No related merge requests found
......@@ -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 {
......
......@@ -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_;
......
......@@ -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));
......
......@@ -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
}
......@@ -3277,33 +3277,6 @@
fun:start_thread
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment