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

Unified Diff: mojo/system/message_in_transit.cc

Issue 226203003: Mojo: Add the ability to attach PlatformHandles to MessageInTransits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/message_in_transit.h ('k') | mojo/system/raw_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/message_in_transit.cc
diff --git a/mojo/system/message_in_transit.cc b/mojo/system/message_in_transit.cc
index c56f4f3bcfaaf125c0df041f489d8d602c9ddc9d..6e2047ffa60a06d16e65b3dd02ecd6c24e04cd71 100644
--- a/mojo/system/message_in_transit.cc
+++ b/mojo/system/message_in_transit.cc
@@ -148,14 +148,8 @@ MessageInTransit::MessageInTransit(const View& message_view)
MessageInTransit::~MessageInTransit() {
base::AlignedFree(main_buffer_);
base::AlignedFree(secondary_buffer_); // Okay if null.
-#ifndef NDEBUG
- main_buffer_size_ = 0;
- main_buffer_ = NULL;
- secondary_buffer_size_ = 0;
- secondary_buffer_ = NULL;
-#endif
- if (dispatchers_.get()) {
+ if (dispatchers_) {
for (size_t i = 0; i < dispatchers_->size(); i++) {
if (!(*dispatchers_)[i])
continue;
@@ -163,8 +157,21 @@ MessageInTransit::~MessageInTransit() {
DCHECK((*dispatchers_)[i]->HasOneRef());
(*dispatchers_)[i]->Close();
}
- dispatchers_.reset();
}
+
+ if (platform_handles_) {
+ for (size_t i = 0; i < platform_handles_->size(); i++)
+ (*platform_handles_)[i].CloseIfNecessary();
+ }
+
+#ifndef NDEBUG
+ main_buffer_size_ = 0;
+ main_buffer_ = NULL;
+ secondary_buffer_size_ = 0;
+ secondary_buffer_ = NULL;
+ dispatchers_.reset();
+ platform_handles_.reset();
+#endif
}
// static
@@ -189,8 +196,8 @@ bool MessageInTransit::GetNextMessageSize(const void* buffer,
void MessageInTransit::SetDispatchers(
scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers) {
- DCHECK(dispatchers.get());
- DCHECK(!dispatchers_.get());
+ DCHECK(dispatchers);
+ DCHECK(!dispatchers_);
dispatchers_ = dispatchers.Pass();
#ifndef NDEBUG
@@ -203,7 +210,7 @@ void MessageInTransit::SerializeAndCloseDispatchers(Channel* channel) {
DCHECK(channel);
DCHECK(!secondary_buffer_);
CHECK_EQ(num_handles(),
- dispatchers_.get() ? dispatchers_->size() : static_cast<size_t>(0));
+ dispatchers_ ? dispatchers_->size() : static_cast<size_t>(0));
if (!num_handles())
return;
@@ -263,7 +270,7 @@ void MessageInTransit::SerializeAndCloseDispatchers(Channel* channel) {
}
void MessageInTransit::DeserializeDispatchers(Channel* channel) {
- DCHECK(!dispatchers_.get());
+ DCHECK(!dispatchers_);
// This should have been checked by calling |IsValid()| on the |View| first.
DCHECK_LE(num_handles(), kMaxMessageNumHandles);
« no previous file with comments | « mojo/system/message_in_transit.h ('k') | mojo/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698