Release the Settings API.
[chromium-blink-merge.git] / ppapi / nacl_irt / plugin_startup.cc
bloba3b5bc207e67acd95aab07893815941e4d7eeda1
1 // Copyright 2014 The Chromium 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.
5 #include "base/logging.h"
6 #include "base/synchronization/waitable_event.h"
7 #include "base/threading/thread.h"
8 #include "ppapi/nacl_irt/plugin_startup.h"
10 namespace ppapi {
11 namespace {
13 int g_nacl_browser_ipc_fd = -1;
14 int g_nacl_renderer_ipc_fd = -1;
16 base::WaitableEvent* g_shutdown_event = NULL;
17 base::Thread* g_io_thread = NULL;
19 } // namespace
21 void SetIPCFileDescriptors(int browser_ipc_fd, int renderer_ipc_fd) {
22 // The initialization must be only once.
23 DCHECK_EQ(g_nacl_browser_ipc_fd, -1);
24 DCHECK_EQ(g_nacl_renderer_ipc_fd, -1);
25 g_nacl_browser_ipc_fd = browser_ipc_fd;
26 g_nacl_renderer_ipc_fd = renderer_ipc_fd;
29 void StartUpPlugin() {
30 // The start up must be called only once.
31 DCHECK(!g_shutdown_event);
32 DCHECK(!g_io_thread);
34 g_shutdown_event = new base::WaitableEvent(true, false);
35 g_io_thread = new base::Thread("Chrome_NaClIOThread");
36 g_io_thread->StartWithOptions(
37 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
40 int GetBrowserIPCFileDescriptor() {
41 // The descriptor must be initialized in advance.
42 DCHECK_NE(g_nacl_browser_ipc_fd, -1);
43 return g_nacl_browser_ipc_fd;
46 int GetRendererIPCFileDescriptor() {
47 // The descriptor must be initialized in advance.
48 DCHECK_NE(g_nacl_renderer_ipc_fd, -1);
49 return g_nacl_renderer_ipc_fd;
52 base::WaitableEvent* GetShutdownEvent() {
53 // The shutdown event must be initialized in advance.
54 DCHECK(g_shutdown_event);
55 return g_shutdown_event;
58 base::Thread* GetIOThread() {
59 // The IOThread must be initialized in advance.
60 DCHECK(g_io_thread);
61 return g_io_thread;
64 } // namespace ppapi