summaryrefslogtreecommitdiffstats
path: root/ppapi/native_client
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-03 00:13:13 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-03 00:13:13 +0000
commit084c69365aff0aa5c9a1e00517dd1c6343a7f88d (patch)
tree889c51210f1fa9148a27836d3bb8869c52c3bc5d /ppapi/native_client
parent476d8116d2032e3957a25c66d39e698c01b90aad (diff)
downloadchromium_src-084c69365aff0aa5c9a1e00517dd1c6343a7f88d.zip
chromium_src-084c69365aff0aa5c9a1e00517dd1c6343a7f88d.tar.gz
chromium_src-084c69365aff0aa5c9a1e00517dd1c6343a7f88d.tar.bz2
Fix ppapi_extension_mime_handler nacl test.
The URLLoader Resource that's passed to HandleDocumentLoad is released by the browser (or proxy) after HandleDocumentLoad returns. The plugin is expected to AddRefResource the URLLoader if they use it. In this case, the test was passing just because the synchronous SRPC proxy called ReadResponseBody back to the browser synchronously, which was able to read data immediately. Making the loaded data file bigger or using required callbacks made the test fail. AddRefing the URLLoader fixes it. BUG=116317 Review URL: https://chromiumcodereview.appspot.com/11312067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165807 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc
index b17161f..907bc76 100644
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc
+++ b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc
@@ -57,10 +57,10 @@ void ReadCallback(void* user_data, int32_t pp_error_or_bytes) {
PP_Resource url_loader = reinterpret_cast<PP_Resource>(user_data);
EXPECT_ON_LOAD(pp_error_or_bytes >= PP_OK);
- // EXPECT_ON_LOAD just records an error, make sure to stop processing too.
- // On error we may end up leaking the URLLoader from HandleDocumentLoad.
- if (pp_error_or_bytes < PP_OK)
+ if (pp_error_or_bytes < PP_OK) {
+ PPBCore()->ReleaseResource(url_loader);
return;
+ }
if (PP_OK == pp_error_or_bytes) {
// Check the contents of the file against the known contents.
@@ -69,32 +69,34 @@ void ReadCallback(void* user_data, int32_t pp_error_or_bytes) {
strlen(kKnownFileContents));
EXPECT_ON_LOAD(diff == 0);
PPBURLLoader()->Close(url_loader);
+ PPBCore()->ReleaseResource(url_loader);
ON_LOAD_PASSED;
} else {
buffer_pos += pp_error_or_bytes;
PP_CompletionCallback callback =
- PP_MakeOptionalCompletionCallback(ReadCallback, user_data);
+ PP_MakeCompletionCallback(ReadCallback, user_data);
pp_error_or_bytes =
PPBURLLoader()->ReadResponseBody(url_loader,
buffer + buffer_pos,
kMaxFileSize - buffer_pos,
callback);
- if (pp_error_or_bytes != PP_OK_COMPLETIONPENDING)
- PP_RunCompletionCallback(&callback, pp_error_or_bytes);
}
+ EXPECT(pp_error_or_bytes == PP_OK_COMPLETIONPENDING);
}
PP_Bool HandleDocumentLoad(PP_Instance instance,
PP_Resource url_loader) {
+ // The browser will release url_loader after this method returns. We need to
+ // keep it around until we have read all bytes or get an error.
+ PPBCore()->AddRefResource(url_loader);
void* user_data = reinterpret_cast<void*>(url_loader);
PP_CompletionCallback callback =
- PP_MakeOptionalCompletionCallback(ReadCallback, user_data);
+ PP_MakeCompletionCallback(ReadCallback, user_data);
int32_t pp_error_or_bytes = PPBURLLoader()->ReadResponseBody(url_loader,
buffer,
kMaxFileSize,
callback);
- if (pp_error_or_bytes != PP_OK_COMPLETIONPENDING)
- PP_RunCompletionCallback(&callback, pp_error_or_bytes);
+ EXPECT(pp_error_or_bytes == PP_OK_COMPLETIONPENDING);
return PP_TRUE;
}