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

Side by Side Diff: chrome/nacl/nacl_listener.cc

Issue 8397001: Open NaCl IRT file only once at startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/nacl/nacl_listener.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/nacl/nacl_listener.h" 5 #include "chrome/nacl/nacl_listener.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { 90 bool NaClListener::OnMessageReceived(const IPC::Message& msg) {
91 bool handled = true; 91 bool handled = true;
92 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) 92 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg)
93 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr) 93 IPC_MESSAGE_HANDLER(NaClProcessMsg_Start, OnStartSelLdr)
94 IPC_MESSAGE_UNHANDLED(handled = false) 94 IPC_MESSAGE_UNHANDLED(handled = false)
95 IPC_END_MESSAGE_MAP() 95 IPC_END_MESSAGE_MAP()
96 return handled; 96 return handled;
97 } 97 }
98 98
99 void NaClListener::OnStartSelLdr( 99 void NaClListener::OnStartSelLdr(std::vector<nacl::FileDescriptor> handles) {
100 std::vector<nacl::FileDescriptor> handles,
101 bool have_irt_file) {
102 #if defined(OS_LINUX) 100 #if defined(OS_LINUX)
103 nacl::SetCreateMemoryObjectFunc(content::MakeSharedMemorySegmentViaIPC); 101 nacl::SetCreateMemoryObjectFunc(content::MakeSharedMemorySegmentViaIPC);
104 #elif defined(OS_MACOSX) 102 #elif defined(OS_MACOSX)
105 nacl::SetCreateMemoryObjectFunc(CreateMemoryObject); 103 nacl::SetCreateMemoryObjectFunc(CreateMemoryObject);
106 CHECK(handles.size() >= 1); 104 CHECK(handles.size() >= 1);
107 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); 105 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]);
108 handles.pop_back(); 106 handles.pop_back();
109 #endif 107 #endif
110 108
111 if (have_irt_file) { 109 CHECK(handles.size() >= 1);
112 CHECK(handles.size() >= 1); 110 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]);
113 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]); 111 handles.pop_back();
114 handles.pop_back(); 112
115 #if defined(OS_WIN) 113 #if defined(OS_WIN)
116 int irt_desc = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), 114 int irt_desc = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle),
117 _O_RDWR | _O_BINARY); 115 _O_RDONLY | _O_BINARY);
118 if (irt_desc < 0) { 116 if (irt_desc < 0) {
119 LOG(ERROR) << "_open_osfhandle() failed"; 117 LOG(ERROR) << "_open_osfhandle() failed";
120 return; 118 return;
121 } 119 }
122 #else 120 #else
123 int irt_desc = irt_handle; 121 int irt_desc = irt_handle;
124 #endif 122 #endif
125 NaClSetIrtFileDesc(irt_desc); 123
126 } 124 NaClSetIrtFileDesc(irt_desc);
127 125
128 scoped_array<NaClHandle> array(new NaClHandle[handles.size()]); 126 scoped_array<NaClHandle> array(new NaClHandle[handles.size()]);
129 for (size_t i = 0; i < handles.size(); i++) { 127 for (size_t i = 0; i < handles.size(); i++) {
130 array[i] = nacl::ToNativeHandle(handles[i]); 128 array[i] = nacl::ToNativeHandle(handles[i]);
131 } 129 }
132 NaClMainForChromium(static_cast<int>(handles.size()), array.get(), 130 NaClMainForChromium(static_cast<int>(handles.size()), array.get(),
133 debug_enabled_); 131 debug_enabled_);
134 NOTREACHED(); 132 NOTREACHED();
135 } 133 }
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_listener.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698