Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_NACL_NACL_IPC_ADAPTER_H_ | 5 #ifndef CHROME_NACL_NACL_IPC_ADAPTER_H_ |
| 6 #define CHROME_NACL_NACL_IPC_ADAPTER_H_ | 6 #define CHROME_NACL_NACL_IPC_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 #pragma pack(push, 4) | 65 #pragma pack(push, 4) |
| 66 struct NaClMessageHeader : public Pickle::Header { | 66 struct NaClMessageHeader : public Pickle::Header { |
| 67 int32 routing; | 67 int32 routing; |
| 68 uint32 type; | 68 uint32 type; |
| 69 uint32 flags; | 69 uint32 flags; |
| 70 uint16 num_fds; | 70 uint16 num_fds; |
| 71 uint16 pad; | 71 uint16 pad; |
| 72 }; | 72 }; |
| 73 #pragma pack(pop) | 73 #pragma pack(pop) |
| 74 | 74 |
| 75 typedef base::Callback<void(IPC::PlatformFileForTransit, base::FilePath)> | |
| 76 ResolveFileTokenReplyCallback; | |
| 77 | |
| 78 typedef base::Callback<void(uint64_t, // file_token_lo | |
| 79 uint64_t, // file_token_hi | |
| 80 ResolveFileTokenReplyCallback)> | |
| 81 ResolveFileTokenCallback; | |
| 82 | |
| 75 // Creates an adapter, using the thread associated with the given task | 83 // Creates an adapter, using the thread associated with the given task |
| 76 // runner for posting messages. In normal use, the task runner will post to | 84 // runner for posting messages. In normal use, the task runner will post to |
| 77 // the I/O thread of the process. | 85 // the I/O thread of the process. |
| 78 // | 86 // |
| 79 // If you use this constructor, you MUST call ConnectChannel after the | 87 // If you use this constructor, you MUST call ConnectChannel after the |
| 80 // NaClIPCAdapter is constructed, or the NaClIPCAdapter's channel will not be | 88 // NaClIPCAdapter is constructed, or the NaClIPCAdapter's channel will not be |
| 81 // connected. | 89 // connected. |
| 82 NaClIPCAdapter(const IPC::ChannelHandle& handle, base::TaskRunner* runner); | 90 // |
| 91 // |resolve_file_token_cb| is a callback to be invoked for resolving file | |
|
Mark Seaborn
2015/04/16 20:51:21
Maybe say "optional callback"?
Yusuke Sato
2015/04/16 21:25:02
Done.
| |
| 92 // tokens received from the renderer. When the file token is resolved, the | |
| 93 // ResolveFileTokenReplyCallback passed inside the ResolveFileTokenCallback | |
| 94 // will be invoked. | |
| 95 NaClIPCAdapter( | |
| 96 const IPC::ChannelHandle& handle, | |
| 97 base::TaskRunner* runner, | |
| 98 ResolveFileTokenCallback resolve_file_token_cb); | |
| 83 | 99 |
| 84 // Initializes with a given channel that's already created for testing | 100 // Initializes with a given channel that's already created for testing |
| 85 // purposes. This function will take ownership of the given channel. | 101 // purposes. This function will take ownership of the given channel. |
| 86 NaClIPCAdapter(scoped_ptr<IPC::Channel> channel, base::TaskRunner* runner); | 102 NaClIPCAdapter(scoped_ptr<IPC::Channel> channel, base::TaskRunner* runner); |
| 87 | 103 |
| 88 // Connect the channel. This must be called after the constructor that accepts | 104 // Connect the channel. This must be called after the constructor that accepts |
| 89 // an IPC::ChannelHandle, and causes the Channel to be connected on the IO | 105 // an IPC::ChannelHandle, and causes the Channel to be connected on the IO |
| 90 // thread. | 106 // thread. |
| 91 void ConnectChannel(); | 107 void ConnectChannel(); |
| 92 | 108 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 108 | 124 |
| 109 #if defined(OS_POSIX) | 125 #if defined(OS_POSIX) |
| 110 base::ScopedFD TakeClientFileDescriptor(); | 126 base::ScopedFD TakeClientFileDescriptor(); |
| 111 #endif | 127 #endif |
| 112 | 128 |
| 113 // Listener implementation. | 129 // Listener implementation. |
| 114 bool OnMessageReceived(const IPC::Message& message) override; | 130 bool OnMessageReceived(const IPC::Message& message) override; |
| 115 void OnChannelConnected(int32 peer_pid) override; | 131 void OnChannelConnected(int32 peer_pid) override; |
| 116 void OnChannelError() override; | 132 void OnChannelError() override; |
| 117 | 133 |
| 118 typedef base::Callback<void(IPC::PlatformFileForTransit, base::FilePath)> | |
| 119 ResolveFileTokenReplyCallback; | |
| 120 | |
| 121 typedef base::Callback<void(uint64_t, // file_token_lo | |
| 122 uint64_t, // file_token_hi | |
| 123 ResolveFileTokenReplyCallback)> | |
| 124 ResolveFileTokenCallback; | |
| 125 | |
| 126 // Sets a callback to be invoked for resolving file tokens received from the | |
| 127 // renderer. When the file token is resolved, the | |
| 128 // ResolveFileTokenReplyCallback passed inside the ResolveFileTokenCallback | |
| 129 // will be invoked. | |
| 130 void set_resolve_file_token_callback(ResolveFileTokenCallback cb) { | |
| 131 resolve_file_token_cb_ = cb; | |
| 132 } | |
| 133 | |
| 134 private: | 134 private: |
| 135 friend class base::RefCountedThreadSafe<NaClIPCAdapter>; | 135 friend class base::RefCountedThreadSafe<NaClIPCAdapter>; |
| 136 | 136 |
| 137 class RewrittenMessage; | 137 class RewrittenMessage; |
| 138 | 138 |
| 139 // This is the data that must only be accessed inside the lock. This struct | 139 // This is the data that must only be accessed inside the lock. This struct |
| 140 // just separates it so it's easier to see. | 140 // just separates it so it's easier to see. |
| 141 struct LockedData { | 141 struct LockedData { |
| 142 LockedData(); | 142 LockedData(); |
| 143 ~LockedData(); | 143 ~LockedData(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 // To be accessed on the I/O thread (via task runner) only. | 216 // To be accessed on the I/O thread (via task runner) only. |
| 217 IOThreadData io_thread_data_; | 217 IOThreadData io_thread_data_; |
| 218 | 218 |
| 219 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter); | 219 DISALLOW_COPY_AND_ASSIGN(NaClIPCAdapter); |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 // Export TranslatePepperFileReadWriteOpenFlags for testing. | 222 // Export TranslatePepperFileReadWriteOpenFlags for testing. |
| 223 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags); | 223 int TranslatePepperFileReadWriteOpenFlagsForTesting(int32_t pp_open_flags); |
| 224 | 224 |
| 225 #endif // CHROME_NACL_NACL_IPC_ADAPTER_H_ | 225 #endif // CHROME_NACL_NACL_IPC_ADAPTER_H_ |
| OLD | NEW |