| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "pnacl_translation_resource_host.h" | 5 #include "pnacl_translation_resource_host.h" |
| 6 | 6 |
| 7 #include "components/nacl/common/nacl_host_messages.h" | 7 #include "components/nacl/common/nacl_host_messages.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/shared_impl/ppapi_globals.h" | 9 #include "ppapi/shared_impl/ppapi_globals.h" |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 PP_ToBool(success))); | 109 PP_ToBool(success))); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void PnaclTranslationResourceHost::OnNexeTempFileReply( | 112 void PnaclTranslationResourceHost::OnNexeTempFileReply( |
| 113 PP_Instance instance, | 113 PP_Instance instance, |
| 114 bool is_hit, | 114 bool is_hit, |
| 115 IPC::PlatformFileForTransit file) { | 115 IPC::PlatformFileForTransit file) { |
| 116 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 116 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 117 base::File base_file = IPC::PlatformFileForTransitToFile(file); | 117 base::File base_file = IPC::PlatformFileForTransitToFile(file); |
| 118 CacheRequestInfoMap::iterator it = pending_cache_requests_.find(instance); | 118 CacheRequestInfoMap::iterator it = pending_cache_requests_.find(instance); |
| 119 int32_t status = PP_ERROR_FAILED; | 119 if (!base_file.IsValid()) { |
| 120 // Handle the expected successful case first. | 120 DLOG(ERROR) << "Got invalid platformfilefortransit"; |
| 121 PP_FileHandle file_handle = PP_kInvalidFileHandle; | |
| 122 if (it != pending_cache_requests_.end() && base_file.IsValid()) { | |
| 123 file_handle = base_file.TakePlatformFile(); | |
| 124 status = PP_OK; | |
| 125 } | 121 } |
| 126 if (it == pending_cache_requests_.end()) { | 122 if (it != pending_cache_requests_.end()) { |
| 127 DLOG(ERROR) << "Could not find pending request for reply"; | 123 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
| 128 } else { | 124 int32_t status = PP_ERROR_FAILED; |
| 125 if (base_file.IsValid()) { |
| 126 file_handle = base_file.TakePlatformFile(); |
| 127 status = PP_OK; |
| 128 } |
| 129 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 129 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 130 FROM_HERE, | 130 FROM_HERE, |
| 131 base::Bind(it->second, status, is_hit, file_handle)); | 131 base::Bind(it->second, status, is_hit, file_handle)); |
| 132 pending_cache_requests_.erase(it); | 132 pending_cache_requests_.erase(it); |
| 133 } | 133 } else { |
| 134 if (!base_file.IsValid()) { | 134 DLOG(ERROR) << "Could not find pending request for reply"; |
| 135 DLOG(ERROR) << "Got invalid platformfilefortransit"; | |
| 136 } | 135 } |
| 137 } | 136 } |
| 138 | 137 |
| 139 void PnaclTranslationResourceHost::CleanupCacheRequests() { | 138 void PnaclTranslationResourceHost::CleanupCacheRequests() { |
| 140 DCHECK(io_message_loop_->BelongsToCurrentThread()); | 139 DCHECK(io_message_loop_->BelongsToCurrentThread()); |
| 141 for (CacheRequestInfoMap::iterator it = pending_cache_requests_.begin(); | 140 for (CacheRequestInfoMap::iterator it = pending_cache_requests_.begin(); |
| 142 it != pending_cache_requests_.end(); | 141 it != pending_cache_requests_.end(); |
| 143 ++it) { | 142 ++it) { |
| 144 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 143 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 145 FROM_HERE, | 144 FROM_HERE, |
| 146 base::Bind(it->second, | 145 base::Bind(it->second, |
| 147 static_cast<int32_t>(PP_ERROR_ABORTED), | 146 static_cast<int32_t>(PP_ERROR_ABORTED), |
| 148 false, | 147 false, |
| 149 PP_kInvalidFileHandle)); | 148 PP_kInvalidFileHandle)); |
| 150 } | 149 } |
| 151 pending_cache_requests_.clear(); | 150 pending_cache_requests_.clear(); |
| 152 } | 151 } |
| OLD | NEW |