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 "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
8 #include "ipc/ipc_channel_handle.h" | 8 #include "ipc/ipc_channel_handle.h" |
9 #include "ipc/ipc_channel_proxy.h" | 9 #include "ipc/ipc_channel_proxy.h" |
10 #include "ipc/ipc_sync_message_filter.h" | 10 #include "ipc/ipc_sync_message_filter.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // established. In such a case, it is necessary to wait for the set up | 26 // established. In such a case, it is necessary to wait for the set up |
27 // completion. | 27 // completion. |
28 class ManifestMessageFilter : public IPC::SyncMessageFilter { | 28 class ManifestMessageFilter : public IPC::SyncMessageFilter { |
29 public: | 29 public: |
30 ManifestMessageFilter(base::WaitableEvent* shutdown_event) | 30 ManifestMessageFilter(base::WaitableEvent* shutdown_event) |
31 : SyncMessageFilter(shutdown_event), | 31 : SyncMessageFilter(shutdown_event), |
32 connected_event_( | 32 connected_event_( |
33 true /* manual_reset */, false /* initially_signaled */) { | 33 true /* manual_reset */, false /* initially_signaled */) { |
34 } | 34 } |
35 | 35 |
36 virtual bool Send(IPC::Message* message) override { | 36 bool Send(IPC::Message* message) override { |
37 // Wait until set up is actually done. | 37 // Wait until set up is actually done. |
38 connected_event_.Wait(); | 38 connected_event_.Wait(); |
39 return SyncMessageFilter::Send(message); | 39 return SyncMessageFilter::Send(message); |
40 } | 40 } |
41 | 41 |
42 // When set up is done, OnFilterAdded is called on IO thread. Unblocks the | 42 // When set up is done, OnFilterAdded is called on IO thread. Unblocks the |
43 // Send(). | 43 // Send(). |
44 virtual void OnFilterAdded(IPC::Sender* sender) override { | 44 void OnFilterAdded(IPC::Sender* sender) override { |
45 SyncMessageFilter::OnFilterAdded(sender); | 45 SyncMessageFilter::OnFilterAdded(sender); |
46 connected_event_.Signal(); | 46 connected_event_.Signal(); |
47 } | 47 } |
48 | 48 |
49 // If an error is found, unblocks the Send(), too, to return an error. | 49 // If an error is found, unblocks the Send(), too, to return an error. |
50 virtual void OnChannelError() override { | 50 void OnChannelError() override { |
51 SyncMessageFilter::OnChannelError(); | 51 SyncMessageFilter::OnChannelError(); |
52 connected_event_.Signal(); | 52 connected_event_.Signal(); |
53 } | 53 } |
54 | 54 |
55 // Similar to OnChannelError, unblocks the Send() on the channel closing. | 55 // Similar to OnChannelError, unblocks the Send() on the channel closing. |
56 virtual void OnChannelClosing() override { | 56 void OnChannelClosing() override { |
57 SyncMessageFilter::OnChannelClosing(); | 57 SyncMessageFilter::OnChannelClosing(); |
58 connected_event_.Signal(); | 58 connected_event_.Signal(); |
59 } | 59 } |
60 | 60 |
61 private: | 61 private: |
62 base::WaitableEvent connected_event_; | 62 base::WaitableEvent connected_event_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(ManifestMessageFilter); | 64 DISALLOW_COPY_AND_ASSIGN(ManifestMessageFilter); |
65 }; | 65 }; |
66 | 66 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 ManifestService* manifest_service = GetManifestService(); | 164 ManifestService* manifest_service = GetManifestService(); |
165 if (manifest_service == NULL || | 165 if (manifest_service == NULL || |
166 !manifest_service->OpenResource(file, fd)) { | 166 !manifest_service->OpenResource(file, fd)) { |
167 return NACL_ABI_EIO; | 167 return NACL_ABI_EIO; |
168 } | 168 } |
169 return (*fd == -1) ? NACL_ABI_ENOENT : 0; | 169 return (*fd == -1) ? NACL_ABI_ENOENT : 0; |
170 } | 170 } |
171 | 171 |
172 } // namespace ppapi | 172 } // namespace ppapi |
OLD | NEW |