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

Side by Side Diff: ipc/ipc_channel_win.cc

Issue 11570038: Remove IPC::MessageIterator. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « content/common/indexed_db/indexed_db_message_filter.cc ('k') | ipc/ipc_message_utils.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 #include "ipc/ipc_channel_win.h" 5 #include "ipc/ipc_channel_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/pickle.h"
13 #include "base/process_util.h" 14 #include "base/process_util.h"
14 #include "base/rand_util.h" 15 #include "base/rand_util.h"
15 #include "base/string_number_conversions.h" 16 #include "base/string_number_conversions.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "base/win/scoped_handle.h" 19 #include "base/win/scoped_handle.h"
19 #include "ipc/ipc_listener.h" 20 #include "ipc/ipc_listener.h"
20 #include "ipc/ipc_logging.h" 21 #include "ipc/ipc_logging.h"
21 #include "ipc/ipc_message_utils.h" 22 #include "ipc/ipc_message_utils.h"
22 23
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 147
147 bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) { 148 bool Channel::ChannelImpl::WillDispatchInputMessage(Message* msg) {
148 // Make sure we get a hello when client validation is required. 149 // Make sure we get a hello when client validation is required.
149 if (validate_client_) 150 if (validate_client_)
150 return IsHelloMessage(*msg); 151 return IsHelloMessage(*msg);
151 return true; 152 return true;
152 } 153 }
153 154
154 void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) { 155 void Channel::ChannelImpl::HandleHelloMessage(const Message& msg) {
155 // The hello message contains one parameter containing the PID. 156 // The hello message contains one parameter containing the PID.
156 MessageIterator it = MessageIterator(msg); 157 PickleIterator it(msg);
157 int32 claimed_pid = it.NextInt(); 158 int32 claimed_pid;
158 if (validate_client_ && (it.NextInt() != client_secret_)) { 159 bool failed = !it.ReadInt(&claimed_pid);
160
161 if (!failed && validate_client_) {
162 int32 secret;
163 failed = it.ReadInt(&secret) ? (secret != client_secret_) : true;
164 }
165
166 if (failed) {
159 NOTREACHED(); 167 NOTREACHED();
160 // Something went wrong. Abort connection.
161 Close(); 168 Close();
162 listener()->OnChannelError(); 169 listener()->OnChannelError();
163 return; 170 return;
164 } 171 }
172
165 peer_pid_ = claimed_pid; 173 peer_pid_ = claimed_pid;
166 // validation completed. 174 // Validation completed.
167 validate_client_ = false; 175 validate_client_ = false;
168 listener()->OnChannelConnected(claimed_pid); 176 listener()->OnChannelConnected(claimed_pid);
169 } 177 }
170 178
171 bool Channel::ChannelImpl::DidEmptyInputBuffers() { 179 bool Channel::ChannelImpl::DidEmptyInputBuffers() {
172 // We don't need to do anything here. 180 // We don't need to do anything here.
173 return true; 181 return true;
174 } 182 }
175 183
176 // static 184 // static
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 int secret; 508 int secret;
501 do { // Guarantee we get a non-zero value. 509 do { // Guarantee we get a non-zero value.
502 secret = base::RandInt(0, std::numeric_limits<int>::max()); 510 secret = base::RandInt(0, std::numeric_limits<int>::max());
503 } while (secret == 0); 511 } while (secret == 0);
504 512
505 id.append(GenerateUniqueRandomChannelID()); 513 id.append(GenerateUniqueRandomChannelID());
506 return id.append(base::StringPrintf("\\%d", secret)); 514 return id.append(base::StringPrintf("\\%d", secret));
507 } 515 }
508 516
509 } // namespace IPC 517 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/indexed_db/indexed_db_message_filter.cc ('k') | ipc/ipc_message_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698