2 * Copyright (C) 2010, 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
32 MessageClassInvalid = 0,
34 // Messages sent by Core IPC.
37 // Messages sent by the UI process to the web process.
38 MessageClassAuthenticationManager,
39 MessageClassDrawingArea,
40 MessageClassLayerTreeCoordinator,
41 MessageClassWebApplicationCacheManager,
42 MessageClassWebBatteryManagerProxy,
43 MessageClassWebCookieManager,
44 MessageClassWebDatabaseManager,
45 MessageClassWebFullScreenManager,
46 MessageClassWebGeolocationManagerProxy,
47 MessageClassWebIconDatabaseProxy,
48 MessageClassWebInspector,
49 MessageClassWebKeyValueStorageManager,
50 MessageClassWebMediaCacheManager,
51 MessageClassWebNetworkInfoManagerProxy,
52 MessageClassWebNotificationManager,
54 MessageClassWebPageGroupProxy,
55 MessageClassWebProcess,
56 MessageClassWebResourceCacheManager,
57 MessageClassEventDispatcher,
59 MessageClassWebSoupRequestManager,
62 // Messages sent by the web process to the UI process.
63 MessageClassDownloadProxy,
64 MessageClassDrawingAreaProxy,
65 MessageClassLayerTreeCoordinatorProxy,
66 MessageClassWebApplicationCacheManagerProxy,
67 MessageClassWebBatteryManager,
68 MessageClassWebConnection,
69 MessageClassWebContext,
70 MessageClassWebContextLegacy,
71 MessageClassWebCookieManagerProxy,
72 MessageClassWebDatabaseManagerProxy,
73 MessageClassWebFullScreenManagerProxy,
74 MessageClassWebGeolocationManager,
75 MessageClassWebIconDatabase,
76 MessageClassWebInspectorProxy,
77 MessageClassWebKeyValueStorageManagerProxy,
78 MessageClassWebMediaCacheManagerProxy,
79 MessageClassWebNetworkInfoManager,
80 MessageClassWebNotificationManagerProxy,
81 MessageClassWebPageProxy,
82 MessageClassWebProcessProxy,
83 MessageClassWebResourceCacheManagerProxy,
85 MessageClassWebSoupRequestManagerProxy,
87 MessageClassWebVibrationProxy,
88 MessageClassRemoteLayerTreeHost,
90 // Messages sent to a WebConnection
91 MessageClassWebConnectionLegacy,
93 // Messages sent by the UI process to the plug-in process.
94 MessageClassPluginProcess,
96 // Messages sent by the plug-in process to the UI process.
97 MessageClassPluginProcessProxy,
99 // Messages sent by the web process to the plug-in process.
100 MessageClassWebProcessConnection,
101 MessageClassPluginControllerProxy,
103 // Messages sent by the plug-in process to the web process.
104 MessageClassPluginProcessConnection,
105 MessageClassPluginProxy,
107 // NPObject messages sent by both the plug-in process and the web process.
108 MessageClassNPObjectMessageReceiver,
110 // Messages sent by the UI process to the network process.
111 MessageClassNetworkProcess,
113 // Messages sent by the network process to the UI process.
114 MessageClassNetworkProcessProxy,
116 // Messages sent by the web process to the network process.
117 MessageClassNetworkConnectionToWebProcess,
119 // Messages sent by the network process to a web process.
120 MessageClassNetworkProcessConnection,
121 MessageClassWebResourceLoader,
123 #if ENABLE(SHARED_WORKER_PROCESS)
124 // Messages sent by the UI process to the shared worker process.
125 MessageClassSharedWorkerProcess,
126 #endif // ENABLE(SHARED_WORKER_PROCESS)
128 // Messages sent by the shared worker process to the UI process.
129 MessageClassSharedWorkerProcessProxy,
131 #if ENABLE(CUSTOM_PROTOCOLS)
132 // Messages sent by the UI process to a web process (soon the network process).
133 MessageClassCustomProtocolManager,
135 // Messages sent by a web process (soon the network process) to the UI process.
136 MessageClassCustomProtocolManagerProxy,
140 template<typename> struct MessageKindTraits { };
144 MessageID Layout (the most significant bit is reserved and therefore always zero)
159 SyncMessage = 1 << 0,
160 DispatchMessageWhenWaitingForSyncReply = 1 << 1,
168 template <typename EnumType>
169 explicit MessageID(EnumType messageKind, unsigned char flags = 0)
170 : m_messageID(stripMostSignificantBit(flags << 24 | (MessageKindTraits<EnumType>::messageClass) << 16 | messageKind))
174 MessageID messageIDWithAddedFlags(unsigned char flags)
178 messageID.m_messageID = stripMostSignificantBit(m_messageID | (flags << 24));
182 template <typename EnumType>
185 ASSERT(getClass() == MessageKindTraits<EnumType>::messageClass);
186 return static_cast<EnumType>(m_messageID & 0xffff);
189 template <MessageClass K>
192 return getClass() == K;
195 template <typename EnumType>
196 bool operator==(EnumType messageKind) const
198 return m_messageID == MessageID(messageKind).m_messageID;
201 static MessageID fromInt(unsigned i)
204 messageID.m_messageID = stripMostSignificantBit(i);
209 unsigned toInt() const { return m_messageID; }
211 bool shouldDispatchMessageWhenWaitingForSyncReply() const { return getFlags() & DispatchMessageWhenWaitingForSyncReply; }
212 bool isSync() const { return getFlags() & SyncMessage; }
214 MessageClass messageClass() const
216 return static_cast<MessageClass>(getClass());
220 static inline unsigned stripMostSignificantBit(unsigned value)
222 return value & 0x7fffffff;
225 unsigned char getFlags() const { return (m_messageID & 0xff000000) >> 24; }
226 unsigned char getClass() const { return (m_messageID & 0x00ff0000) >> 16; }
228 unsigned m_messageID;
231 } // namespace CoreIPC
233 #endif // MessageID_h