| Index: base/posix/global_descriptors.cc
|
| diff --git a/base/posix/global_descriptors.cc b/base/posix/global_descriptors.cc
|
| index bcca443acc13a7f52794689ee1f0037a8704e364..6c187838ad69d63051a1155d64c26623de8a2db0 100644
|
| --- a/base/posix/global_descriptors.cc
|
| +++ b/base/posix/global_descriptors.cc
|
| @@ -11,6 +11,16 @@
|
|
|
| namespace base {
|
|
|
| +GlobalDescriptors::Descriptor::Descriptor(Key key, int fd)
|
| + : key(key), fd(fd), region(base::MemoryMappedFile::Region::kWholeFile) {
|
| +}
|
| +
|
| +GlobalDescriptors::Descriptor::Descriptor(Key key,
|
| + int fd,
|
| + base::MemoryMappedFile::Region region)
|
| + : key(key), fd(fd), region(region) {
|
| +}
|
| +
|
| // static
|
| GlobalDescriptors* GlobalDescriptors::GetInstance() {
|
| typedef Singleton<base::GlobalDescriptors,
|
| @@ -30,23 +40,38 @@ int GlobalDescriptors::Get(Key key) const {
|
| int GlobalDescriptors::MaybeGet(Key key) const {
|
| for (Mapping::const_iterator
|
| i = descriptors_.begin(); i != descriptors_.end(); ++i) {
|
| - if (i->first == key)
|
| - return i->second;
|
| + if (i->key == key)
|
| + return i->fd;
|
| }
|
|
|
| return -1;
|
| }
|
|
|
| void GlobalDescriptors::Set(Key key, int fd) {
|
| - for (Mapping::iterator
|
| - i = descriptors_.begin(); i != descriptors_.end(); ++i) {
|
| - if (i->first == key) {
|
| - i->second = fd;
|
| + Set(key, fd, base::MemoryMappedFile::Region::kWholeFile);
|
| +}
|
| +
|
| +void GlobalDescriptors::Set(Key key,
|
| + int fd,
|
| + base::MemoryMappedFile::Region region) {
|
| + for (auto& i : descriptors_) {
|
| + if (i.key == key) {
|
| + i.fd = fd;
|
| + i.region = region;
|
| return;
|
| }
|
| }
|
|
|
| - descriptors_.push_back(std::make_pair(key, fd));
|
| + descriptors_.push_back(Descriptor(key, fd, region));
|
| +}
|
| +
|
| +base::MemoryMappedFile::Region GlobalDescriptors::GetRegion(Key key) const {
|
| + for (const auto& i : descriptors_) {
|
| + if (i.key == key)
|
| + return i.region;
|
| + }
|
| + DLOG(FATAL) << "Unknown global descriptor: " << key;
|
| + return base::MemoryMappedFile::Region::kWholeFile;
|
| }
|
|
|
| void GlobalDescriptors::Reset(const Mapping& mapping) {
|
|
|