| 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/system/dispatcher.h" | 5 #include "mojo/system/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/constants.h" | 8 #include "mojo/system/constants.h" |
| 9 #include "mojo/system/message_pipe_dispatcher.h" | 9 #include "mojo/system/message_pipe_dispatcher.h" |
| 10 | 10 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 DCHECK(destination); | 409 DCHECK(destination); |
| 410 DCHECK(channel); | 410 DCHECK(channel); |
| 411 DCHECK(actual_size); | 411 DCHECK(actual_size); |
| 412 DCHECK(HasOneRef()); | 412 DCHECK(HasOneRef()); |
| 413 | 413 |
| 414 base::AutoLock locker(lock_); | 414 base::AutoLock locker(lock_); |
| 415 DCHECK(!is_closed_); | 415 DCHECK(!is_closed_); |
| 416 | 416 |
| 417 // We have to call |GetMaximumSerializedSizeImplNoLock()| first, because we | 417 // We have to call |GetMaximumSerializedSizeImplNoLock()| first, because we |
| 418 // leave it to |SerializeAndCloseImplNoLock()| to close the thing. | 418 // leave it to |SerializeAndCloseImplNoLock()| to close the thing. |
| 419 size_t max_size = DCHECK_IS_ON() ? | 419 size_t max_size = DCHECK_IS_ON ? |
| 420 GetMaximumSerializedSizeImplNoLock(channel) : static_cast<size_t>(-1); | 420 GetMaximumSerializedSizeImplNoLock(channel) : static_cast<size_t>(-1); |
| 421 | 421 |
| 422 // Like other |...Close()| methods, we mark ourselves as closed before calling | 422 // Like other |...Close()| methods, we mark ourselves as closed before calling |
| 423 // the impl. | 423 // the impl. |
| 424 is_closed_ = true; | 424 is_closed_ = true; |
| 425 // No need to cancel waiters: we shouldn't have any (and shouldn't be in | 425 // No need to cancel waiters: we shouldn't have any (and shouldn't be in |
| 426 // |Core|'s handle table. | 426 // |Core|'s handle table. |
| 427 | 427 |
| 428 if (!SerializeAndCloseImplNoLock(channel, destination, actual_size)) | 428 if (!SerializeAndCloseImplNoLock(channel, destination, actual_size)) |
| 429 return false; | 429 return false; |
| 430 | 430 |
| 431 DCHECK_LE(*actual_size, max_size); | 431 DCHECK_LE(*actual_size, max_size); |
| 432 return true; | 432 return true; |
| 433 } | 433 } |
| 434 | 434 |
| 435 // DispatcherTransport --------------------------------------------------------- | 435 // DispatcherTransport --------------------------------------------------------- |
| 436 | 436 |
| 437 void DispatcherTransport::End() { | 437 void DispatcherTransport::End() { |
| 438 DCHECK(dispatcher_); | 438 DCHECK(dispatcher_); |
| 439 dispatcher_->lock_.Release(); | 439 dispatcher_->lock_.Release(); |
| 440 dispatcher_ = NULL; | 440 dispatcher_ = NULL; |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace system | 443 } // namespace system |
| 444 } // namespace mojo | 444 } // namespace mojo |
| OLD | NEW |