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

Unified Diff: src/shared/ppapi_proxy/plugin_callback.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: src/shared/ppapi_proxy/plugin_callback.cc
===================================================================
--- src/shared/ppapi_proxy/plugin_callback.cc (revision 4116)
+++ src/shared/ppapi_proxy/plugin_callback.cc (working copy)
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "native_client/src/shared/ppapi_proxy/plugin_callback.h"
+#include <string.h>
#include "srpcgen/ppp_rpc.h"
namespace ppapi_proxy {
@@ -12,21 +13,31 @@
}
int32_t CompletionCallbackTable::AddCallback(
- const PP_CompletionCallback& callback) {
+ const PP_CompletionCallback& callback,
+ char* read_buffer) {
if (callback.func == NULL)
return 0;
- table_[next_id_] = callback;
+ CallbackInfo info = { callback, read_buffer };
+ table_[next_id_] = info;
return next_id_++;
sehr (please use chromium) 2011/01/12 17:49:12 nit: ++next_id_;
polina 2011/01/12 23:44:27 This will return the next id, not the current one,
}
+int32_t CompletionCallbackTable::AddCallback(
+ const PP_CompletionCallback& callback) {
+ return AddCallback(callback, NULL);
+}
+
PP_CompletionCallback CompletionCallbackTable::RemoveCallback(
- int32_t callback_id) {
+ int32_t callback_id, char** read_buffer) {
CallbackTable::iterator it = table_.find(callback_id);
if (table_.end() != it) {
- PP_CompletionCallback callback = it->second;
+ CallbackInfo info = it->second;
table_.erase(it);
- return callback;
+ if (read_buffer != NULL)
+ *read_buffer = info.read_buffer;
+ return info.callback;
}
+ *read_buffer = NULL;
return PP_BlockUntilComplete();
}
@@ -36,14 +47,24 @@
void CompletionCallbackRpcServer::RunCompletionCallback(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
+ // inputs
int32_t callback_id,
- int32_t result) {
+ int32_t result,
+ // TODO(polina): use shm for read buffer
+ nacl_abi_size_t read_buffer_size, char* read_buffer) {
NaClSrpcClosureRunner runner(done);
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
+
+ char* user_buffer;
PP_CompletionCallback callback =
- ppapi_proxy::CompletionCallbackTable::Get()->RemoveCallback(callback_id);
+ ppapi_proxy::CompletionCallbackTable::Get()->RemoveCallback(
+ callback_id, &user_buffer);
if (callback.func == NULL)
return;
+
+ if (user_buffer != NULL && read_buffer_size > 0)
+ memcpy(user_buffer, read_buffer, read_buffer_size);
PP_RunCompletionCallback(&callback, result);
+
rpc->result = NACL_SRPC_RESULT_OK;
}

Powered by Google App Engine
This is Rietveld 408576698