| 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 #if DCHECK_IS_ON |
| 420 GetMaximumSerializedSizeImplNoLock(channel) : static_cast<size_t>(-1); | 420 size_t max_size = GetMaximumSerializedSizeImplNoLock(channel); |
| 421 #else |
| 422 size_t max_size = static_cast<size_t>(-1); |
| 423 #endif |
| 421 | 424 |
| 422 // Like other |...Close()| methods, we mark ourselves as closed before calling | 425 // Like other |...Close()| methods, we mark ourselves as closed before calling |
| 423 // the impl. | 426 // the impl. |
| 424 is_closed_ = true; | 427 is_closed_ = true; |
| 425 // No need to cancel waiters: we shouldn't have any (and shouldn't be in | 428 // No need to cancel waiters: we shouldn't have any (and shouldn't be in |
| 426 // |Core|'s handle table. | 429 // |Core|'s handle table. |
| 427 | 430 |
| 428 if (!SerializeAndCloseImplNoLock(channel, destination, actual_size)) | 431 if (!SerializeAndCloseImplNoLock(channel, destination, actual_size)) |
| 429 return false; | 432 return false; |
| 430 | 433 |
| 431 DCHECK_LE(*actual_size, max_size); | 434 DCHECK_LE(*actual_size, max_size); |
| 432 return true; | 435 return true; |
| 433 } | 436 } |
| 434 | 437 |
| 435 // DispatcherTransport --------------------------------------------------------- | 438 // DispatcherTransport --------------------------------------------------------- |
| 436 | 439 |
| 437 void DispatcherTransport::End() { | 440 void DispatcherTransport::End() { |
| 438 DCHECK(dispatcher_); | 441 DCHECK(dispatcher_); |
| 439 dispatcher_->lock_.Release(); | 442 dispatcher_->lock_.Release(); |
| 440 dispatcher_ = NULL; | 443 dispatcher_ = NULL; |
| 441 } | 444 } |
| 442 | 445 |
| 443 } // namespace system | 446 } // namespace system |
| 444 } // namespace mojo | 447 } // namespace mojo |
| OLD | NEW |