75ffc9cf545d28f9dee1872ca02c8f12018e1524
[platform/framework/web/crosswalk.git] / src / xwalk / application / tools / linux / xwalk_extension_process_launcher.cc
1 // Copyright (c) 2014 Intel Corporation. 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 "base/message_loop/message_loop.h"
6 #include "xwalk/application/tools/linux/xwalk_extension_process_launcher.h"
7 #include "xwalk/extensions/extension_process/xwalk_extension_process.h"
8
9 XWalkExtensionProcessLauncher::XWalkExtensionProcessLauncher()
10     : base::Thread("LauncherExtensionService"),
11       is_started_(false) {
12   base::Thread::Options thread_options;
13   thread_options.message_loop_type = base::MessageLoop::TYPE_DEFAULT;
14   StartWithOptions(thread_options);
15 }
16
17 XWalkExtensionProcessLauncher::~XWalkExtensionProcessLauncher() {
18   Stop();
19 }
20
21 void XWalkExtensionProcessLauncher::Launch(
22     const std::string& channel_id, int channel_fd) {
23   is_started_ = true;
24   message_loop()->PostTask(
25       FROM_HERE,
26       base::Bind(&XWalkExtensionProcessLauncher::StartExtensionProcess,
27                  base::Unretained(this), channel_id, channel_fd));
28 }
29
30 void XWalkExtensionProcessLauncher::StartExtensionProcess(
31     const std::string& channel_id, int channel_fd) {
32   extension_process_.reset(new xwalk::extensions::XWalkExtensionProcess(
33       IPC::ChannelHandle(channel_id, base::FileDescriptor(channel_fd, true))));
34 }