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