Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1046)

Side by Side Diff: ipc/ipc_message.h

Issue 1345353004: Resize IPC input buffer to fit the next message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests and address comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 IPC_IPC_MESSAGE_H_ 5 #ifndef IPC_IPC_MESSAGE_H_
6 #define IPC_IPC_MESSAGE_H_ 6 #define IPC_IPC_MESSAGE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/pickle.h" 14 #include "base/pickle.h"
14 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
15 #include "ipc/brokerable_attachment.h" 16 #include "ipc/brokerable_attachment.h"
16 #include "ipc/ipc_export.h" 17 #include "ipc/ipc_export.h"
17 18
18 #if !defined(NDEBUG) 19 #if !defined(NDEBUG)
19 #define IPC_MESSAGE_LOG_ENABLED 20 #define IPC_MESSAGE_LOG_ENABLED
20 #endif 21 #endif
21 22
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 (obj->*func)(parameter); 162 (obj->*func)(parameter);
162 return true; 163 return true;
163 } 164 }
164 165
165 // Used for async messages with no parameters. 166 // Used for async messages with no parameters.
166 static void Log(std::string* name, const Message* msg, std::string* l) { 167 static void Log(std::string* name, const Message* msg, std::string* l) {
167 } 168 }
168 169
169 // The static method FindNext() returns several pieces of information, which 170 // The static method FindNext() returns several pieces of information, which
170 // are aggregated into an instance of this struct. 171 // are aggregated into an instance of this struct.
171 struct NextMessageInfo { 172 struct IPC_EXPORT NextMessageInfo {
172 NextMessageInfo(); 173 NextMessageInfo();
173 ~NextMessageInfo(); 174 ~NextMessageInfo();
174 175
176 // Total message size. Always valid if |message_found| is true.
177 // If |message_found| is false but we could determine message size
178 // from the header, this field is non-zero. Otherwise it's zero.
179 size_t message_size;
175 // Whether an entire message was found in the given memory range. 180 // Whether an entire message was found in the given memory range.
176 bool message_found; 181 bool message_found;
177 // Only filled in if |message_found| is true. 182 // Only filled in if |message_found| is true.
178 // The start address is passed into FindNext() by the caller, so isn't 183 // The start address is passed into FindNext() by the caller, so isn't
179 // repeated in this struct. The end address of the pickle should be used to 184 // repeated in this struct. The end address of the pickle should be used to
180 // construct a base::Pickle. 185 // construct a base::Pickle.
181 const char* pickle_end; 186 const char* pickle_end;
182 // Only filled in if |message_found| is true. 187 // Only filled in if |message_found| is true.
183 // The end address of the message should be used to determine the start 188 // The end address of the message should be used to determine the start
184 // address of the next message. 189 // address of the next message.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // a valid value for every message dispatched to listeners. 305 // a valid value for every message dispatched to listeners.
301 base::ProcessId sender_pid_; 306 base::ProcessId sender_pid_;
302 307
303 #ifdef IPC_MESSAGE_LOG_ENABLED 308 #ifdef IPC_MESSAGE_LOG_ENABLED
304 // Used for logging. 309 // Used for logging.
305 mutable int64_t received_time_; 310 mutable int64_t received_time_;
306 mutable std::string output_params_; 311 mutable std::string output_params_;
307 mutable LogData* log_data_; 312 mutable LogData* log_data_;
308 mutable bool dont_log_; 313 mutable bool dont_log_;
309 #endif 314 #endif
315
316 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNext);
317 FRIEND_TEST_ALL_PREFIXES(IPCMessageTest, FindNextOverflow);
310 }; 318 };
311 319
312 //------------------------------------------------------------------------------ 320 //------------------------------------------------------------------------------
313 321
314 } // namespace IPC 322 } // namespace IPC
315 323
316 enum SpecialRoutingIDs { 324 enum SpecialRoutingIDs {
317 // indicates that we don't have a routing ID yet. 325 // indicates that we don't have a routing ID yet.
318 MSG_ROUTING_NONE = -2, 326 MSG_ROUTING_NONE = -2,
319 327
320 // indicates a general message not sent to a particular tab. 328 // indicates a general message not sent to a particular tab.
321 MSG_ROUTING_CONTROL = INT32_MAX, 329 MSG_ROUTING_CONTROL = INT32_MAX,
322 }; 330 };
323 331
324 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies 332 #define IPC_REPLY_ID 0xFFFFFFF0 // Special message id for replies
325 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging 333 #define IPC_LOGGING_ID 0xFFFFFFF1 // Special message id for logging
326 334
327 #endif // IPC_IPC_MESSAGE_H_ 335 #endif // IPC_IPC_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698