| 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 <stdint.h> |
| 9 |
| 8 #include <list> | 10 #include <list> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" |
| 12 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
| 13 #include "sandbox/win/src/crosscall_params.h" | 15 #include "sandbox/win/src/crosscall_params.h" |
| 14 #include "sandbox/win/src/crosscall_server.h" | 16 #include "sandbox/win/src/crosscall_server.h" |
| 15 #include "sandbox/win/src/sharedmem_ipc_client.h" | 17 #include "sandbox/win/src/sharedmem_ipc_client.h" |
| 16 | 18 |
| 17 // IPC transport implementation that uses shared memory. | 19 // IPC transport implementation that uses shared memory. |
| 18 // This is the server side | 20 // This is the server side |
| 19 // | 21 // |
| 20 // The server side has knowledge about the layout of the shared memory | 22 // The server side has knowledge about the layout of the shared memory |
| 21 // and the state transitions. Both are explained in sharedmem_ipc_client.h | 23 // and the state transitions. Both are explained in sharedmem_ipc_client.h |
| (...skipping 24 matching lines...) Expand all Loading... |
| 46 // target_process_id: process id of the target process. | 48 // target_process_id: process id of the target process. |
| 47 // thread_provider: a thread provider object. | 49 // thread_provider: a thread provider object. |
| 48 // dispatcher: an object that can service IPC calls. | 50 // dispatcher: an object that can service IPC calls. |
| 49 SharedMemIPCServer(HANDLE target_process, DWORD target_process_id, | 51 SharedMemIPCServer(HANDLE target_process, DWORD target_process_id, |
| 50 ThreadProvider* thread_provider, Dispatcher* dispatcher); | 52 ThreadProvider* thread_provider, Dispatcher* dispatcher); |
| 51 | 53 |
| 52 ~SharedMemIPCServer(); | 54 ~SharedMemIPCServer(); |
| 53 | 55 |
| 54 // Initializes the server structures, shared memory structures and | 56 // Initializes the server structures, shared memory structures and |
| 55 // creates the kernels events used to signal the IPC. | 57 // creates the kernels events used to signal the IPC. |
| 56 bool Init(void* shared_mem, uint32 shared_size, uint32 channel_size); | 58 bool Init(void* shared_mem, uint32_t shared_size, uint32_t channel_size); |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 // Allow tests to be marked DISABLED_. Note that FLAKY_ and FAILS_ prefixes | 61 // Allow tests to be marked DISABLED_. Note that FLAKY_ and FAILS_ prefixes |
| 60 // do not work with sandbox tests. | 62 // do not work with sandbox tests. |
| 61 FRIEND_TEST_ALL_PREFIXES(IPCTest, SharedMemServerTests); | 63 FRIEND_TEST_ALL_PREFIXES(IPCTest, SharedMemServerTests); |
| 62 // When an event fires (IPC request). A thread from the ThreadProvider | 64 // When an event fires (IPC request). A thread from the ThreadProvider |
| 63 // will call this function. The context parameter should be the same as | 65 // will call this function. The context parameter should be the same as |
| 64 // provided when ThreadProvider::RegisterWait was called. | 66 // provided when ThreadProvider::RegisterWait was called. |
| 65 static void __stdcall ThreadPingEventReady(void* context, | 67 static void __stdcall ThreadPingEventReady(void* context, |
| 66 unsigned char); | 68 unsigned char); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 // call or about threading issues. | 80 // call or about threading issues. |
| 79 struct ServerControl { | 81 struct ServerControl { |
| 80 ServerControl(); | 82 ServerControl(); |
| 81 ~ServerControl(); | 83 ~ServerControl(); |
| 82 | 84 |
| 83 // This channel server ping event. | 85 // This channel server ping event. |
| 84 base::win::ScopedHandle ping_event; | 86 base::win::ScopedHandle ping_event; |
| 85 // This channel server pong event. | 87 // This channel server pong event. |
| 86 base::win::ScopedHandle pong_event; | 88 base::win::ScopedHandle pong_event; |
| 87 // The size of this channel. | 89 // The size of this channel. |
| 88 uint32 channel_size; | 90 uint32_t channel_size; |
| 89 // The pointer to the actual channel data. | 91 // The pointer to the actual channel data. |
| 90 char* channel_buffer; | 92 char* channel_buffer; |
| 91 // The pointer to the base of the shared memory. | 93 // The pointer to the base of the shared memory. |
| 92 char* shared_base; | 94 char* shared_base; |
| 93 // A pointer to this channel's client-side control structure this structure | 95 // A pointer to this channel's client-side control structure this structure |
| 94 // lives in the shared memory. | 96 // lives in the shared memory. |
| 95 ChannelControl* channel; | 97 ChannelControl* channel; |
| 96 // the IPC dispatcher associated with this channel. | 98 // the IPC dispatcher associated with this channel. |
| 97 Dispatcher* dispatcher; | 99 Dispatcher* dispatcher; |
| 98 // The target process information associated with this channel. | 100 // The target process information associated with this channel. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 123 | 125 |
| 124 // The dispatcher handles 'ready' IPC calls. | 126 // The dispatcher handles 'ready' IPC calls. |
| 125 Dispatcher* call_dispatcher_; | 127 Dispatcher* call_dispatcher_; |
| 126 | 128 |
| 127 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); | 129 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 } // namespace sandbox | 132 } // namespace sandbox |
| 131 | 133 |
| 132 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ | 134 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
| OLD | NEW |