Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "GMPProcessChild.h"
7 :
8 : #include "base/command_line.h"
9 : #include "base/string_util.h"
10 : #include "mozilla/ipc/IOThreadChild.h"
11 : #include "mozilla/BackgroundHangMonitor.h"
12 :
13 : using mozilla::ipc::IOThreadChild;
14 :
15 : namespace mozilla {
16 : namespace gmp {
17 :
18 0 : GMPProcessChild::GMPProcessChild(ProcessId aParentPid)
19 0 : : ProcessChild(aParentPid)
20 : {
21 0 : }
22 :
23 0 : GMPProcessChild::~GMPProcessChild()
24 : {
25 0 : }
26 :
27 : bool
28 0 : GMPProcessChild::Init(int aArgc, char* aArgv[])
29 : {
30 0 : nsAutoString pluginFilename;
31 :
32 : #if defined(OS_POSIX)
33 : // NB: need to be very careful in ensuring that the first arg
34 : // (after the binary name) here is indeed the plugin module path.
35 : // Keep in sync with dom/plugins/PluginModuleParent.
36 0 : std::vector<std::string> values = CommandLine::ForCurrentProcess()->argv();
37 0 : MOZ_ASSERT(values.size() >= 2, "not enough args");
38 0 : pluginFilename = NS_ConvertUTF8toUTF16(nsDependentCString(values[1].c_str()));
39 : #elif defined(OS_WIN)
40 : std::vector<std::wstring> values = CommandLine::ForCurrentProcess()->GetLooseValues();
41 : MOZ_ASSERT(values.size() >= 1, "not enough loose args");
42 : pluginFilename = nsDependentString(values[0].c_str());
43 : #else
44 : #error Not implemented
45 : #endif
46 :
47 0 : BackgroundHangMonitor::Startup();
48 :
49 0 : return mPlugin.Init(pluginFilename,
50 : ParentPid(),
51 : IOThreadChild::message_loop(),
52 0 : IOThreadChild::channel());
53 : }
54 :
55 : void
56 0 : GMPProcessChild::CleanUp()
57 : {
58 0 : BackgroundHangMonitor::Shutdown();
59 0 : }
60 :
61 : } // namespace gmp
62 : } // namespace mozilla
|