Commit 1158ce6d authored by teravest@chromium.org's avatar teravest@chromium.org

Pepper: Fix caching for translated nexes.

A refactor of FileDownloader (r284961) broke the caching behavior for nexes
that were translated from pexes; the cache would always end up with entries of
length 0, breaking future loads of the pexe. This is the translated nexe was
written to the wrong file handle, preventing caching of the result.

This change causes the translated nexe to be written to the correct file
handle, fixing the caching behavior.

I manually tested this change on the "game of life" demo at
https://gonativeclient.appspot.com/demo/life, verifying that a cached
translated nexe for the pexe was successfully loaded.

BUG=401121

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287912 0039d316-1c4b-4281-b951-d872f2087c98
parent 8463895c
...@@ -1619,7 +1619,8 @@ class PexeDownloader : public blink::WebURLLoaderClient { ...@@ -1619,7 +1619,8 @@ class PexeDownloader : public blink::WebURLLoaderClient {
return; return;
} }
stream_handler_->DidCacheMiss(stream_handler_user_data_, stream_handler_->DidCacheMiss(stream_handler_user_data_,
expected_content_length_); expected_content_length_,
file_handle);
// No translated nexe was found in the cache, so we should download the // No translated nexe was found in the cache, so we should download the
// file to start streaming it. // file to start streaming it.
......
...@@ -26,7 +26,8 @@ interface PPP_PexeStreamHandler { ...@@ -26,7 +26,8 @@ interface PPP_PexeStreamHandler {
* Provides the expected length of the pexe, as read from HTTP headers. * Provides the expected length of the pexe, as read from HTTP headers.
*/ */
void DidCacheMiss([inout] mem_t user_data, void DidCacheMiss([inout] mem_t user_data,
[in] int64_t expected_total_length); [in] int64_t expected_total_length,
[in] PP_FileHandle temp_nexe_file);
/** /**
* Invoked when a block of data has been downloaded. * Invoked when a block of data has been downloaded.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* From private/ppp_pexe_stream_handler.idl, /* From private/ppp_pexe_stream_handler.idl,
* modified Thu Jul 10 11:05:31 2014. * modified Wed Aug 6 13:11:06 2014.
*/ */
#ifndef PPAPI_C_PRIVATE_PPP_PEXE_STREAM_HANDLER_H_ #ifndef PPAPI_C_PRIVATE_PPP_PEXE_STREAM_HANDLER_H_
...@@ -37,7 +37,9 @@ struct PPP_PexeStreamHandler_1_0 { ...@@ -37,7 +37,9 @@ struct PPP_PexeStreamHandler_1_0 {
* Invoked as a result of a cache miss for a translated pexe. * Invoked as a result of a cache miss for a translated pexe.
* Provides the expected length of the pexe, as read from HTTP headers. * Provides the expected length of the pexe, as read from HTTP headers.
*/ */
void (*DidCacheMiss)(void* user_data, int64_t expected_total_length); void (*DidCacheMiss)(void* user_data,
int64_t expected_total_length,
PP_FileHandle temp_nexe_file);
/** /**
* Invoked when a block of data has been downloaded. * Invoked when a block of data has been downloaded.
* Only invoked after DidCacheMiss(). * Only invoked after DidCacheMiss().
......
...@@ -63,9 +63,11 @@ void DidCacheHit(void* user_data, PP_FileHandle nexe_file_handle) { ...@@ -63,9 +63,11 @@ void DidCacheHit(void* user_data, PP_FileHandle nexe_file_handle) {
coordinator->BitcodeStreamCacheHit(nexe_file_handle); coordinator->BitcodeStreamCacheHit(nexe_file_handle);
} }
void DidCacheMiss(void* user_data, int64_t expected_pexe_size) { void DidCacheMiss(void* user_data, int64_t expected_pexe_size,
PP_FileHandle temp_nexe_file) {
PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data); PnaclCoordinator* coordinator = static_cast<PnaclCoordinator*>(user_data);
coordinator->BitcodeStreamCacheMiss(expected_pexe_size); coordinator->BitcodeStreamCacheMiss(expected_pexe_size,
temp_nexe_file);
} }
void DidStreamData(void* user_data, const void* stream_data, int32_t length) { void DidStreamData(void* user_data, const void* stream_data, int32_t length) {
...@@ -329,7 +331,8 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) { ...@@ -329,7 +331,8 @@ void PnaclCoordinator::BitcodeStreamCacheHit(PP_FileHandle handle) {
NexeReadDidOpen(temp_nexe_file_->Open(false)); NexeReadDidOpen(temp_nexe_file_->Open(false));
} }
void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size,
PP_FileHandle nexe_handle) {
expected_pexe_size_ = expected_pexe_size; expected_pexe_size_ = expected_pexe_size;
for (int i = 0; i < split_module_count_; i++) { for (int i = 0; i < split_module_count_; i++) {
...@@ -348,8 +351,6 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) { ...@@ -348,8 +351,6 @@ void PnaclCoordinator::BitcodeStreamCacheMiss(int64_t expected_pexe_size) {
} }
invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid()); invalid_desc_wrapper_.reset(plugin_->wrapper_factory()->MakeInvalid());
PP_FileHandle nexe_handle =
plugin_->nacl_interface()->CreateTemporaryFile(plugin_->pp_instance());
temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle)); temp_nexe_file_.reset(new TempFile(plugin_, nexe_handle));
// Open the nexe file for connecting ld and sel_ldr. // Open the nexe file for connecting ld and sel_ldr.
// Start translation when done with this last step of setup! // Start translation when done with this last step of setup!
......
...@@ -88,7 +88,8 @@ class PnaclCoordinator { ...@@ -88,7 +88,8 @@ class PnaclCoordinator {
void BitcodeStreamCacheHit(PP_FileHandle handle); void BitcodeStreamCacheHit(PP_FileHandle handle);
void BitcodeStreamCacheMiss(int64_t expected_pexe_size); void BitcodeStreamCacheMiss(int64_t expected_pexe_size,
PP_FileHandle handle);
// Invoked when a pexe data chunk arrives (when using streaming translation) // Invoked when a pexe data chunk arrives (when using streaming translation)
void BitcodeStreamGotData(const void* data, int32_t length); void BitcodeStreamGotData(const void* data, int32_t length);
......
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