Index: ppapi/native_client/src/trusted/plugin/service_runtime.cc |
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc |
index fbbd781df3d006fe4524b4be63cd1d8b84a77fc2..393b29b78e90c8f3eae4c58a915d4bf8b2e347c4 100644 |
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc |
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc |
@@ -51,17 +51,12 @@ |
namespace plugin { |
-OpenManifestEntryResource::~OpenManifestEntryResource() { |
-} |
- |
PluginReverseInterface::PluginReverseInterface( |
- nacl::WeakRefAnchor* anchor, |
PP_Instance pp_instance, |
ServiceRuntime* service_runtime, |
pp::CompletionCallback init_done_cb, |
pp::CompletionCallback crash_cb) |
- : anchor_(anchor), |
- pp_instance_(pp_instance), |
+ : pp_instance_(pp_instance), |
service_runtime_(service_runtime), |
shutting_down_(false), |
init_done_cb_(init_done_cb), |
@@ -103,123 +98,11 @@ void PluginReverseInterface::StartupInitializationComplete() { |
} |
} |
-// TODO(bsy): OpenManifestEntry should use the manifest to ResolveKey |
-// and invoke StreamAsFile with a completion callback that invokes |
-// GetPOSIXFileDesc. |
bool PluginReverseInterface::OpenManifestEntry(nacl::string url_key, |
struct NaClFileInfo* info) { |
- bool op_complete = false; // NB: mu_ and cv_ also controls access to this! |
- // The to_open object is owned by the weak ref callback. Because this function |
- // waits for the callback to finish, the to_open object will be deallocated on |
- // the main thread before this function can return. The pointers it contains |
- // to stack variables will not leak. |
- OpenManifestEntryResource* to_open = |
- new OpenManifestEntryResource(url_key, info, &op_complete); |
- CHECK(to_open != NULL); |
- NaClLog(4, "PluginReverseInterface::OpenManifestEntry: %s\n", |
- url_key.c_str()); |
- // This assumes we are not on the main thread. If false, we deadlock. |
- plugin::WeakRefCallOnMainThread( |
- anchor_, |
- 0, |
- this, |
- &plugin::PluginReverseInterface::OpenManifestEntry_MainThreadContinuation, |
- to_open); |
- NaClLog(4, |
- "PluginReverseInterface::OpenManifestEntry:" |
- " waiting on main thread\n"); |
- |
- { |
- nacl::MutexLocker take(&mu_); |
- while (!shutting_down_ && !op_complete) |
- NaClXCondVarWait(&cv_, &mu_); |
- NaClLog(4, "PluginReverseInterface::OpenManifestEntry: done!\n"); |
- if (shutting_down_) { |
- NaClLog(4, |
- "PluginReverseInterface::OpenManifestEntry:" |
- " plugin is shutting down\n"); |
- return false; |
- } |
- } |
- |
- // info->desc has the returned descriptor if successful, else -1. |
- |
- // The caller is responsible for not closing info->desc. If it is |
- // closed prematurely, then another open could re-use the OS |
- // descriptor, confusing the opened_ map. If the caller is going to |
- // want to make a NaClDesc object and transfer it etc., then the |
- // caller should DUP the descriptor (but remember the original |
- // value) for use by the NaClDesc object, which closes when the |
- // object is destroyed. |
- NaClLog(4, |
- "PluginReverseInterface::OpenManifestEntry: info->desc = %d\n", |
- info->desc); |
- if (info->desc == -1) { |
- // TODO(bsy,ncbray): what else should we do with the error? This |
- // is a runtime error that may simply be a programming error in |
- // the untrusted code, or it may be something else wrong w/ the |
- // manifest. |
- NaClLog(4, "OpenManifestEntry: failed for key %s", url_key.c_str()); |
- } |
- return true; |
-} |
- |
-// Transfer point from OpenManifestEntry() which runs on the main thread |
-// (Some PPAPI actions -- like StreamAsFile -- can only run on the main thread). |
-// OpenManifestEntry() is waiting on a condvar for this continuation to |
-// complete. We Broadcast and awaken OpenManifestEntry() whenever we are done |
-// either here, or in a later MainThreadContinuation step, if there are |
-// multiple steps. |
-void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( |
- OpenManifestEntryResource* p, |
- int32_t err) { |
- UNREFERENCED_PARAMETER(err); |
- // CallOnMainThread continuations always called with err == PP_OK. |
- |
- NaClLog(4, "Entered OpenManifestEntry_MainThreadContinuation\n"); |
- |
- // Because p is owned by the callback of this invocation, so it is necessary |
- // to create another instance. |
- OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p); |
- pp::CompletionCallback stream_cc = WeakRefNewCallback( |
- anchor_, |
- this, |
- &PluginReverseInterface::StreamAsFile_MainThreadContinuation, |
- open_cont); |
- |
- GetNaClInterface()->OpenManifestEntry( |
- pp_instance_, |
- PP_FromBool(!service_runtime_->main_service_runtime()), |
- p->url.c_str(), |
- &open_cont->pp_file_info, |
- stream_cc.pp_completion_callback()); |
- // p is deleted automatically. |
-} |
- |
-void PluginReverseInterface::StreamAsFile_MainThreadContinuation( |
- OpenManifestEntryResource* p, |
- int32_t result) { |
- NaClLog(4, "Entered StreamAsFile_MainThreadContinuation\n"); |
- { |
- nacl::MutexLocker take(&mu_); |
- if (result == PP_OK) { |
- // We downloaded this file to temporary storage for this plugin; it's |
- // reasonable to provide a file descriptor with write access. |
- p->file_info->desc = ConvertFileDescriptor(p->pp_file_info.handle, false); |
- p->file_info->file_token.lo = p->pp_file_info.token_lo; |
- p->file_info->file_token.hi = p->pp_file_info.token_hi; |
- NaClLog(4, |
- "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n", |
- p->file_info->desc); |
- } else { |
- NaClLog( |
- 4, |
- "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n"); |
- p->file_info->desc = -1; |
- } |
- *p->op_complete_ptr = true; |
- NaClXCondVarBroadcast(&cv_); |
- } |
+ // Not implemented. See ManifestServiceChannel for where this logic happens |
+ // now. |
+ return false; |
} |
void PluginReverseInterface::ReportCrash() { |
@@ -257,8 +140,7 @@ ServiceRuntime::ServiceRuntime(Plugin* plugin, |
main_service_runtime_(main_service_runtime), |
uses_nonsfi_mode_(uses_nonsfi_mode), |
reverse_service_(NULL), |
- anchor_(new nacl::WeakRefAnchor()), |
- rev_interface_(new PluginReverseInterface(anchor_, pp_instance, this, |
+ rev_interface_(new PluginReverseInterface(pp_instance, this, |
init_done_cb, crash_cb)), |
start_sel_ldr_done_(false), |
start_nexe_done_(false), |
@@ -583,7 +465,6 @@ bool ServiceRuntime::RemoteLog(int severity, const nacl::string& msg) { |
void ServiceRuntime::Shutdown() { |
rev_interface_->ShutDown(); |
- anchor_->Abandon(); |
// Abandon callbacks, tell service threads to quit if they were |
// blocked waiting for main thread operations to finish. Note that |
// some callbacks must still await their completion event, e.g., |
@@ -617,8 +498,6 @@ ServiceRuntime::~ServiceRuntime() { |
reverse_service_->Unref(); |
rev_interface_->Unref(); |
- |
- anchor_->Unref(); |
NaClCondVarDtor(&cond_); |
NaClMutexDtor(&mu_); |
} |