| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "components/nacl/renderer/plugin/service_runtime.h" | 7 #include "components/nacl/renderer/plugin/service_runtime.h" |
| 8 | 8 |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "components/nacl/renderer/plugin/plugin.h" | 15 #include "components/nacl/renderer/plugin/plugin.h" |
| 16 #include "components/nacl/renderer/plugin/plugin_error.h" | 16 #include "components/nacl/renderer/plugin/plugin_error.h" |
| 17 #include "components/nacl/renderer/plugin/sel_ldr_launcher_chrome.h" | 17 #include "components/nacl/renderer/plugin/sel_ldr_launcher_chrome.h" |
| 18 #include "components/nacl/renderer/plugin/srpc_client.h" | |
| 19 #include "components/nacl/renderer/plugin/utility.h" | 18 #include "components/nacl/renderer/plugin/utility.h" |
| 20 #include "native_client/src/include/nacl_macros.h" | 19 #include "native_client/src/include/nacl_macros.h" |
| 21 #include "native_client/src/include/nacl_scoped_ptr.h" | 20 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 22 #include "native_client/src/include/portability_io.h" | 21 #include "native_client/src/include/portability_io.h" |
| 23 #include "native_client/src/include/portability_string.h" | 22 #include "native_client/src/include/portability_string.h" |
| 24 #include "native_client/src/public/imc_types.h" | 23 #include "native_client/src/public/imc_types.h" |
| 25 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" | 24 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" |
| 26 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" | 25 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" |
| 27 #include "ppapi/c/pp_errors.h" | 26 #include "ppapi/c/pp_errors.h" |
| 28 #include "ppapi/cpp/completion_callback.h" | 27 #include "ppapi/cpp/completion_callback.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void ServiceRuntime::StartNexe() { | 100 void ServiceRuntime::StartNexe() { |
| 102 SetupCommandChannel(); | 101 SetupCommandChannel(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 void ServiceRuntime::ReportLoadError(const ErrorInfo& error_info) { | 104 void ServiceRuntime::ReportLoadError(const ErrorInfo& error_info) { |
| 106 if (main_service_runtime_) { | 105 if (main_service_runtime_) { |
| 107 plugin_->ReportLoadError(error_info); | 106 plugin_->ReportLoadError(error_info); |
| 108 } | 107 } |
| 109 } | 108 } |
| 110 | 109 |
| 111 SrpcClient* ServiceRuntime::SetupAppChannel() { | |
| 112 nacl::DescWrapper* connect_desc = subprocess_->socket_addr()->Connect(); | |
| 113 if (NULL == connect_desc) { | |
| 114 LOG(ERROR) << "ServiceRuntime::SetupAppChannel (connect failed)"; | |
| 115 return NULL; | |
| 116 } else { | |
| 117 SrpcClient* srpc_client = SrpcClient::New(connect_desc); | |
| 118 delete connect_desc; | |
| 119 return srpc_client; | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 void ServiceRuntime::Shutdown() { | 110 void ServiceRuntime::Shutdown() { |
| 124 // Abandon callbacks, tell service threads to quit if they were | 111 // Abandon callbacks, tell service threads to quit if they were |
| 125 // blocked waiting for main thread operations to finish. Note that | 112 // blocked waiting for main thread operations to finish. Note that |
| 126 // some callbacks must still await their completion event, e.g., | 113 // some callbacks must still await their completion event, e.g., |
| 127 // CallOnMainThread must still wait for the time out, or I/O events | 114 // CallOnMainThread must still wait for the time out, or I/O events |
| 128 // must finish, so resources associated with pending events cannot | 115 // must finish, so resources associated with pending events cannot |
| 129 // be deallocated. | 116 // be deallocated. |
| 130 | 117 |
| 131 // Note that this does waitpid() to get rid of any zombie subprocess. | 118 // Note that this does waitpid() to get rid of any zombie subprocess. |
| 132 subprocess_.reset(NULL); | 119 subprocess_.reset(NULL); |
| 133 } | 120 } |
| 134 | 121 |
| 135 ServiceRuntime::~ServiceRuntime() { | 122 ServiceRuntime::~ServiceRuntime() { |
| 136 // We do this just in case Shutdown() was not called. | 123 // We do this just in case Shutdown() was not called. |
| 137 subprocess_.reset(NULL); | 124 subprocess_.reset(NULL); |
| 138 } | 125 } |
| 139 | 126 |
| 140 } // namespace plugin | 127 } // namespace plugin |
| OLD | NEW |