Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: tests/ppapi_geturl/url_load_request.cc

Issue 6177007: ppapi_proxy: Support loading and reading urls. Proxy URLLoader.... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/ppapi_geturl/url_load_request.cc
===================================================================
--- tests/ppapi_geturl/url_load_request.cc (revision 4116)
+++ tests/ppapi_geturl/url_load_request.cc (working copy)
@@ -12,11 +12,36 @@
#include "native_client/src/include/nacl_macros.h"
#include "native_client/src/shared/platform/nacl_check.h"
#include "native_client/tests/ppapi_geturl/module.h"
+#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
namespace {
+// A local helper that does not contribut to loading/reading of urls, but
sehr (please use chromium) 2011/01/12 17:49:12 contribute
polina 2011/01/12 23:44:27 Done.
+// allows us to test proxying of Is<Interface> functions.
+// TODO(polina): when we have unit tests, move this there.
+void TestIsInterface(std::string test_interface,
+ PP_Resource resource,
+ const PPB_URLRequestInfo* ppb_url_request_info,
+ const PPB_URLResponseInfo* ppb_url_response_info,
+ const PPB_URLLoader* ppb_url_loader) {
+ printf("--- TestIsInterface: %s\n", test_interface.c_str());
+ if (test_interface == PPB_URLREQUESTINFO_INTERFACE) {
+ CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_TRUE);
+ CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_FALSE);
+ CHECK(ppb_url_loader->IsURLLoader(resource) == PP_FALSE);
+ } else if (test_interface == PPB_URLRESPONSEINFO_INTERFACE) {
+ CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_FALSE);
+ CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_TRUE);
+ CHECK(ppb_url_loader->IsURLLoader(resource) == PP_FALSE);
+ } else if (test_interface == PPB_URLLOADER_INTERFACE) {
+ CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_FALSE);
+ CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_FALSE);
+ CHECK(ppb_url_loader->IsURLLoader(resource) == PP_TRUE);
+ }
+}
+
void OpenCallback(void* user_data, int32_t pp_error) {
UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
if (NULL != obj)
@@ -168,6 +193,12 @@
return false;
}
+ TestIsInterface(PPB_URLREQUESTINFO_INTERFACE, request_,
+ request_interface_, response_interface_, loader_interface_);
+ TestIsInterface(PPB_URLLOADER_INTERFACE, loader_,
+ request_interface_, response_interface_, loader_interface_);
+
+ // TODO(sanga): enable this for untrusted code when FileIO proxy is supported.
#if !defined(__native_client__)
fileio_interface_ = static_cast<const PPB_FileIO_Dev*>(
module->GetBrowserInterface(PPB_FILEIO_DEV_INTERFACE));
@@ -225,6 +256,8 @@
ReportFailure("UrlLoadRequest::OpenCallback: null response");
return;
}
+ TestIsInterface(PPB_URLRESPONSEINFO_INTERFACE, response_,
+ request_interface_, response_interface_, loader_interface_);
PP_Var url = response_interface_->GetProperty(response_,
PP_URLRESPONSEPROPERTY_URL);
if (url.type != PP_VARTYPE_STRING) {
@@ -268,6 +301,8 @@
ReportFailure("UrlLoadRequest::FinishStreamingToFileCallback: null file");
return;
}
+// TODO(sanga): enable this for untrusted code when FileIO proxy is supported.
+#if !defined(__native_client__)
pp_error = fileio_interface_->Open(
fileio_,
fileref,
@@ -277,6 +312,9 @@
if (pp_error != PP_ERROR_WOULDBLOCK) { // Async failure.
ReportFailure("PPB_FileIO::Open: ", pp_error);
}
+#else
+ ReportFailure("PPB_FileIO not supported");
+#endif
}
void UrlLoadRequest::ReadResponseBodyCallback(int32_t pp_error_or_bytes) {

Powered by Google App Engine
This is Rietveld 408576698