Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2356)

Unified Diff: ppapi/nacl_irt/plugin_startup.cc

Issue 231793003: Add IPC Channel for new ManifestService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/nacl_irt/plugin_startup.h ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/nacl_irt/plugin_startup.cc
diff --git a/ppapi/nacl_irt/plugin_startup.cc b/ppapi/nacl_irt/plugin_startup.cc
index a3b5bc207e67acd95aab07893815941e4d7eeda1..986fe32337087dd76f6a294cdc9c22f4cb627b89 100644
--- a/ppapi/nacl_irt/plugin_startup.cc
+++ b/ppapi/nacl_irt/plugin_startup.cc
@@ -2,28 +2,58 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/nacl_irt/plugin_startup.h"
+
+#include "base/bind.h"
+#include "base/file_descriptor_posix.h"
#include "base/logging.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
-#include "ppapi/nacl_irt/plugin_startup.h"
+#include "ipc/ipc_channel_handle.h"
+#include "ppapi/nacl_irt/manifest_service.h"
namespace ppapi {
namespace {
int g_nacl_browser_ipc_fd = -1;
int g_nacl_renderer_ipc_fd = -1;
+int g_manifest_service_fd = -1;
base::WaitableEvent* g_shutdown_event = NULL;
base::Thread* g_io_thread = NULL;
+ManifestService* g_manifest_service = NULL;
+
+// Creates the manifest service on IO thread so that its Listener's thread and
+// IO thread are shared. Upon completion of the manifest service creation,
+// event is signaled.
+void StartUpManifestServiceOnIOThread(base::WaitableEvent* event) {
+ // The start up must be called only once.
+ DCHECK(!g_manifest_service);
+ // manifest_service_fd must be set.
+ DCHECK_NE(g_manifest_service_fd, -1);
+ // IOThread and shutdown event must be initialized in advance.
+ DCHECK(g_io_thread);
+ DCHECK(g_shutdown_event);
+
+ g_manifest_service = new ManifestService(
+ IPC::ChannelHandle(
+ "NaCl IPC", base::FileDescriptor(g_manifest_service_fd, false)),
+ g_io_thread->message_loop_proxy(),
+ g_shutdown_event);
+ event->Signal();
+}
} // namespace
-void SetIPCFileDescriptors(int browser_ipc_fd, int renderer_ipc_fd) {
+void SetIPCFileDescriptors(
+ int browser_ipc_fd, int renderer_ipc_fd, int manifest_service_fd) {
// The initialization must be only once.
DCHECK_EQ(g_nacl_browser_ipc_fd, -1);
DCHECK_EQ(g_nacl_renderer_ipc_fd, -1);
+ DCHECK_EQ(g_manifest_service_fd, -1);
g_nacl_browser_ipc_fd = browser_ipc_fd;
g_nacl_renderer_ipc_fd = renderer_ipc_fd;
+ g_manifest_service_fd = manifest_service_fd;
}
void StartUpPlugin() {
@@ -35,6 +65,20 @@ void StartUpPlugin() {
g_io_thread = new base::Thread("Chrome_NaClIOThread");
g_io_thread->StartWithOptions(
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+
+ if (g_manifest_service_fd != -1) {
+ // Manifest service must be created on IOThread so that the main message
+ // handling will be done on the thread, which has a message loop
+ // even before irt_ppapi_start invocation.
+ // TODO(hidehiko,dmichael): This works, but is probably not well designed
+ // usage. Once a better approach is made, replace this by that way.
+ // (crbug.com/364241).
+ base::WaitableEvent event(true, false);
+ g_io_thread->message_loop_proxy()->PostTask(
+ FROM_HERE,
+ base::Bind(StartUpManifestServiceOnIOThread, &event));
+ event.Wait();
+ }
}
int GetBrowserIPCFileDescriptor() {
« no previous file with comments | « ppapi/nacl_irt/plugin_startup.h ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698