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
3 // found in the LICENSE file.
5 // Common IPC messages used for child processes.
6 // Multiply-included message file, hence no include guard.
11 #include "base/memory/shared_memory.h"
12 #include "base/tracked_objects.h"
13 #include "base/values.h"
14 #include "cc/resources/shared_bitmap_manager.h"
15 #include "content/common/content_export.h"
16 #include "content/common/host_discardable_shared_memory_manager.h"
17 #include "ipc/ipc_message_macros.h"
18 #include "ui/gfx/gpu_memory_buffer.h"
19 #include "ui/gfx/ipc/gfx_param_traits.h"
21 #if defined(OS_MACOSX)
22 #include "content/common/mac/io_surface_manager_token.h"
25 IPC_ENUM_TRAITS_MAX_VALUE(tracked_objects::ThreadData::Status
,
26 tracked_objects::ThreadData::STATUS_LAST
)
28 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::LocationSnapshot
)
29 IPC_STRUCT_TRAITS_MEMBER(file_name
)
30 IPC_STRUCT_TRAITS_MEMBER(function_name
)
31 IPC_STRUCT_TRAITS_MEMBER(line_number
)
32 IPC_STRUCT_TRAITS_END()
34 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::BirthOnThreadSnapshot
)
35 IPC_STRUCT_TRAITS_MEMBER(location
)
36 IPC_STRUCT_TRAITS_MEMBER(thread_name
)
37 IPC_STRUCT_TRAITS_END()
39 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::DeathDataSnapshot
)
40 IPC_STRUCT_TRAITS_MEMBER(count
)
41 IPC_STRUCT_TRAITS_MEMBER(run_duration_sum
)
42 IPC_STRUCT_TRAITS_MEMBER(run_duration_max
)
43 IPC_STRUCT_TRAITS_MEMBER(run_duration_sample
)
44 IPC_STRUCT_TRAITS_MEMBER(queue_duration_sum
)
45 IPC_STRUCT_TRAITS_MEMBER(queue_duration_max
)
46 IPC_STRUCT_TRAITS_MEMBER(queue_duration_sample
)
47 IPC_STRUCT_TRAITS_END()
49 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::TaskSnapshot
)
50 IPC_STRUCT_TRAITS_MEMBER(birth
)
51 IPC_STRUCT_TRAITS_MEMBER(death_data
)
52 IPC_STRUCT_TRAITS_MEMBER(death_thread_name
)
53 IPC_STRUCT_TRAITS_END()
55 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::ProcessDataPhaseSnapshot
)
56 IPC_STRUCT_TRAITS_MEMBER(tasks
)
57 IPC_STRUCT_TRAITS_END()
59 IPC_STRUCT_TRAITS_BEGIN(tracked_objects::ProcessDataSnapshot
)
60 IPC_STRUCT_TRAITS_MEMBER(phased_snapshots
)
61 IPC_STRUCT_TRAITS_MEMBER(process_id
)
62 IPC_STRUCT_TRAITS_END()
64 IPC_ENUM_TRAITS_MAX_VALUE(gfx::GpuMemoryBufferType
,
65 gfx::GPU_MEMORY_BUFFER_TYPE_LAST
)
67 IPC_STRUCT_TRAITS_BEGIN(gfx::GpuMemoryBufferHandle
)
68 IPC_STRUCT_TRAITS_MEMBER(id
)
69 IPC_STRUCT_TRAITS_MEMBER(type
)
70 IPC_STRUCT_TRAITS_MEMBER(handle
)
71 #if defined(USE_OZONE)
72 IPC_STRUCT_TRAITS_MEMBER(native_pixmap_handle
)
74 IPC_STRUCT_TRAITS_END()
76 IPC_STRUCT_TRAITS_BEGIN(gfx::GpuMemoryBufferId
)
77 IPC_STRUCT_TRAITS_MEMBER(id
)
78 IPC_STRUCT_TRAITS_END()
80 #undef IPC_MESSAGE_EXPORT
81 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
83 #define IPC_MESSAGE_START ChildProcessMsgStart
85 // Messages sent from the browser to the child process.
87 // Sent in response to ChildProcessHostMsg_ShutdownRequest to tell the child
88 // process that it's safe to shutdown.
89 IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown
)
91 #if defined(IPC_MESSAGE_LOG_ENABLED)
92 // Tell the child process to begin or end IPC message logging.
93 IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled
,
97 // Tell the child process to enable or disable the profiler status.
98 IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProfilerStatus
,
99 tracked_objects::ThreadData::Status
/* profiler status */)
101 // Send to all the child processes to send back profiler data (ThreadData in
103 IPC_MESSAGE_CONTROL2(ChildProcessMsg_GetChildProfilerData
,
104 int /* sequence_number */,
105 int /* current_profiling_phase */)
107 // Send to all the child processes to mark the current profiling phase as
108 // finished and start a new phase.
109 IPC_MESSAGE_CONTROL1(ChildProcessMsg_ProfilingPhaseCompleted
,
110 int /* profiling_phase */)
112 // Send to all the child processes to send back histogram data.
113 IPC_MESSAGE_CONTROL1(ChildProcessMsg_GetChildHistogramData
,
114 int /* sequence_number */)
116 // Sent to child processes to tell them to enter or leave background mode.
117 IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProcessBackgrounded
,
118 bool /* background */)
120 #if defined(USE_TCMALLOC)
121 // Sent to child process to request tcmalloc stats.
122 IPC_MESSAGE_CONTROL0(ChildProcessMsg_GetTcmallocStats
)
125 #if defined(OS_MACOSX)
126 // Sent to child processes to tell them what token to use when registering
127 // and/or acquiring IOSurfaces.
128 IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIOSurfaceManagerToken
,
129 content::IOSurfaceManagerToken
/* token */)
132 #if defined(USE_OZONE)
133 // Sent to child processes to initialize ClientNativePixmapFactory using
134 // a device file descriptor.
135 IPC_MESSAGE_CONTROL1(ChildProcessMsg_InitializeClientNativePixmapFactory
,
136 base::FileDescriptor
/* device_fd */)
138 ////////////////////////////////////////////////////////////////////////////////
139 // Messages sent from the child process to the browser.
141 IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest
)
143 // Send back profiler data (ThreadData in tracked_objects).
144 IPC_MESSAGE_CONTROL2(
145 ChildProcessHostMsg_ChildProfilerData
,
146 int, /* sequence_number */
147 tracked_objects::ProcessDataSnapshot
/* process_data_snapshot */)
149 // Send back histograms as vector of pickled-histogram strings.
150 IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_ChildHistogramData
,
151 int, /* sequence_number */
152 std::vector
<std::string
> /* histogram_data */)
154 // Request a histogram from the browser. The browser will send the histogram
155 // data only if it has been passed the command line flag
156 // switches::kDomAutomationController.
157 IPC_SYNC_MESSAGE_CONTROL1_1(ChildProcessHostMsg_GetBrowserHistogram
,
158 std::string
, /* histogram_name */
159 std::string
/* histogram_json */)
162 // Request that the given font be loaded by the host so it's cached by the
163 // OS. Please see ChildProcessHost::PreCacheFont for details.
164 IPC_SYNC_MESSAGE_CONTROL1_0(ChildProcessHostMsg_PreCacheFont
,
165 LOGFONT
/* font data */)
167 // Release the cached font
168 IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ReleaseCachedFonts
)
169 #endif // defined(OS_WIN)
171 // Asks the browser to create a block of shared memory for the child process to
172 // fill in and pass back to the browser.
173 IPC_SYNC_MESSAGE_CONTROL1_1(ChildProcessHostMsg_SyncAllocateSharedMemory
,
174 uint32
/* buffer size */,
175 base::SharedMemoryHandle
)
177 // Asks the browser to create a block of shared memory for the child process to
178 // fill in and pass back to the browser.
179 IPC_SYNC_MESSAGE_CONTROL2_1(ChildProcessHostMsg_SyncAllocateSharedBitmap
,
180 uint32
/* buffer size */,
182 base::SharedMemoryHandle
)
184 // Informs the browser that the child allocated a shared bitmap.
185 IPC_MESSAGE_CONTROL3(ChildProcessHostMsg_AllocatedSharedBitmap
,
186 uint32
/* buffer size */,
187 base::SharedMemoryHandle
,
190 // Informs the browser that the child deleted a shared bitmap.
191 IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_DeletedSharedBitmap
,
194 #if defined(USE_TCMALLOC)
195 // Reply to ChildProcessMsg_GetTcmallocStats.
196 IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_TcmallocStats
,
197 std::string
/* output */)
200 // Asks the browser to create a gpu memory buffer.
201 IPC_SYNC_MESSAGE_CONTROL5_1(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer
,
202 gfx::GpuMemoryBufferId
/* new_id */,
207 gfx::GpuMemoryBufferHandle
)
209 // Informs the browser that the child deleted a gpu memory buffer.
210 IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_DeletedGpuMemoryBuffer
,
211 gfx::GpuMemoryBufferId
,
212 uint32
/* sync_point */)
214 // Asks the browser to create a block of discardable shared memory for the
216 IPC_SYNC_MESSAGE_CONTROL2_1(
217 ChildProcessHostMsg_SyncAllocateLockedDiscardableSharedMemory
,
219 content::DiscardableSharedMemoryId
,
220 base::SharedMemoryHandle
)
222 // Informs the browser that the child deleted a block of discardable shared
224 IPC_MESSAGE_CONTROL1(ChildProcessHostMsg_DeletedDiscardableSharedMemory
,
225 content::DiscardableSharedMemoryId
)