OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "native_client/src/trusted/plugin/nacl_subprocess.h" | |
6 | |
7 #include "native_client/src/trusted/plugin/plugin_error.h" | |
8 #include "native_client/src/trusted/plugin/scriptable_handle.h" | |
9 #include "native_client/src/trusted/plugin/service_runtime.h" | |
10 | |
11 namespace plugin { | |
12 | |
13 nacl::string NaClSubprocess::description() const { | |
14 nacl::stringstream ss; | |
15 if (assigned_id_ == kMainSubprocessId) { | |
16 ss << "main subprocess"; | |
17 } else { | |
18 ss << "helper subprocess #" << assigned_id_; | |
19 } | |
20 return ss.str(); | |
21 } | |
22 | |
23 nacl::string NaClSubprocess::detailed_description() const { | |
24 nacl::stringstream ss; | |
25 ss << description() | |
26 << "={ this=" << static_cast<const void*>(this) | |
27 << ", srpc_client=" << static_cast<void*>(srpc_client_.get()) | |
28 << ", service_runtime=" << static_cast<void*>(service_runtime_.get()) | |
29 << " }"; | |
30 return ss.str(); | |
31 } | |
32 | |
33 // Shutdown the socket connection and service runtime, in that order. | |
34 void NaClSubprocess::Shutdown() { | |
35 srpc_client_.reset(NULL); | |
36 if (service_runtime_.get() != NULL) { | |
37 service_runtime_->Shutdown(); | |
38 service_runtime_.reset(NULL); | |
39 } | |
40 } | |
41 | |
42 NaClSubprocess::~NaClSubprocess() { | |
43 Shutdown(); | |
44 } | |
45 | |
46 bool NaClSubprocess::StartSrpcServices() { | |
47 srpc_client_.reset(service_runtime_->SetupAppChannel()); | |
48 return NULL != srpc_client_.get(); | |
49 } | |
50 | |
51 bool NaClSubprocess::StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info) { | |
52 return srpc_client_->StartJSObjectProxy(plugin, error_info); | |
53 } | |
54 | |
55 bool NaClSubprocess::HasMethod(uintptr_t method_id) const { | |
56 if (NULL == srpc_client_.get()) { | |
57 return false; | |
58 } | |
59 return srpc_client_->HasMethod(method_id); | |
60 } | |
61 | |
62 bool NaClSubprocess::InitParams(uintptr_t method_id, SrpcParams* params) const { | |
63 if (NULL == srpc_client_.get()) { | |
64 return false; | |
65 } | |
66 return srpc_client_->InitParams(method_id, params); | |
67 } | |
68 | |
69 bool NaClSubprocess::Invoke(uintptr_t method_id, SrpcParams* params) const { | |
70 if (NULL == srpc_client_.get()) { | |
71 return false; | |
72 } | |
73 return srpc_client_->Invoke(method_id, params); | |
74 } | |
75 | |
76 } // namespace plugin | |
OLD | NEW |