| 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // ThreadPingEventReady callback. The IPC server then retrieves the buffer, | 29 // ThreadPingEventReady callback. The IPC server then retrieves the buffer, |
| 30 // marshals it into a CrossCallParam object and calls the Dispatcher, who is in | 30 // marshals it into a CrossCallParam object and calls the Dispatcher, who is in |
| 31 // charge of fulfilling the IPC request. | 31 // charge of fulfilling the IPC request. |
| 32 namespace sandbox { | 32 namespace sandbox { |
| 33 | 33 |
| 34 // the shared memory implementation of the IPC server. There should be one | 34 // the shared memory implementation of the IPC server. There should be one |
| 35 // of these objects per target (IPC client) process | 35 // of these objects per target (IPC client) process |
| 36 class SharedMemIPCServer { | 36 class SharedMemIPCServer { |
| 37 public: | 37 public: |
| 38 // Creates the IPC server. | 38 // Creates the IPC server. |
| 39 // target_process: handle to the target process. It must be suspended. | 39 // target_process: handle to the target process. It must be suspended. It is |
| 40 // unfortunate to receive a raw handle (and store it inside this object) as |
| 41 // that dilutes ownership of the process, but in practice a SharedMemIPCServer |
| 42 // is owned by TargetProcess, which calls this method, and owns the handle, so |
| 43 // everything is safe. If that changes, we should break this dependency and |
| 44 // duplicate the handle instead. |
| 40 // target_process_id: process id of the target process. | 45 // target_process_id: process id of the target process. |
| 41 // target_job: the job object handle associated with the target process. | |
| 42 // thread_provider: a thread provider object. | 46 // thread_provider: a thread provider object. |
| 43 // dispatcher: an object that can service IPC calls. | 47 // dispatcher: an object that can service IPC calls. |
| 44 SharedMemIPCServer(HANDLE target_process, DWORD target_process_id, | 48 SharedMemIPCServer(HANDLE target_process, DWORD target_process_id, |
| 45 HANDLE target_job, ThreadProvider* thread_provider, | 49 ThreadProvider* thread_provider, Dispatcher* dispatcher); |
| 46 Dispatcher* dispatcher); | |
| 47 | 50 |
| 48 ~SharedMemIPCServer(); | 51 ~SharedMemIPCServer(); |
| 49 | 52 |
| 50 // Initializes the server structures, shared memory structures and | 53 // Initializes the server structures, shared memory structures and |
| 51 // creates the kernels events used to signal the IPC. | 54 // creates the kernels events used to signal the IPC. |
| 52 bool Init(void* shared_mem, uint32 shared_size, uint32 channel_size); | 55 bool Init(void* shared_mem, uint32 shared_size, uint32 channel_size); |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 // Allow tests to be marked DISABLED_. Note that FLAKY_ and FAILS_ prefixes | 58 // Allow tests to be marked DISABLED_. Note that FLAKY_ and FAILS_ prefixes |
| 56 // do not work with sandbox tests. | 59 // do not work with sandbox tests. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // The thread provider provides the threads that call back into this object | 109 // The thread provider provides the threads that call back into this object |
| 107 // when the IPC events fire. | 110 // when the IPC events fire. |
| 108 ThreadProvider* thread_provider_; | 111 ThreadProvider* thread_provider_; |
| 109 | 112 |
| 110 // The IPC object is associated with a target process. | 113 // The IPC object is associated with a target process. |
| 111 HANDLE target_process_; | 114 HANDLE target_process_; |
| 112 | 115 |
| 113 // The target process id associated with the IPC object. | 116 // The target process id associated with the IPC object. |
| 114 DWORD target_process_id_; | 117 DWORD target_process_id_; |
| 115 | 118 |
| 116 // The target object is inside a job too. | |
| 117 HANDLE target_job_object_; | |
| 118 | |
| 119 // The dispatcher handles 'ready' IPC calls. | 119 // The dispatcher handles 'ready' IPC calls. |
| 120 Dispatcher* call_dispatcher_; | 120 Dispatcher* call_dispatcher_; |
| 121 | 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); | 122 DISALLOW_COPY_AND_ASSIGN(SharedMemIPCServer); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 } // namespace sandbox | 125 } // namespace sandbox |
| 126 | 126 |
| 127 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ | 127 #endif // SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ |
| OLD | NEW |