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

Side by Side Diff: ipc/ipc_channel_posix.cc

Issue 621613002: Refactoring: Make IPC::Channel::TakeClientFileDescriptor() a ScopedFD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Mac build Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ipc/ipc_channel_posix.h" 5 #include "ipc/ipc_channel_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 551
552 return true; 552 return true;
553 } 553 }
554 554
555 int ChannelPosix::GetClientFileDescriptor() const { 555 int ChannelPosix::GetClientFileDescriptor() const {
556 base::AutoLock lock(client_pipe_lock_); 556 base::AutoLock lock(client_pipe_lock_);
557 return client_pipe_.get(); 557 return client_pipe_.get();
558 } 558 }
559 559
560 int ChannelPosix::TakeClientFileDescriptor() { 560 base::ScopedFD ChannelPosix::TakeClientFileDescriptor() {
561 base::AutoLock lock(client_pipe_lock_); 561 base::AutoLock lock(client_pipe_lock_);
562 if (!client_pipe_.is_valid()) 562 if (!client_pipe_.is_valid())
563 return -1; 563 return base::ScopedFD();
564 PipeMap::GetInstance()->Remove(pipe_name_); 564 PipeMap::GetInstance()->Remove(pipe_name_);
565 return client_pipe_.release(); 565 return client_pipe_.Pass();
566 } 566 }
567 567
568 void ChannelPosix::CloseClientFileDescriptor() { 568 void ChannelPosix::CloseClientFileDescriptor() {
569 base::AutoLock lock(client_pipe_lock_); 569 base::AutoLock lock(client_pipe_lock_);
570 if (!client_pipe_.is_valid()) 570 if (!client_pipe_.is_valid())
571 return; 571 return;
572 PipeMap::GetInstance()->Remove(pipe_name_); 572 PipeMap::GetInstance()->Remove(pipe_name_);
573 client_pipe_.reset(); 573 client_pipe_.reset();
574 } 574 }
575 575
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1076 }
1077 1077
1078 #if defined(OS_LINUX) 1078 #if defined(OS_LINUX)
1079 // static 1079 // static
1080 void Channel::SetGlobalPid(int pid) { 1080 void Channel::SetGlobalPid(int pid) {
1081 ChannelPosix::SetGlobalPid(pid); 1081 ChannelPosix::SetGlobalPid(pid);
1082 } 1082 }
1083 #endif // OS_LINUX 1083 #endif // OS_LINUX
1084 1084
1085 } // namespace IPC 1085 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698