OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ | 5 #ifndef SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
6 #define SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ | 6 #define SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/win/scoped_handle.h" |
12 #include "sandbox/win/src/crosscall_params.h" | 13 #include "sandbox/win/src/crosscall_params.h" |
13 #include "sandbox/win/src/crosscall_server.h" | 14 #include "sandbox/win/src/crosscall_server.h" |
14 #include "sandbox/win/src/sharedmem_ipc_client.h" | 15 #include "sandbox/win/src/sharedmem_ipc_client.h" |
15 | 16 |
16 // IPC transport implementation that uses shared memory. | 17 // IPC transport implementation that uses shared memory. |
17 // This is the server side | 18 // This is the server side |
18 // | 19 // |
19 // The server side has knowledge about the layout of the shared memory | 20 // The server side has knowledge about the layout of the shared memory |
20 // and the state transitions. Both are explained in sharedmem_ipc_client.h | 21 // and the state transitions. Both are explained in sharedmem_ipc_client.h |
21 // | 22 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // do not work with sandbox tests. | 57 // do not work with sandbox tests. |
57 FRIEND_TEST_ALL_PREFIXES(IPCTest, SharedMemServerTests); | 58 FRIEND_TEST_ALL_PREFIXES(IPCTest, SharedMemServerTests); |
58 // When an event fires (IPC request). A thread from the ThreadProvider | 59 // When an event fires (IPC request). A thread from the ThreadProvider |
59 // will call this function. The context parameter should be the same as | 60 // will call this function. The context parameter should be the same as |
60 // provided when ThreadProvider::RegisterWait was called. | 61 // provided when ThreadProvider::RegisterWait was called. |
61 static void __stdcall ThreadPingEventReady(void* context, | 62 static void __stdcall ThreadPingEventReady(void* context, |
62 unsigned char); | 63 unsigned char); |
63 | 64 |
64 // Makes the client and server events. This function is called once | 65 // Makes the client and server events. This function is called once |
65 // per channel. | 66 // per channel. |
66 bool MakeEvents(HANDLE* server_ping, HANDLE* server_pong, | 67 bool MakeEvents(base::win::ScopedHandle* server_ping, |
| 68 base::win::ScopedHandle* server_pong, |
67 HANDLE* client_ping, HANDLE* client_pong); | 69 HANDLE* client_ping, HANDLE* client_pong); |
68 | 70 |
69 // A copy this structure is maintained per channel. | 71 // A copy this structure is maintained per channel. |
70 // Note that a lot of the fields are just the same of what we have in the IPC | 72 // Note that a lot of the fields are just the same of what we have in the IPC |
71 // object itself. It is better to have the copies since we can dispatch in the | 73 // object itself. It is better to have the copies since we can dispatch in the |
72 // static method without worrying about converting back to a member function | 74 // static method without worrying about converting back to a member function |
73 // call or about threading issues. | 75 // call or about threading issues. |
74 struct ServerControl { | 76 struct ServerControl { |
75 // This channel server ping event. | 77 // This channel server ping event. |
76 HANDLE ping_event; | 78 base::win::ScopedHandle ping_event; |
77 // This channel server pong event. | 79 // This channel server pong event. |
78 HANDLE pong_event; | 80 base::win::ScopedHandle pong_event; |
79 // The size of this channel. | 81 // The size of this channel. |
80 uint32 channel_size; | 82 uint32 channel_size; |
81 // The pointer to the actual channel data. | 83 // The pointer to the actual channel data. |
82 char* channel_buffer; | 84 char* channel_buffer; |
83 // The pointer to the base of the shared memory. | 85 // The pointer to the base of the shared memory. |
84 char* shared_base; | 86 char* shared_base; |
85 // A pointer to this channel's client-side control structure this structure | 87 // A pointer to this channel's client-side control structure this structure |
86 // lives in the shared memory. | 88 // lives in the shared memory. |
87 ChannelControl* channel; | 89 ChannelControl* channel; |
88 // the IPC dispatcher associated with this channel. | 90 // the IPC dispatcher associated with this channel. |
(...skipping 29 matching lines...) Expand all Loading... |
118 | 120 |
119 // The dispatcher handles 'ready' IPC calls. | 121 // The dispatcher handles 'ready' IPC calls. |
120 Dispatcher* call_dispatcher_; | 122 Dispatcher* call_dispatcher_; |
121 | 123 |
122 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); | 124 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); |
123 }; | 125 }; |
124 | 126 |
125 } // namespace sandbox | 127 } // namespace sandbox |
126 | 128 |
127 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ | 129 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
OLD | NEW |