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

Side by Side Diff: mojo/edk/system/raw_channel_win.cc

Issue 852113002: Remove RawChannel::Init() and Channel::Init() failure cases. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/edk/system/raw_channel.h" 5 #include "mojo/edk/system/raw_channel.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"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 // |RawChannel| private methods: 162 // |RawChannel| private methods:
163 IOResult Read(size_t* bytes_read) override; 163 IOResult Read(size_t* bytes_read) override;
164 IOResult ScheduleRead() override; 164 IOResult ScheduleRead() override;
165 embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( 165 embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
166 size_t num_platform_handles, 166 size_t num_platform_handles,
167 const void* platform_handle_table) override; 167 const void* platform_handle_table) override;
168 IOResult WriteNoLock(size_t* platform_handles_written, 168 IOResult WriteNoLock(size_t* platform_handles_written,
169 size_t* bytes_written) override; 169 size_t* bytes_written) override;
170 IOResult ScheduleWriteNoLock() override; 170 IOResult ScheduleWriteNoLock() override;
171 bool OnInit() override; 171 void OnInit() override;
172 void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, 172 void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
173 scoped_ptr<WriteBuffer> write_buffer) override; 173 scoped_ptr<WriteBuffer> write_buffer) override;
174 174
175 // Passed to |io_handler_| during initialization. 175 // Passed to |io_handler_| during initialization.
176 embedder::ScopedPlatformHandle handle_; 176 embedder::ScopedPlatformHandle handle_;
177 177
178 RawChannelIOHandler* io_handler_; 178 RawChannelIOHandler* io_handler_;
179 179
180 const bool skip_completion_port_on_success_; 180 const bool skip_completion_port_on_success_;
181 181
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 base::Bind(&RawChannelIOHandler::OnIOCompleted, 514 base::Bind(&RawChannelIOHandler::OnIOCompleted,
515 base::Unretained(io_handler_), 515 base::Unretained(io_handler_),
516 base::Unretained(io_handler_->write_context_no_lock()), 516 base::Unretained(io_handler_->write_context_no_lock()),
517 static_cast<DWORD>(bytes_written), ERROR_SUCCESS)); 517 static_cast<DWORD>(bytes_written), ERROR_SUCCESS));
518 return IO_PENDING; 518 return IO_PENDING;
519 } 519 }
520 520
521 return io_result; 521 return io_result;
522 } 522 }
523 523
524 bool RawChannelWin::OnInit() { 524 void RawChannelWin::OnInit() {
525 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io()); 525 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
526 526
527 DCHECK(handle_.is_valid()); 527 DCHECK(handle_.is_valid());
528 if (skip_completion_port_on_success_ && 528 if (skip_completion_port_on_success_) {
529 !g_vista_or_higher_functions.Get().SetFileCompletionNotificationModes( 529 // I don't know how this can fail (unless |handle_| is bad, in which case
530 handle_.get().handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) { 530 // it's a bug in our code).
531 return false; 531 CHECK(g_vista_or_higher_functions.Get().SetFileCompletionNotificationModes(
532 handle_.get().handle, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS));
532 } 533 }
533 534
534 DCHECK(!io_handler_); 535 DCHECK(!io_handler_);
535 io_handler_ = new RawChannelIOHandler(this, handle_.Pass()); 536 io_handler_ = new RawChannelIOHandler(this, handle_.Pass());
536
537 return true;
538 } 537 }
539 538
540 void RawChannelWin::OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, 539 void RawChannelWin::OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer,
541 scoped_ptr<WriteBuffer> write_buffer) { 540 scoped_ptr<WriteBuffer> write_buffer) {
542 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io()); 541 DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
543 DCHECK(io_handler_); 542 DCHECK(io_handler_);
544 543
545 write_lock().AssertAcquired(); 544 write_lock().AssertAcquired();
546 545
547 if (io_handler_->pending_read() || io_handler_->pending_write_no_lock()) { 546 if (io_handler_->pending_read() || io_handler_->pending_write_no_lock()) {
(...skipping 20 matching lines...) Expand all
568 567
569 // Static factory method declared in raw_channel.h. 568 // Static factory method declared in raw_channel.h.
570 // static 569 // static
571 scoped_ptr<RawChannel> RawChannel::Create( 570 scoped_ptr<RawChannel> RawChannel::Create(
572 embedder::ScopedPlatformHandle handle) { 571 embedder::ScopedPlatformHandle handle) {
573 return make_scoped_ptr(new RawChannelWin(handle.Pass())); 572 return make_scoped_ptr(new RawChannelWin(handle.Pass()));
574 } 573 }
575 574
576 } // namespace system 575 } // namespace system
577 } // namespace mojo 576 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/raw_channel_unittest.cc ('k') | mojo/edk/system/remote_message_pipe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698