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

Side by Side Diff: ipc/ipc_sync_message.h

Issue 1149113006: Move Pickle to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « ipc/ipc_message_utils_impl.h ('k') | ipc/mojo/ipc_mojo_message_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SYNC_MESSAGE_H_ 5 #ifndef IPC_IPC_SYNC_MESSAGE_H_
6 #define IPC_IPC_SYNC_MESSAGE_H_ 6 #define IPC_IPC_SYNC_MESSAGE_H_
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 base::WaitableEvent* pump_messages_event() const { 54 base::WaitableEvent* pump_messages_event() const {
55 return pump_messages_event_; 55 return pump_messages_event_;
56 } 56 }
57 57
58 // Returns true if the message is a reply to the given request id. 58 // Returns true if the message is a reply to the given request id.
59 static bool IsMessageReplyTo(const Message& msg, int request_id); 59 static bool IsMessageReplyTo(const Message& msg, int request_id);
60 60
61 // Given a reply message, returns an iterator to the beginning of the data 61 // Given a reply message, returns an iterator to the beginning of the data
62 // (i.e. skips over the synchronous specific data). 62 // (i.e. skips over the synchronous specific data).
63 static PickleIterator GetDataIterator(const Message* msg); 63 static base::PickleIterator GetDataIterator(const Message* msg);
64 64
65 // Given a synchronous message (or its reply), returns its id. 65 // Given a synchronous message (or its reply), returns its id.
66 static int GetMessageId(const Message& msg); 66 static int GetMessageId(const Message& msg);
67 67
68 // Generates a reply message to the given message. 68 // Generates a reply message to the given message.
69 static Message* GenerateReply(const Message* msg); 69 static Message* GenerateReply(const Message* msg);
70 70
71 private: 71 private:
72 struct SyncHeader { 72 struct SyncHeader {
73 // unique ID (unique per sender) 73 // unique ID (unique per sender)
74 int message_id; 74 int message_id;
75 }; 75 };
76 76
77 static bool ReadSyncHeader(const Message& msg, SyncHeader* header); 77 static bool ReadSyncHeader(const Message& msg, SyncHeader* header);
78 static bool WriteSyncHeader(Message* msg, const SyncHeader& header); 78 static bool WriteSyncHeader(Message* msg, const SyncHeader& header);
79 79
80 scoped_ptr<MessageReplyDeserializer> deserializer_; 80 scoped_ptr<MessageReplyDeserializer> deserializer_;
81 base::WaitableEvent* pump_messages_event_; 81 base::WaitableEvent* pump_messages_event_;
82 }; 82 };
83 83
84 // Used to deserialize parameters from a reply to a synchronous message 84 // Used to deserialize parameters from a reply to a synchronous message
85 class IPC_EXPORT MessageReplyDeserializer { 85 class IPC_EXPORT MessageReplyDeserializer {
86 public: 86 public:
87 virtual ~MessageReplyDeserializer() {} 87 virtual ~MessageReplyDeserializer() {}
88 bool SerializeOutputParameters(const Message& msg); 88 bool SerializeOutputParameters(const Message& msg);
89 private: 89 private:
90 // Derived classes need to implement this, using the given iterator (which 90 // Derived classes need to implement this, using the given iterator (which
91 // is skipped past the header for synchronous messages). 91 // is skipped past the header for synchronous messages).
92 virtual bool SerializeOutputParameters(const Message& msg, 92 virtual bool SerializeOutputParameters(const Message& msg,
93 PickleIterator iter) = 0; 93 base::PickleIterator iter) = 0;
94 }; 94 };
95 95
96 // When sending a synchronous message, this structure contains an object 96 // When sending a synchronous message, this structure contains an object
97 // that knows how to deserialize the response. 97 // that knows how to deserialize the response.
98 struct PendingSyncMsg { 98 struct PendingSyncMsg {
99 PendingSyncMsg(int id, 99 PendingSyncMsg(int id,
100 MessageReplyDeserializer* d, 100 MessageReplyDeserializer* d,
101 base::WaitableEvent* e) 101 base::WaitableEvent* e)
102 : id(id), deserializer(d), done_event(e), send_result(false) { } 102 : id(id), deserializer(d), done_event(e), send_result(false) { }
103 int id; 103 int id;
104 MessageReplyDeserializer* deserializer; 104 MessageReplyDeserializer* deserializer;
105 base::WaitableEvent* done_event; 105 base::WaitableEvent* done_event;
106 bool send_result; 106 bool send_result;
107 }; 107 };
108 108
109 } // namespace IPC 109 } // namespace IPC
110 110
111 #endif // IPC_IPC_SYNC_MESSAGE_H_ 111 #endif // IPC_IPC_SYNC_MESSAGE_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils_impl.h ('k') | ipc/mojo/ipc_mojo_message_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698