OLD | NEW |
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 DWORD error) { | 296 DWORD error) { |
297 DCHECK(!owner_ || | 297 DCHECK(!owner_ || |
298 base::MessageLoop::current() == owner_->message_loop_for_io()); | 298 base::MessageLoop::current() == owner_->message_loop_for_io()); |
299 DCHECK(suppress_self_destruct_); | 299 DCHECK(suppress_self_destruct_); |
300 | 300 |
301 CHECK(pending_read_); | 301 CHECK(pending_read_); |
302 pending_read_ = false; | 302 pending_read_ = false; |
303 if (!owner_) | 303 if (!owner_) |
304 return; | 304 return; |
305 | 305 |
| 306 // Note: |OnReadCompleted()| may detach us from |owner_|. |
306 if (error == ERROR_SUCCESS) { | 307 if (error == ERROR_SUCCESS) { |
307 DCHECK_GT(bytes_read, 0u); | 308 DCHECK_GT(bytes_read, 0u); |
308 owner_->OnReadCompleted(IO_SUCCEEDED, bytes_read); | 309 owner_->OnReadCompleted(IO_SUCCEEDED, bytes_read); |
309 } else if (error == ERROR_BROKEN_PIPE) { | 310 } else if (error == ERROR_BROKEN_PIPE) { |
310 DCHECK_EQ(bytes_read, 0u); | 311 DCHECK_EQ(bytes_read, 0u); |
311 owner_->OnReadCompleted(IO_FAILED_SHUTDOWN, 0); | 312 owner_->OnReadCompleted(IO_FAILED_SHUTDOWN, 0); |
312 } else { | 313 } else { |
313 DCHECK_EQ(bytes_read, 0u); | 314 DCHECK_EQ(bytes_read, 0u); |
314 LOG(WARNING) << "ReadFile: " << logging::SystemErrorCodeToString(error); | 315 LOG(WARNING) << "ReadFile: " << logging::SystemErrorCodeToString(error); |
315 owner_->OnReadCompleted(IO_FAILED_UNKNOWN, 0); | 316 owner_->OnReadCompleted(IO_FAILED_UNKNOWN, 0); |
(...skipping 12 matching lines...) Expand all Loading... |
328 pending_write_ = false; | 329 pending_write_ = false; |
329 return; | 330 return; |
330 } | 331 } |
331 | 332 |
332 { | 333 { |
333 base::AutoLock locker(owner_->write_lock()); | 334 base::AutoLock locker(owner_->write_lock()); |
334 CHECK(pending_write_); | 335 CHECK(pending_write_); |
335 pending_write_ = false; | 336 pending_write_ = false; |
336 } | 337 } |
337 | 338 |
| 339 // Note: |OnWriteCompleted()| may detach us from |owner_|. |
338 if (error == ERROR_SUCCESS) { | 340 if (error == ERROR_SUCCESS) { |
339 owner_->OnWriteCompleted(IO_SUCCEEDED, 0, bytes_written); | 341 owner_->OnWriteCompleted(IO_SUCCEEDED, 0, bytes_written); |
340 } else if (error == ERROR_BROKEN_PIPE) { | 342 } else if (error == ERROR_BROKEN_PIPE) { |
341 owner_->OnWriteCompleted(IO_FAILED_SHUTDOWN, 0, 0); | 343 owner_->OnWriteCompleted(IO_FAILED_SHUTDOWN, 0, 0); |
342 } else { | 344 } else { |
343 LOG(WARNING) << "WriteFile: " << logging::SystemErrorCodeToString(error); | 345 LOG(WARNING) << "WriteFile: " << logging::SystemErrorCodeToString(error); |
344 owner_->OnWriteCompleted(IO_FAILED_UNKNOWN, 0, 0); | 346 owner_->OnWriteCompleted(IO_FAILED_UNKNOWN, 0, 0); |
345 } | 347 } |
346 } | 348 } |
347 | 349 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 569 |
568 // Static factory method declared in raw_channel.h. | 570 // Static factory method declared in raw_channel.h. |
569 // static | 571 // static |
570 scoped_ptr<RawChannel> RawChannel::Create( | 572 scoped_ptr<RawChannel> RawChannel::Create( |
571 embedder::ScopedPlatformHandle handle) { | 573 embedder::ScopedPlatformHandle handle) { |
572 return make_scoped_ptr(new RawChannelWin(handle.Pass())); | 574 return make_scoped_ptr(new RawChannelWin(handle.Pass())); |
573 } | 575 } |
574 | 576 |
575 } // namespace system | 577 } // namespace system |
576 } // namespace mojo | 578 } // namespace mojo |
OLD | NEW |