| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ppapi/nacl_irt/manifest_service.h" | 5 #include "ppapi/nacl_irt/manifest_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // IPC channel is asynchronously set up. So, the NaCl process may try to | 28 // IPC channel is asynchronously set up. So, the NaCl process may try to |
| 29 // send a OpenResource message to the host before the connection is | 29 // send a OpenResource message to the host before the connection is |
| 30 // established. In such a case, it is necessary to wait for the set up | 30 // established. In such a case, it is necessary to wait for the set up |
| 31 // completion. | 31 // completion. |
| 32 class ManifestMessageFilter : public IPC::SyncMessageFilter { | 32 class ManifestMessageFilter : public IPC::SyncMessageFilter { |
| 33 public: | 33 public: |
| 34 ManifestMessageFilter(base::WaitableEvent* shutdown_event) | 34 ManifestMessageFilter(base::WaitableEvent* shutdown_event) |
| 35 : SyncMessageFilter(shutdown_event, | 35 : SyncMessageFilter(shutdown_event, |
| 36 false /* is_channel_send_thread_safe */), | 36 false /* is_channel_send_thread_safe */), |
| 37 connected_event_( | 37 connected_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 38 true /* manual_reset */, false /* initially_signaled */) { | 38 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
| 39 } | |
| 40 | 39 |
| 41 bool Send(IPC::Message* message) override { | 40 bool Send(IPC::Message* message) override { |
| 42 // Wait until set up is actually done. | 41 // Wait until set up is actually done. |
| 43 connected_event_.Wait(); | 42 connected_event_.Wait(); |
| 44 return SyncMessageFilter::Send(message); | 43 return SyncMessageFilter::Send(message); |
| 45 } | 44 } |
| 46 | 45 |
| 47 // When set up is done, OnFilterAdded is called on IO thread. Unblocks the | 46 // When set up is done, OnFilterAdded is called on IO thread. Unblocks the |
| 48 // Send(). | 47 // Send(). |
| 49 void OnFilterAdded(IPC::Sender* sender) override { | 48 void OnFilterAdded(IPC::Sender* sender) override { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 163 |
| 165 ManifestService* manifest_service = GetManifestService(); | 164 ManifestService* manifest_service = GetManifestService(); |
| 166 if (manifest_service == NULL || | 165 if (manifest_service == NULL || |
| 167 !manifest_service->OpenResource(file, fd)) { | 166 !manifest_service->OpenResource(file, fd)) { |
| 168 return NACL_ABI_EIO; | 167 return NACL_ABI_EIO; |
| 169 } | 168 } |
| 170 return (*fd == -1) ? NACL_ABI_ENOENT : 0; | 169 return (*fd == -1) ? NACL_ABI_ENOENT : 0; |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace ppapi | 172 } // namespace ppapi |
| OLD | NEW |