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

Side by Side Diff: src/trusted/plugin/npapi/plugin_npapi.cc

Issue 5622003: Restructure the structs/unions involved in SRPC argument passing. This will... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/plugin/method_map.cc ('k') | src/trusted/plugin/npapi/scriptable_impl_npapi.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Native Client Authors. All rights reserved. 2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 7
8 #include "native_client/src/trusted/plugin/npapi/plugin_npapi.h" 8 #include "native_client/src/trusted/plugin/npapi/plugin_npapi.h"
9 9
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 plugin::PluginNpapi::kHrefIdent = NPN_GetStringIdentifier("href"); 47 plugin::PluginNpapi::kHrefIdent = NPN_GetStringIdentifier("href");
48 plugin::PluginNpapi::kLengthIdent = NPN_GetStringIdentifier("length"); 48 plugin::PluginNpapi::kLengthIdent = NPN_GetStringIdentifier("length");
49 plugin::PluginNpapi::kLocationIdent = NPN_GetStringIdentifier("location"); 49 plugin::PluginNpapi::kLocationIdent = NPN_GetStringIdentifier("location");
50 identifiers_initialized = true; 50 identifiers_initialized = true;
51 } 51 }
52 52
53 // TODO(polina): is there a way to share this with PluginPPAPI? 53 // TODO(polina): is there a way to share this with PluginPPAPI?
54 bool UrlAsNaClDesc(void* obj, plugin::SrpcParams* params) { 54 bool UrlAsNaClDesc(void* obj, plugin::SrpcParams* params) {
55 NaClSrpcArg** ins = params->ins(); 55 NaClSrpcArg** ins = params->ins();
56 PLUGIN_PRINTF(("UrlAsNaClDesc (obj=%p, url=%s, callback=%p)\n", 56 PLUGIN_PRINTF(("UrlAsNaClDesc (obj=%p, url=%s, callback=%p)\n",
57 obj, ins[0]->u.sval.str, ins[1]->u.oval)); 57 obj, ins[0]->arrays.str, ins[1]->arrays.oval));
58 58
59 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj); 59 plugin::Plugin* plugin = reinterpret_cast<plugin::Plugin*>(obj);
60 const char* url = ins[0]->u.sval.str; 60 const char* url = ins[0]->arrays.str;
61 NPObject* callback_obj = reinterpret_cast<NPObject*>(ins[1]->u.oval); 61 NPObject* callback_obj = reinterpret_cast<NPObject*>(ins[1]->arrays.oval);
62 62
63 plugin::UrlAsNaClDescNotify* callback = 63 plugin::UrlAsNaClDescNotify* callback =
64 new(std::nothrow) plugin::UrlAsNaClDescNotify(plugin, url, callback_obj); 64 new(std::nothrow) plugin::UrlAsNaClDescNotify(plugin, url, callback_obj);
65 if (NULL == callback) { 65 if (NULL == callback) {
66 params->set_exception_string("out of memory in __urlAsNaClDesc"); 66 params->set_exception_string("out of memory in __urlAsNaClDesc");
67 return false; 67 return false;
68 } 68 }
69 if (!callback->StartDownload()) { 69 if (!callback->StartDownload()) {
70 PLUGIN_PRINTF(("UrlAsNaClDesc (failed to load url to local file)\n")); 70 PLUGIN_PRINTF(("UrlAsNaClDesc (failed to load url to local file)\n"));
71 params->set_exception_string("specified url could not be loaded"); 71 params->set_exception_string("specified url could not be loaded");
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if (plugin->receive_thread_running_) { 552 if (plugin->receive_thread_running_) {
553 params->set_exception_string("A callback has already been registered"); 553 params->set_exception_string("A callback has already been registered");
554 return false; 554 return false;
555 } 555 }
556 ReceiveThreadArgs* args = new(std::nothrow) ReceiveThreadArgs; 556 ReceiveThreadArgs* args = new(std::nothrow) ReceiveThreadArgs;
557 if (args == NULL) { 557 if (args == NULL) {
558 params->set_exception_string("Memory allocation failed"); 558 params->set_exception_string("Memory allocation failed");
559 return false; 559 return false;
560 } 560 }
561 args->plugin = InstanceIdentifierToNPP(plugin->instance_id()); 561 args->plugin = InstanceIdentifierToNPP(plugin->instance_id());
562 args->callback = reinterpret_cast<NPObject*>(params->ins()[0]->u.oval); 562 args->callback = reinterpret_cast<NPObject*>(params->ins()[0]->arrays.oval);
563 NPN_RetainObject(args->callback); 563 NPN_RetainObject(args->callback);
564 nacl::DescWrapper* socket = plugin->service_runtime_->async_receive_desc(); 564 nacl::DescWrapper* socket = plugin->service_runtime_->async_receive_desc();
565 NaClDescRef(socket->desc()); 565 NaClDescRef(socket->desc());
566 args->socket = plugin->wrapper_factory()->MakeGeneric(socket->desc()); 566 args->socket = plugin->wrapper_factory()->MakeGeneric(socket->desc());
567 567
568 // It would be nice if the thread interface did not require us to 568 // It would be nice if the thread interface did not require us to
569 // specify a stack size. This is fairly arbitrary. 569 // specify a stack size. This is fairly arbitrary.
570 size_t stack_size = 128 << 10; 570 size_t stack_size = 128 << 10;
571 NaClThreadCreateJoinable(&plugin->receive_thread_, AsyncReceiveThread, args, 571 NaClThreadCreateJoinable(&plugin->receive_thread_, AsyncReceiveThread, args,
572 stack_size); 572 stack_size);
573 plugin->receive_thread_running_ = true; 573 plugin->receive_thread_running_ = true;
574 return true; 574 return true;
575 } 575 }
576 576
577 } // namespace plugin 577 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/method_map.cc ('k') | src/trusted/plugin/npapi/scriptable_impl_npapi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698