1 // Copyright 2012 The Chromium Authors
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 "components/nacl/renderer/plugin/service_runtime.h"
6
7 #include <string.h>
8 #include <string>
9 #include <utility>
10
11 #include "base/compiler_specific.h"
12 #include "components/nacl/renderer/plugin/plugin.h"
13 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/cpp/completion_callback.h"
16 #include "ppapi/cpp/core.h"
17
18 namespace plugin {
19
ServiceRuntime(Plugin * plugin,PP_Instance pp_instance,bool main_service_runtime)20 ServiceRuntime::ServiceRuntime(Plugin* plugin,
21 PP_Instance pp_instance,
22 bool main_service_runtime)
23 : plugin_(plugin),
24 pp_instance_(pp_instance),
25 main_service_runtime_(main_service_runtime) {}
26
StartSelLdr(const SelLdrStartParams & params,pp::CompletionCallback callback)27 void ServiceRuntime::StartSelLdr(const SelLdrStartParams& params,
28 pp::CompletionCallback callback) {
29 nacl::PPBNaClPrivate::LaunchSelLdr(
30 pp_instance_, PP_FromBool(main_service_runtime_), params.url.c_str(),
31 ¶ms.file_info, params.process_type, &translator_channel_,
32 callback.pp_completion_callback());
33 }
34
Shutdown()35 void ServiceRuntime::Shutdown() {
36 nacl::PPBNaClPrivate::TerminateNaClLoader(pp_instance_);
37 }
38
~ServiceRuntime()39 ServiceRuntime::~ServiceRuntime() {
40 Shutdown();
41 }
42
43 } // namespace plugin
44