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

Side by Side Diff: ipc/ipc_channel_win.cc

Issue 5598010: Convert over to channel handles (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed up bad whitespace Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <sddl.h> 8 #include <sddl.h>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 context.handler = channel; 90 context.handler = channel;
91 } 91 }
92 92
93 Channel::ChannelImpl::State::~State() { 93 Channel::ChannelImpl::State::~State() {
94 COMPILE_ASSERT(!offsetof(Channel::ChannelImpl::State, context), 94 COMPILE_ASSERT(!offsetof(Channel::ChannelImpl::State, context),
95 starts_with_io_context); 95 starts_with_io_context);
96 } 96 }
97 97
98 //------------------------------------------------------------------------------ 98 //------------------------------------------------------------------------------
99 99
100 Channel::ChannelImpl::ChannelImpl(const std::string& channel_id, Mode mode, 100 Channel::ChannelImpl::ChannelImpl(const IPC::ChannelHandle &channel_handle,
101 Listener* listener) 101 Mode mode, Listener* listener)
102 : ALLOW_THIS_IN_INITIALIZER_LIST(input_state_(this)), 102 : ALLOW_THIS_IN_INITIALIZER_LIST(input_state_(this)),
103 ALLOW_THIS_IN_INITIALIZER_LIST(output_state_(this)), 103 ALLOW_THIS_IN_INITIALIZER_LIST(output_state_(this)),
104 pipe_(INVALID_HANDLE_VALUE), 104 pipe_(INVALID_HANDLE_VALUE),
105 listener_(listener), 105 listener_(listener),
106 waiting_connect_(mode == MODE_SERVER), 106 waiting_connect_(mode == MODE_SERVER),
107 processing_incoming_(false), 107 processing_incoming_(false),
108 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) { 108 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
109 if (!CreatePipe(channel_id, mode)) { 109 if (!CreatePipe(channel_handle, mode)) {
110 // The pipe may have been closed already. 110 // The pipe may have been closed already.
111 LOG(WARNING) << "Unable to create pipe named \"" << channel_id << 111 LOG(WARNING) << "Unable to create pipe named \"" << channel_handle.name <<
112 "\" in " << (mode == 0 ? "server" : "client") << " mode."; 112 "\" in " << (mode == 0 ? "server" : "client") << " mode.";
113 } 113 }
114 } 114 }
115 115
116 Channel::ChannelImpl::~ChannelImpl() { 116 Channel::ChannelImpl::~ChannelImpl() {
117 Close(); 117 Close();
118 } 118 }
119 119
120 void Channel::ChannelImpl::Close() { 120 void Channel::ChannelImpl::Close() {
121 if (thread_check_.get()) { 121 if (thread_check_.get()) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 const std::wstring Channel::ChannelImpl::PipeName( 170 const std::wstring Channel::ChannelImpl::PipeName(
171 const std::string& channel_id) const { 171 const std::string& channel_id) const {
172 std::wostringstream ss; 172 std::wostringstream ss;
173 // XXX(darin): get application name from somewhere else 173 // XXX(darin): get application name from somewhere else
174 ss << L"\\\\.\\pipe\\chrome." << ASCIIToWide(channel_id); 174 ss << L"\\\\.\\pipe\\chrome." << ASCIIToWide(channel_id);
175 return ss.str(); 175 return ss.str();
176 } 176 }
177 177
178 bool Channel::ChannelImpl::CreatePipe(const std::string& channel_id, 178 bool Channel::ChannelImpl::CreatePipe(const IPC::ChannelHandle &channel_handle,
179 Mode mode) { 179 Mode mode) {
180 DCHECK(pipe_ == INVALID_HANDLE_VALUE); 180 DCHECK(pipe_ == INVALID_HANDLE_VALUE);
181 const std::wstring pipe_name = PipeName(channel_id); 181 const std::wstring pipe_name = PipeName(channel_handle.name);
182 if (mode == MODE_SERVER) { 182 if (mode == MODE_SERVER) {
183 SECURITY_ATTRIBUTES security_attributes = {0}; 183 SECURITY_ATTRIBUTES security_attributes = {0};
184 security_attributes.bInheritHandle = FALSE; 184 security_attributes.bInheritHandle = FALSE;
185 security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); 185 security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
186 if (!GetLogonSessionOnlyDACL( 186 if (!GetLogonSessionOnlyDACL(
187 reinterpret_cast<SECURITY_DESCRIPTOR**>( 187 reinterpret_cast<SECURITY_DESCRIPTOR**>(
188 &security_attributes.lpSecurityDescriptor))) { 188 &security_attributes.lpSecurityDescriptor))) {
189 NOTREACHED(); 189 NOTREACHED();
190 } 190 }
191 191
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 if (!ok && INVALID_HANDLE_VALUE != pipe_) { 463 if (!ok && INVALID_HANDLE_VALUE != pipe_) {
464 // We don't want to re-enter Close(). 464 // We don't want to re-enter Close().
465 Close(); 465 Close();
466 listener_->OnChannelError(); 466 listener_->OnChannelError();
467 } 467 }
468 } 468 }
469 469
470 //------------------------------------------------------------------------------ 470 //------------------------------------------------------------------------------
471 // Channel's methods simply call through to ChannelImpl. 471 // Channel's methods simply call through to ChannelImpl.
472 Channel::Channel(const std::string& channel_id, Mode mode, 472 Channel::Channel(const IPC::ChannelHandle &channel_handle, Mode mode,
473 Listener* listener) 473 Listener* listener)
474 : channel_impl_(new ChannelImpl(channel_id, mode, listener)) { 474 : channel_impl_(new ChannelImpl(channel_handle, mode, listener)) {
475 } 475 }
476 476
477 Channel::~Channel() { 477 Channel::~Channel() {
478 delete channel_impl_; 478 delete channel_impl_;
479 } 479 }
480 480
481 bool Channel::Connect() { 481 bool Channel::Connect() {
482 return channel_impl_->Connect(); 482 return channel_impl_->Connect();
483 } 483 }
484 484
485 void Channel::Close() { 485 void Channel::Close() {
486 channel_impl_->Close(); 486 channel_impl_->Close();
487 } 487 }
488 488
489 void Channel::set_listener(Listener* listener) { 489 void Channel::set_listener(Listener* listener) {
490 channel_impl_->set_listener(listener); 490 channel_impl_->set_listener(listener);
491 } 491 }
492 492
493 bool Channel::Send(Message* message) { 493 bool Channel::Send(Message* message) {
494 return channel_impl_->Send(message); 494 return channel_impl_->Send(message);
495 } 495 }
496 496
497 } // namespace IPC 497 } // namespace IPC
OLDNEW
« ipc/ipc_channel_proxy.cc ('K') | « ipc/ipc_channel_win.h ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698