Commit 3ea468bb authored by jvoung's avatar jvoung Committed by Commit bot

Rearrange PNaCl OnNexeTempFileReply file check to be *before* transferring ownership.

Otherwise, after transferring ownership the old
base_file will always be invalid and we get spurious
error logs, which can be confusing.

This started happening after the refactoring in r274783.
https://codereview.chromium.org/307173002/diff/80001/components/nacl/renderer/pnacl_translation_resource_host.cc

Alternatively, could have checked the file_handle variable that
ends up owning the base_file at the later point, but might as
well check it earlier.

BUG=none
(but it bugged ncbray =))

Review URL: https://codereview.chromium.org/982663002

Cr-Commit-Position: refs/heads/master@{#319170}
parent 4ff9bc71
......@@ -116,23 +116,22 @@ void PnaclTranslationResourceHost::OnNexeTempFileReply(
DCHECK(io_message_loop_->BelongsToCurrentThread());
base::File base_file = IPC::PlatformFileForTransitToFile(file);
CacheRequestInfoMap::iterator it = pending_cache_requests_.find(instance);
int32_t status = PP_ERROR_FAILED;
// Handle the expected successful case first.
PP_FileHandle file_handle = PP_kInvalidFileHandle;
if (it != pending_cache_requests_.end() && base_file.IsValid()) {
file_handle = base_file.TakePlatformFile();
status = PP_OK;
if (!base_file.IsValid()) {
DLOG(ERROR) << "Got invalid platformfilefortransit";
}
if (it == pending_cache_requests_.end()) {
DLOG(ERROR) << "Could not find pending request for reply";
} else {
if (it != pending_cache_requests_.end()) {
PP_FileHandle file_handle = PP_kInvalidFileHandle;
int32_t status = PP_ERROR_FAILED;
if (base_file.IsValid()) {
file_handle = base_file.TakePlatformFile();
status = PP_OK;
}
PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
FROM_HERE,
base::Bind(it->second, status, is_hit, file_handle));
pending_cache_requests_.erase(it);
}
if (!base_file.IsValid()) {
DLOG(ERROR) << "Got invalid platformfilefortransit";
} else {
DLOG(ERROR) << "Could not find pending request for reply";
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment