summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/file_descriptor_posix.cc8
-rw-r--r--chrome/common/file_descriptor_posix.h9
-rw-r--r--chrome/common/ipc_message.cc1
3 files changed, 18 insertions, 0 deletions
diff --git a/chrome/common/file_descriptor_posix.cc b/chrome/common/file_descriptor_posix.cc
index b3dc4a0..7db9514 100644
--- a/chrome/common/file_descriptor_posix.cc
+++ b/chrome/common/file_descriptor_posix.cc
@@ -80,3 +80,11 @@ void DescriptorSet::SetDescriptors(const int* buffer, unsigned count) {
descriptors_.push_back(sd);
}
}
+
+void DescriptorSet::TakeFrom(DescriptorSet* other) {
+ DCHECK(descriptors_.size() == 0);
+
+ descriptors_.swap(other->descriptors_);
+ next_descriptor_ = other->next_descriptor_;
+ other->next_descriptor_ = 0;
+}
diff --git a/chrome/common/file_descriptor_posix.h b/chrome/common/file_descriptor_posix.h
index 533992e..43590b0 100644
--- a/chrome/common/file_descriptor_posix.h
+++ b/chrome/common/file_descriptor_posix.h
@@ -101,6 +101,15 @@ class DescriptorSet {
// ---------------------------------------------------------------------------
+ // ---------------------------------------------------------------------------
+ // Interfaces for IPC::Message...
+
+ // Take all the FileDescriptors from another set. Just like a copy
+ // constructor, except that the source is emptied.
+ void TakeFrom(DescriptorSet* other);
+
+ // ---------------------------------------------------------------------------
+
private:
// A vector of descriptors and close flags. If this message is sent, then
// these descriptors are sent as control data. After sending, any descriptors
diff --git a/chrome/common/ipc_message.cc b/chrome/common/ipc_message.cc
index 67dfad8..9ec3105 100644
--- a/chrome/common/ipc_message.cc
+++ b/chrome/common/ipc_message.cc
@@ -40,6 +40,7 @@ Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
Message::Message(const Message& other) : Pickle(other) {
InitLoggingVariables();
+ descriptor_set_.TakeFrom(&other.descriptor_set_);
}
void Message::InitLoggingVariables() {