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

Side by Side Diff: ipc/ipc_channel_reader.h

Issue 1377483003: Trim IPC ChannelReader's buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reserve-buffer
Patch Set: Fix USE_ATTACHMENT_BROKER && defined(OS_MACOSX) && !defined(OS_IOS) case Created 5 years, 1 month 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_channel.h ('k') | ipc/ipc_channel_reader.cc » ('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_CHANNEL_READER_H_ 5 #ifndef IPC_IPC_CHANNEL_READER_H_
6 #define IPC_IPC_CHANNEL_READER_H_ 6 #define IPC_IPC_CHANNEL_READER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 virtual base::ProcessId GetSenderPID() = 0; 122 virtual base::ProcessId GetSenderPID() = 0;
123 123
124 // Whether the channel is an endpoint of attachment brokering. 124 // Whether the channel is an endpoint of attachment brokering.
125 virtual bool IsAttachmentBrokerEndpoint() = 0; 125 virtual bool IsAttachmentBrokerEndpoint() = 0;
126 126
127 private: 127 private:
128 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentAlreadyBrokered); 128 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentAlreadyBrokered);
129 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentNotYetBrokered); 129 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentNotYetBrokered);
130 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, ResizeOverflowBuffer); 130 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, ResizeOverflowBuffer);
131 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, InvalidMessageSize); 131 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, InvalidMessageSize);
132 FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, TrimBuffer);
132 133
133 using AttachmentIdSet = std::set<BrokerableAttachment::AttachmentId>; 134 using AttachmentIdSet = std::set<BrokerableAttachment::AttachmentId>;
134 using AttachmentIdVector = std::vector<BrokerableAttachment::AttachmentId>; 135 using AttachmentIdVector = std::vector<BrokerableAttachment::AttachmentId>;
135 136
136 // Takes the data received from the IPC channel and translates it into 137 // Takes the data received from the IPC channel and translates it into
137 // Messages. Complete messages are passed to HandleTranslatedMessage(). 138 // Messages. Complete messages are passed to HandleTranslatedMessage().
138 // Returns |false| on unrecoverable error. 139 // Returns |false| on unrecoverable error.
139 bool TranslateInputData(const char* input_data, int input_data_len); 140 bool TranslateInputData(const char* input_data, int input_data_len);
140 141
141 // Internal messages and messages bound for the attachment broker are 142 // Internal messages and messages bound for the attachment broker are
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 Listener* listener_; 189 Listener* listener_;
189 190
190 // We read from the pipe into this buffer. Managed by DispatchInputData, do 191 // We read from the pipe into this buffer. Managed by DispatchInputData, do
191 // not access directly outside that function. 192 // not access directly outside that function.
192 char input_buf_[Channel::kReadBufferSize]; 193 char input_buf_[Channel::kReadBufferSize];
193 194
194 // Large messages that span multiple pipe buffers, get built-up using 195 // Large messages that span multiple pipe buffers, get built-up using
195 // this buffer. 196 // this buffer.
196 std::string input_overflow_buf_; 197 std::string input_overflow_buf_;
197 198
199 // Maximum overflow buffer size, see Channel::kMaximumReadBufferSize.
200 // This is not a constant because we update it to reflect the reality
201 // of std::string::reserve() implementation.
202 size_t max_input_buffer_size_;
203
198 // These messages are waiting to be dispatched. If this vector is non-empty, 204 // These messages are waiting to be dispatched. If this vector is non-empty,
199 // then the front Message must be blocked on receiving an attachment from the 205 // then the front Message must be blocked on receiving an attachment from the
200 // AttachmentBroker. 206 // AttachmentBroker.
201 ScopedVector<Message> queued_messages_; 207 ScopedVector<Message> queued_messages_;
202 208
203 // If the next message to be processed is blocked by the broker, then this 209 // If the next message to be processed is blocked by the broker, then this
204 // set contains the AttachmentIds that are needed to unblock the message. 210 // set contains the AttachmentIds that are needed to unblock the message.
205 AttachmentIdSet blocked_ids_; 211 AttachmentIdSet blocked_ids_;
206 212
207 DISALLOW_COPY_AND_ASSIGN(ChannelReader); 213 DISALLOW_COPY_AND_ASSIGN(ChannelReader);
208 }; 214 };
209 215
210 } // namespace internal 216 } // namespace internal
211 } // namespace IPC 217 } // namespace IPC
212 218
213 #endif // IPC_IPC_CHANNEL_READER_H_ 219 #endif // IPC_IPC_CHANNEL_READER_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel.h ('k') | ipc/ipc_channel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698