OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 "sandbox/src/crosscall_params.h" | 11 #include "sandbox/src/crosscall_params.h" |
12 #include "sandbox/src/crosscall_server.h" | 12 #include "sandbox/src/crosscall_server.h" |
13 #include "sandbox/src/sharedmem_ipc_client.h" | 13 #include "sandbox/src/sharedmem_ipc_client.h" |
14 | 14 |
| 15 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 16 |
15 // IPC transport implementation that uses shared memory. | 17 // IPC transport implementation that uses shared memory. |
16 // This is the server side | 18 // This is the server side |
17 // | 19 // |
18 // 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 |
19 // 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 |
20 // | 22 // |
21 // As opposed to SharedMemIPClient, the Server object should be one for the | 23 // As opposed to SharedMemIPClient, the Server object should be one for the |
22 // entire lifetime of the target process. The server is in charge of creating | 24 // entire lifetime of the target process. The server is in charge of creating |
23 // the events (ping, pong) both for the client and for the target that are used | 25 // the events (ping, pong) both for the client and for the target that are used |
24 // to signal the IPC and also in charge of setting the initial state of the | 26 // to signal the IPC and also in charge of setting the initial state of the |
(...skipping 19 matching lines...) Expand all Loading... |
44 HANDLE target_job, ThreadProvider* thread_provider, | 46 HANDLE target_job, ThreadProvider* thread_provider, |
45 Dispatcher* dispatcher); | 47 Dispatcher* dispatcher); |
46 | 48 |
47 ~SharedMemIPCServer(); | 49 ~SharedMemIPCServer(); |
48 | 50 |
49 // Initializes the server structures, shared memory structures and | 51 // Initializes the server structures, shared memory structures and |
50 // creates the kernels events used to signal the IPC. | 52 // creates the kernels events used to signal the IPC. |
51 bool Init(void* shared_mem, size_t shared_size, size_t channel_size); | 53 bool Init(void* shared_mem, size_t shared_size, size_t channel_size); |
52 | 54 |
53 private: | 55 private: |
| 56 FRIEND_TEST(IPCTest, SharedMemServerTests); |
54 // When an event fires (IPC request). A thread from the ThreadProvider | 57 // When an event fires (IPC request). A thread from the ThreadProvider |
55 // will call this function. The context parameter should be the same as | 58 // will call this function. The context parameter should be the same as |
56 // provided when ThreadProvider::RegisterWait was called. | 59 // provided when ThreadProvider::RegisterWait was called. |
57 static void __stdcall ThreadPingEventReady(void* context, | 60 static void __stdcall ThreadPingEventReady(void* context, |
58 unsigned char); | 61 unsigned char); |
59 | 62 |
60 // Makes the client and server events. This function is called once | 63 // Makes the client and server events. This function is called once |
61 // per channel. | 64 // per channel. |
62 bool MakeEvents(HANDLE* server_ping, HANDLE* server_pong, | 65 bool MakeEvents(HANDLE* server_ping, HANDLE* server_pong, |
63 HANDLE* client_ping, HANDLE* client_pong); | 66 HANDLE* client_ping, HANDLE* client_pong); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 HANDLE target_job_object_; | 116 HANDLE target_job_object_; |
114 | 117 |
115 // The dispatcher handles 'ready' IPC calls. | 118 // The dispatcher handles 'ready' IPC calls. |
116 Dispatcher* call_dispatcher_; | 119 Dispatcher* call_dispatcher_; |
117 | 120 |
118 DISALLOW_EVIL_CONSTRUCTORS(SharedMemIPCServer); | 121 DISALLOW_EVIL_CONSTRUCTORS(SharedMemIPCServer); |
119 }; | 122 }; |
120 | 123 |
121 } // namespace sandbox | 124 } // namespace sandbox |
122 | 125 |
123 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H__ | 126 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
OLD | NEW |