summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 18:32:45 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 18:32:45 +0000
commitd0c0b1d9fa189387ec37d251fd6c5f05fad0f0fe (patch)
tree4120702c3383e5c6603886588bf85902bd41d1d9 /chrome
parent416478170d0dd41b071fdf4df1438786c581c03f (diff)
downloadchromium_src-d0c0b1d9fa189387ec37d251fd6c5f05fad0f0fe.zip
chromium_src-d0c0b1d9fa189387ec37d251fd6c5f05fad0f0fe.tar.gz
chromium_src-d0c0b1d9fa189387ec37d251fd6c5f05fad0f0fe.tar.bz2
POSIX: Rename DescriptorSet to FileDescriptorSet
This is just following up on a code review promise. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj8
-rw-r--r--chrome/common/common.scons2
-rw-r--r--chrome/common/descriptor_set_posix.cc118
-rw-r--r--chrome/common/descriptor_set_posix.h108
-rw-r--r--chrome/common/file_descriptor_set_posix.cc20
-rw-r--r--chrome/common/file_descriptor_set_posix.h18
-rw-r--r--chrome/common/ipc_channel_posix.cc19
-rw-r--r--chrome/common/ipc_channel_posix.h4
-rw-r--r--chrome/common/ipc_message.cc24
-rw-r--r--chrome/common/ipc_message.h18
-rw-r--r--chrome/common/ipc_message_utils.h2
-rw-r--r--chrome/common/ipc_tests.cc3
12 files changed, 58 insertions, 286 deletions
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index 81d9157..18a692c 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -280,7 +280,6 @@
844EA08D0F3E0C5000B0EF26 /* debugger_node.cc in Sources */ = {isa = PBXBuildFile; fileRef = 844EA07A0F3E0C1000B0EF26 /* debugger_node.cc */; };
844EA08E0F3E0C5900B0EF26 /* debugger_wrapper.cc in Sources */ = {isa = PBXBuildFile; fileRef = 844EA0820F3E0C1000B0EF26 /* debugger_wrapper.cc */; };
8570EB3F140C07ABF1957F12 /* url_pattern_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = A9C335E39D39A7DE087850FC /* url_pattern_unittest.cc */; };
- 884BD6B5D58856CAC05DE5C0 /* descriptor_set_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = FE95CE48F3AD7531827F63CF /* descriptor_set_posix.cc */; };
8F51B73AAAF1772ECF9BD180 /* url_fetcher.cc in Sources */ = {isa = PBXBuildFile; fileRef = 778D7927798B7E3FAA498D3D /* url_fetcher.cc */; };
94542322A5E5A8F4FDDAB7F0 /* render_view_host_manager.cc in Sources */ = {isa = PBXBuildFile; fileRef = A76E42AD0F28EDB5009A7E88 /* render_view_host_manager.cc */; };
9E85B39CA40439D93CE52E60 /* fav_icon_helper.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF8760E9D4839009A6919 /* fav_icon_helper.cc */; };
@@ -556,6 +555,7 @@
E4F3258C0EE83767002533CE /* libgoogleurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFF6E0E9D540F009A6919 /* libgoogleurl.a */; };
E4F325C80EE83A45002533CE /* ipc_fuzzing_tests.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBAD0E9D4C9F009A6919 /* ipc_fuzzing_tests.cc */; };
E4F325D10EE83B71002533CE /* ipc_tests.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBBE0E9D4C9F009A6919 /* ipc_tests.cc */; };
+ E54EDFC97B4932925C31CB41 /* file_descriptor_set_posix.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4590B61B84978823B2BADA68 /* file_descriptor_set_posix.cc */; };
E765478D55A73228BAD044E3 /* cert_store.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF8570E9D4839009A6919 /* cert_store.cc */; };
F775995035B63E51251B0922 /* ssl_error_info.cc in Sources */ = {isa = PBXBuildFile; fileRef = 26D97CE692D919FEB1521E43 /* ssl_error_info.cc */; };
/* End PBXBuildFile section */
@@ -1814,6 +1814,7 @@
3CCF8AA8A56FF8FE59F0C299 /* template_url.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url.cc; sourceTree = "<group>"; };
3D00CDB6C665E7ED1A1090D7 /* bookmark_model.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_model.cc; path = browser/bookmarks/bookmark_model.cc; sourceTree = SOURCE_ROOT; };
433B6EFB7A1D931A13C9556F /* url_fetcher_protect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = url_fetcher_protect.h; sourceTree = "<group>"; };
+ 4590B61B84978823B2BADA68 /* file_descriptor_set_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = file_descriptor_set_posix.cc; sourceTree = "<group>"; };
4D1F59EA0F2A6B590040C1E3 /* image_diff */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = image_diff; sourceTree = BUILT_PRODUCTS_DIR; };
4D1F59FD0F2A6BBB0040C1E3 /* image_diff.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = image_diff.cc; sourceTree = "<group>"; };
4D1F5AB10F2A6EE90040C1E3 /* libpng.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libpng.xcodeproj; path = third_party/libpng/libpng.xcodeproj; sourceTree = "<group>"; };
@@ -2725,7 +2726,6 @@
E4F324790EE5D17E002533CE /* referrer.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = referrer.cc; sourceTree = "<group>"; };
EA72C084DB3FC0FC595E525E /* template_url_model.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url_model.cc; sourceTree = "<group>"; };
EA72CF50C0AB4492A644C703 /* url_fetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = url_fetcher.h; sourceTree = "<group>"; };
- FE95CE48F3AD7531827F63CF /* descriptor_set_posix.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = descriptor_set_posix.cc; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -3616,11 +3616,11 @@
4D7BFBA00E9D4C9F009A6919 /* common_resources.h */,
4D7BFBA10E9D4C9F009A6919 /* debug_flags.cc */,
4D7BFBA20E9D4C9F009A6919 /* debug_flags.h */,
- FE95CE48F3AD7531827F63CF /* descriptor_set_posix.cc */,
4D7BFBA30E9D4C9F009A6919 /* drag_drop_types.cc */,
4D7BFBA40E9D4C9F009A6919 /* drag_drop_types.h */,
4D7BFBA50E9D4C9F009A6919 /* env_vars.cc */,
4D7BFBA60E9D4C9F009A6919 /* env_vars.h */,
+ 4590B61B84978823B2BADA68 /* file_descriptor_set_posix.cc */,
4D7BFBA70E9D4C9F009A6919 /* filter_policy.h */,
4D7BFBA80E9D4C9F009A6919 /* gears_api.h */,
4D7BFBAA0E9D4C9F009A6919 /* ipc_channel.h */,
@@ -5509,8 +5509,8 @@
B562E2C70F0582F800FB1A4F /* common_glue.cc in Sources */,
4D7BFCCE0E9D4D7A009A6919 /* cookie_monster_sqlite.cc in Sources */,
4D7BFC2E0E9D4CF5009A6919 /* debug_flags.cc in Sources */,
- 884BD6B5D58856CAC05DE5C0 /* descriptor_set_posix.cc in Sources */,
4D7BFC330E9D4CF9009A6919 /* env_vars.cc in Sources */,
+ E54EDFC97B4932925C31CB41 /* file_descriptor_set_posix.cc in Sources */,
B5FDC0580EE488E500BEC6E6 /* ipc_channel_posix.cc in Sources */,
B5DBEA900EFC60E200C95176 /* ipc_channel_proxy.cc in Sources */,
2DF2A9EB8AF96926EE9B6B02 /* ipc_logging.cc in Sources */,
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index 5824335..e5c709f 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -221,7 +221,7 @@ if not env.Bit('windows'):
# TODO(port): This is temporary so we can link.
input_files.Append(
'temp_scaffolding_stubs.cc',
- 'descriptor_set_posix.cc',
+ 'file_descriptor_set_posix.cc',
)
# TODO(port): Port these.
diff --git a/chrome/common/descriptor_set_posix.cc b/chrome/common/descriptor_set_posix.cc
deleted file mode 100644
index 9b19ef2..0000000
--- a/chrome/common/descriptor_set_posix.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/descriptor_set_posix.h"
-
-#include "base/logging.h"
-
-DescriptorSet::DescriptorSet()
- : consumed_descriptor_highwater_(0) {
-}
-
-DescriptorSet::~DescriptorSet() {
- if (consumed_descriptor_highwater_ == descriptors_.size())
- return;
-
- LOG(WARNING) << "DescriptorSet destroyed with unconsumed descriptors";
- // We close all the descriptors where the close flag is set. If this
- // message should have been transmitted, then closing those with close
- // flags set mirrors the expected behaviour.
- //
- // If this message was received with more descriptors than expected
- // (which could a DOS against the browser by a rogue renderer) then all
- // the descriptors have their close flag set and we free all the extra
- // kernel resources.
- for (unsigned i = consumed_descriptor_highwater_;
- i < descriptors_.size(); ++i) {
- if (descriptors_[i].auto_close)
- close(descriptors_[i].fd);
- }
-}
-
-bool DescriptorSet::Add(int fd) {
- if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
- return false;
-
- struct base::FileDescriptor sd;
- sd.fd = fd;
- sd.auto_close = false;
- descriptors_.push_back(sd);
- return true;
-}
-
-bool DescriptorSet::AddAndAutoClose(int fd) {
- if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
- return false;
-
- struct base::FileDescriptor sd;
- sd.fd = fd;
- sd.auto_close = true;
- descriptors_.push_back(sd);
- DCHECK(descriptors_.size() <= MAX_DESCRIPTORS_PER_MESSAGE);
- return true;
-}
-
-int DescriptorSet::GetDescriptorAt(unsigned index) const {
- if (index >= descriptors_.size())
- return -1;
-
- // We should always walk the descriptors in order, so it's reasonable to
- // enforce this. Consider the case where a compromised renderer sends us
- // the following message:
- //
- // ExampleMsg:
- // num_fds:2 msg:FD(index = 1) control:SCM_RIGHTS {n, m}
- //
- // Here the renderer sent us a message which should have a descriptor, but
- // actually sent two in an attempt to fill our fd table and kill us. By
- // setting the index of the descriptor in the message to 1 (it should be
- // 0), we would record a highwater of 1 and then consider all the
- // descriptors to have been used.
- //
- // So we can either track of the use of each descriptor in a bitset, or we
- // can enforce that we walk the indexes strictly in order.
- //
- // There's one more wrinkle: When logging messages, we may reparse them. So
- // we have an exception: When the consumed_descriptor_highwater_ is at the
- // end of the array and index 0 is requested, we reset the highwater value.
- if (index == 0 && consumed_descriptor_highwater_ == descriptors_.size())
- consumed_descriptor_highwater_ = 0;
-
- if (index != consumed_descriptor_highwater_)
- return -1;
-
- consumed_descriptor_highwater_ = index + 1;
- return descriptors_[index].fd;
-}
-
-void DescriptorSet::GetDescriptors(int* buffer) const {
- for (std::vector<base::FileDescriptor>::const_iterator
- i = descriptors_.begin(); i != descriptors_.end(); ++i) {
- *(buffer++) = i->fd;
- }
-}
-
-void DescriptorSet::CommitAll() {
- for (std::vector<base::FileDescriptor>::iterator
- i = descriptors_.begin(); i != descriptors_.end(); ++i) {
- if (i->auto_close)
- close(i->fd);
- }
- descriptors_.clear();
- consumed_descriptor_highwater_ = 0;
-}
-
-void DescriptorSet::SetDescriptors(const int* buffer, unsigned count) {
- DCHECK_LE(count, MAX_DESCRIPTORS_PER_MESSAGE);
- DCHECK_EQ(descriptors_.size(), 0u);
- DCHECK_EQ(consumed_descriptor_highwater_, 0u);
-
- descriptors_.reserve(count);
- for (unsigned i = 0; i < count; ++i) {
- struct base::FileDescriptor sd;
- sd.fd = buffer[i];
- sd.auto_close = true;
- descriptors_.push_back(sd);
- }
-}
diff --git a/chrome/common/descriptor_set_posix.h b/chrome/common/descriptor_set_posix.h
deleted file mode 100644
index 1757648..0000000
--- a/chrome/common/descriptor_set_posix.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_DESCRIPTOR_SET_POSIX_H_
-#define CHROME_COMMON_DESCRIPTOR_SET_POSIX_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/file_descriptor_posix.h"
-#include "base/ref_counted.h"
-
-// -----------------------------------------------------------------------------
-// A DescriptorSet is an ordered set of POSIX file descriptors. These are
-// associated with IPC messages so that descriptors can be transmitted over a
-// UNIX domain socket.
-// -----------------------------------------------------------------------------
-class DescriptorSet : public base::RefCountedThreadSafe<DescriptorSet> {
- public:
- DescriptorSet();
- ~DescriptorSet();
-
- // This is the maximum number of descriptors per message. We need to know this
- // because the control message kernel interface has to be given a buffer which
- // is large enough to store all the descriptor numbers. Otherwise the kernel
- // tells us that it truncated the control data and the extra descriptors are
- // lost.
- //
- // In debugging mode, it's a fatal error to try and add more than this number
- // of descriptors to a DescriptorSet.
- enum {
- MAX_DESCRIPTORS_PER_MESSAGE = 4,
- };
-
- // ---------------------------------------------------------------------------
- // Interfaces for building during message serialisation...
-
- // Add a descriptor to the end of the set. Returns false iff the set is full.
- bool Add(int fd);
- // Add a descriptor to the end of the set and automatically close it after
- // transmission. Returns false iff the set is full.
- bool AddAndAutoClose(int fd);
-
- // ---------------------------------------------------------------------------
-
-
- // ---------------------------------------------------------------------------
- // Interfaces for accessing during message deserialisation...
-
- // Return the number of descriptors
- unsigned size() const { return descriptors_.size(); }
- // Return true if no unconsumed descriptors remain
- bool empty() const { return descriptors_.empty(); }
- // Fetch the nth descriptor from the beginning of the set. Code using this
- // /must/ access the descriptors in order, except that it may wrap from the
- // end to index 0 again.
- //
- // This interface is designed for the deserialising code as it doesn't
- // support close flags.
- // returns: file descriptor, or -1 on error
- int GetDescriptorAt(unsigned n) const;
-
- // ---------------------------------------------------------------------------
-
-
- // ---------------------------------------------------------------------------
- // Interfaces for transmission...
-
- // Fill an array with file descriptors without 'consuming' them. CommitAll
- // must be called after these descriptors have been transmitted.
- // buffer: (output) a buffer of, at least, size() integers.
- void GetDescriptors(int* buffer) const;
- // This must be called after transmitting the descriptors returned by
- // GetDescriptors. It marks all the descriptors as consumed and closes those
- // which are auto-close.
- void CommitAll();
-
- // ---------------------------------------------------------------------------
-
-
- // ---------------------------------------------------------------------------
- // Interfaces for receiving...
-
- // Set the contents of the set from the given buffer. This set must be empty
- // before calling. The auto-close flag is set on all the descriptors so that
- // unconsumed descriptors are closed on destruction.
- void SetDescriptors(const int* buffer, unsigned count);
-
- // ---------------------------------------------------------------------------
-
- 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
- // with a true flag are closed. If this message has been received, then these
- // are the descriptors which were received and all close flags are true.
- std::vector<base::FileDescriptor> descriptors_;
-
- // This contains the index of the next descriptor which should be consumed.
- // It's used in a couple of ways. Firstly, at destruction we can check that
- // all the descriptors have been read (with GetNthDescriptor). Secondly, we
- // can check that they are read in order.
- mutable unsigned consumed_descriptor_highwater_;
-
- DISALLOW_COPY_AND_ASSIGN(DescriptorSet);
-};
-
-#endif // CHROME_COMMON_FILE_DESCRIPTOR_POSIX_H_
diff --git a/chrome/common/file_descriptor_set_posix.cc b/chrome/common/file_descriptor_set_posix.cc
index 9b19ef2..b57c007 100644
--- a/chrome/common/file_descriptor_set_posix.cc
+++ b/chrome/common/file_descriptor_set_posix.cc
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/descriptor_set_posix.h"
+#include "chrome/common/file_descriptor_set_posix.h"
#include "base/logging.h"
-DescriptorSet::DescriptorSet()
+FileDescriptorSet::FileDescriptorSet()
: consumed_descriptor_highwater_(0) {
}
-DescriptorSet::~DescriptorSet() {
+FileDescriptorSet::~FileDescriptorSet() {
if (consumed_descriptor_highwater_ == descriptors_.size())
return;
- LOG(WARNING) << "DescriptorSet destroyed with unconsumed descriptors";
+ LOG(WARNING) << "FileDescriptorSet destroyed with unconsumed descriptors";
// We close all the descriptors where the close flag is set. If this
// message should have been transmitted, then closing those with close
// flags set mirrors the expected behaviour.
@@ -30,7 +30,7 @@ DescriptorSet::~DescriptorSet() {
}
}
-bool DescriptorSet::Add(int fd) {
+bool FileDescriptorSet::Add(int fd) {
if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
return false;
@@ -41,7 +41,7 @@ bool DescriptorSet::Add(int fd) {
return true;
}
-bool DescriptorSet::AddAndAutoClose(int fd) {
+bool FileDescriptorSet::AddAndAutoClose(int fd) {
if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
return false;
@@ -53,7 +53,7 @@ bool DescriptorSet::AddAndAutoClose(int fd) {
return true;
}
-int DescriptorSet::GetDescriptorAt(unsigned index) const {
+int FileDescriptorSet::GetDescriptorAt(unsigned index) const {
if (index >= descriptors_.size())
return -1;
@@ -86,14 +86,14 @@ int DescriptorSet::GetDescriptorAt(unsigned index) const {
return descriptors_[index].fd;
}
-void DescriptorSet::GetDescriptors(int* buffer) const {
+void FileDescriptorSet::GetDescriptors(int* buffer) const {
for (std::vector<base::FileDescriptor>::const_iterator
i = descriptors_.begin(); i != descriptors_.end(); ++i) {
*(buffer++) = i->fd;
}
}
-void DescriptorSet::CommitAll() {
+void FileDescriptorSet::CommitAll() {
for (std::vector<base::FileDescriptor>::iterator
i = descriptors_.begin(); i != descriptors_.end(); ++i) {
if (i->auto_close)
@@ -103,7 +103,7 @@ void DescriptorSet::CommitAll() {
consumed_descriptor_highwater_ = 0;
}
-void DescriptorSet::SetDescriptors(const int* buffer, unsigned count) {
+void FileDescriptorSet::SetDescriptors(const int* buffer, unsigned count) {
DCHECK_LE(count, MAX_DESCRIPTORS_PER_MESSAGE);
DCHECK_EQ(descriptors_.size(), 0u);
DCHECK_EQ(consumed_descriptor_highwater_, 0u);
diff --git a/chrome/common/file_descriptor_set_posix.h b/chrome/common/file_descriptor_set_posix.h
index 1757648..342e6d9 100644
--- a/chrome/common/file_descriptor_set_posix.h
+++ b/chrome/common/file_descriptor_set_posix.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_DESCRIPTOR_SET_POSIX_H_
-#define CHROME_COMMON_DESCRIPTOR_SET_POSIX_H_
+#ifndef CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_
+#define CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_
#include <vector>
@@ -12,14 +12,14 @@
#include "base/ref_counted.h"
// -----------------------------------------------------------------------------
-// A DescriptorSet is an ordered set of POSIX file descriptors. These are
+// A FileDescriptorSet is an ordered set of POSIX file descriptors. These are
// associated with IPC messages so that descriptors can be transmitted over a
// UNIX domain socket.
// -----------------------------------------------------------------------------
-class DescriptorSet : public base::RefCountedThreadSafe<DescriptorSet> {
+class FileDescriptorSet : public base::RefCountedThreadSafe<FileDescriptorSet> {
public:
- DescriptorSet();
- ~DescriptorSet();
+ FileDescriptorSet();
+ ~FileDescriptorSet();
// This is the maximum number of descriptors per message. We need to know this
// because the control message kernel interface has to be given a buffer which
@@ -28,7 +28,7 @@ class DescriptorSet : public base::RefCountedThreadSafe<DescriptorSet> {
// lost.
//
// In debugging mode, it's a fatal error to try and add more than this number
- // of descriptors to a DescriptorSet.
+ // of descriptors to a FileDescriptorSet.
enum {
MAX_DESCRIPTORS_PER_MESSAGE = 4,
};
@@ -102,7 +102,7 @@ class DescriptorSet : public base::RefCountedThreadSafe<DescriptorSet> {
// can check that they are read in order.
mutable unsigned consumed_descriptor_highwater_;
- DISALLOW_COPY_AND_ASSIGN(DescriptorSet);
+ DISALLOW_COPY_AND_ASSIGN(FileDescriptorSet);
};
-#endif // CHROME_COMMON_FILE_DESCRIPTOR_POSIX_H_
+#endif // CHROME_COMMON_FILE_DESCRIPTOR_SET_POSIX_H_
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc
index 72d1554..e29596c 100644
--- a/chrome/common/ipc_channel_posix.cc
+++ b/chrome/common/ipc_channel_posix.cc
@@ -28,7 +28,7 @@
#include "base/singleton.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/descriptor_set_posix.h"
+#include "chrome/common/file_descriptor_set_posix.h"
#include "chrome/common/ipc_message_utils.h"
namespace IPC {
@@ -494,7 +494,7 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
}
if (m.header()->num_fds >
- DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE) {
+ FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE) {
// There are too many descriptors in this message
error = "Message requires an excessive number of descriptors";
}
@@ -514,7 +514,8 @@ bool Channel::ChannelImpl::ProcessIncomingMessages() {
return false;
}
- m.descriptor_set()->SetDescriptors(&fds[fds_i], m.header()->num_fds);
+ m.file_descriptor_set()->SetDescriptors(
+ &fds[fds_i], m.header()->num_fds);
fds_i += m.header()->num_fds;
}
#ifdef IPC_MESSAGE_DEBUG_EXTRA
@@ -578,15 +579,15 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
msgh.msg_iov = &iov;
msgh.msg_iovlen = 1;
char buf[CMSG_SPACE(
- sizeof(int[DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE]))];
+ sizeof(int[FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE]))];
if (message_send_bytes_written_ == 0 &&
- !msg->descriptor_set()->empty()) {
+ !msg->file_descriptor_set()->empty()) {
// This is the first chunk of a message which has descriptors to send
struct cmsghdr *cmsg;
- const unsigned num_fds = msg->descriptor_set()->size();
+ const unsigned num_fds = msg->file_descriptor_set()->size();
- DCHECK_LE(num_fds, DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE);
+ DCHECK_LE(num_fds, FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE);
msgh.msg_control = buf;
msgh.msg_controllen = CMSG_SPACE(sizeof(int) * num_fds);
@@ -594,7 +595,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds);
- msg->descriptor_set()->GetDescriptors(
+ msg->file_descriptor_set()->GetDescriptors(
reinterpret_cast<int*>(CMSG_DATA(cmsg)));
msgh.msg_controllen = cmsg->cmsg_len;
@@ -603,7 +604,7 @@ bool Channel::ChannelImpl::ProcessOutgoingMessages() {
bytes_written = sendmsg(pipe_, &msgh, MSG_DONTWAIT);
if (bytes_written > 0)
- msg->descriptor_set()->CommitAll();
+ msg->file_descriptor_set()->CommitAll();
} while (bytes_written == -1 && errno == EINTR);
if (bytes_written < 0 && errno != EAGAIN) {
diff --git a/chrome/common/ipc_channel_posix.h b/chrome/common/ipc_channel_posix.h
index d6ed17d..fbdd59b 100644
--- a/chrome/common/ipc_channel_posix.h
+++ b/chrome/common/ipc_channel_posix.h
@@ -14,7 +14,7 @@
#include <vector>
#include "base/message_loop.h"
-#include "chrome/common/descriptor_set_posix.h"
+#include "chrome/common/file_descriptor_set_posix.h"
namespace IPC {
@@ -76,7 +76,7 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
// We assume a worst case: kReadBufferSize bytes of messages, where each
// message has no payload and a full complement of descriptors.
MAX_READ_FDS = (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) *
- DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE,
+ FileDescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE,
};
// This is a control message buffer large enough to hold kMaxReadFDs
diff --git a/chrome/common/ipc_message.cc b/chrome/common/ipc_message.cc
index 9a15f1c..593b763 100644
--- a/chrome/common/ipc_message.cc
+++ b/chrome/common/ipc_message.cc
@@ -8,7 +8,7 @@
#include "build/build_config.h"
#if defined(OS_POSIX)
-#include "chrome/common/descriptor_set_posix.h"
+#include "chrome/common/file_descriptor_set_posix.h"
#endif
namespace IPC {
@@ -45,7 +45,7 @@ Message::Message(const char* data, int data_len) : Pickle(data, data_len) {
Message::Message(const Message& other) : Pickle(other) {
InitLoggingVariables();
#if defined(OS_POSIX)
- descriptor_set_ = other.descriptor_set_;
+ file_descriptor_set_ = other.file_descriptor_set_;
#endif
}
@@ -60,7 +60,7 @@ void Message::InitLoggingVariables() {
Message& Message::operator=(const Message& other) {
*static_cast<Pickle*>(this) = other;
#if defined(OS_POSIX)
- descriptor_set_ = other.descriptor_set_;
+ file_descriptor_set_ = other.file_descriptor_set_;
#endif
return *this;
}
@@ -90,11 +90,11 @@ void Message::set_received_time(int64 time) const {
bool Message::WriteFileDescriptor(const base::FileDescriptor& descriptor) {
// We write the index of the descriptor so that we don't have to
// keep the current descriptor as extra decoding state when deserialising.
- WriteInt(descriptor_set()->size());
+ WriteInt(file_descriptor_set()->size());
if (descriptor.auto_close) {
- return descriptor_set()->AddAndAutoClose(descriptor.fd);
+ return file_descriptor_set()->AddAndAutoClose(descriptor.fd);
} else {
- return descriptor_set()->Add(descriptor.fd);
+ return file_descriptor_set()->Add(descriptor.fd);
}
}
@@ -104,19 +104,19 @@ bool Message::ReadFileDescriptor(void** iter,
if (!ReadInt(iter, &descriptor_index))
return false;
- DescriptorSet* descriptor_set = descriptor_set_.get();
- if (!descriptor_set)
+ FileDescriptorSet* file_descriptor_set = file_descriptor_set_.get();
+ if (!file_descriptor_set)
return false;
- descriptor->fd = descriptor_set->GetDescriptorAt(descriptor_index);
+ descriptor->fd = file_descriptor_set->GetDescriptorAt(descriptor_index);
descriptor->auto_close = false;
return descriptor->fd >= 0;
}
-void Message::EnsureDescriptorSet() {
- if (descriptor_set_.get() == NULL)
- descriptor_set_ = new DescriptorSet;
+void Message::EnsureFileDescriptorSet() {
+ if (file_descriptor_set_.get() == NULL)
+ file_descriptor_set_ = new FileDescriptorSet;
}
#endif
diff --git a/chrome/common/ipc_message.h b/chrome/common/ipc_message.h
index b670bf1..d0aa1c7 100644
--- a/chrome/common/ipc_message.h
+++ b/chrome/common/ipc_message.h
@@ -23,7 +23,7 @@ namespace base {
class FileDescriptor;
}
-class DescriptorSet;
+class FileDescriptorSet;
namespace IPC {
@@ -239,17 +239,17 @@ class Message : public Pickle {
#if defined(OS_POSIX)
// The set of file descriptors associated with this message.
- scoped_refptr<DescriptorSet> descriptor_set_;
+ scoped_refptr<FileDescriptorSet> file_descriptor_set_;
- // Ensure that a DescriptorSet is allocated
- void EnsureDescriptorSet();
+ // Ensure that a FileDescriptorSet is allocated
+ void EnsureFileDescriptorSet();
- DescriptorSet* descriptor_set() {
- EnsureDescriptorSet();
- return descriptor_set_.get();
+ FileDescriptorSet* file_descriptor_set() {
+ EnsureFileDescriptorSet();
+ return file_descriptor_set_.get();
}
- const DescriptorSet* descriptor_set() const {
- return descriptor_set_.get();
+ const FileDescriptorSet* file_descriptor_set() const {
+ return file_descriptor_set_.get();
}
#endif
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index fa65288..ae42bb0 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -13,7 +13,7 @@
#include "base/string_util.h"
#include "base/tuple.h"
#if defined(OS_POSIX)
-#include "chrome/common/descriptor_set_posix.h"
+#include "chrome/common/file_descriptor_set_posix.h"
#endif
#include "chrome/common/ipc_sync_message.h"
#include "chrome/common/thumbnail_score.h"
diff --git a/chrome/common/ipc_tests.cc b/chrome/common/ipc_tests.cc
index 4b24406..ae88659 100644
--- a/chrome/common/ipc_tests.cc
+++ b/chrome/common/ipc_tests.cc
@@ -26,9 +26,6 @@
#include "base/test_suite.h"
#include "base/thread.h"
#include "chrome/common/chrome_switches.h"
-#if defined(OS_POSIX)
-#include "chrome/common/descriptor_set_posix.h"
-#endif
#include "chrome/common/ipc_channel.h"
#include "chrome/common/ipc_channel_proxy.h"
#include "chrome/common/ipc_message_utils.h"