Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/base/physicalsocketserver.h" | 10 #include "webrtc/base/physicalsocketserver.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 // initialized by constructor of a static object. If neccessary libjingle | 131 // initialized by constructor of a static object. If neccessary libjingle |
| 132 // users can link it with a different version of this function by replacing | 132 // users can link it with a different version of this function by replacing |
| 133 // win32socketinit.cc. See win32socketinit.cc for more details. | 133 // win32socketinit.cc. See win32socketinit.cc for more details. |
| 134 EnsureWinsockInit(); | 134 EnsureWinsockInit(); |
| 135 #endif | 135 #endif |
| 136 if (s_ != INVALID_SOCKET) { | 136 if (s_ != INVALID_SOCKET) { |
| 137 enabled_events_ = DE_READ | DE_WRITE; | 137 enabled_events_ = DE_READ | DE_WRITE; |
| 138 | 138 |
| 139 int type = SOCK_STREAM; | 139 int type = SOCK_STREAM; |
| 140 socklen_t len = sizeof(type); | 140 socklen_t len = sizeof(type); |
| 141 VERIFY(0 == getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len)); | 141 int res = getsockopt(s_, SOL_SOCKET, SO_TYPE, (SockOptArg)&type, &len); |
| 142 RTC_DCHECK (res == 0); | |
|
kwiberg-webrtc
2017/02/07 09:39:49
Spurious space. Also, RTC_DCHECK_EQ?
| |
| 142 udp_ = (SOCK_DGRAM == type); | 143 udp_ = (SOCK_DGRAM == type); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 PhysicalSocket::~PhysicalSocket() { | 147 PhysicalSocket::~PhysicalSocket() { |
| 147 Close(); | 148 Close(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 bool PhysicalSocket::Create(int family, int type) { | 151 bool PhysicalSocket::Create(int family, int type) { |
| 151 Close(); | 152 Close(); |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 ~EventDispatcher() override { | 828 ~EventDispatcher() override { |
| 828 ss_->Remove(this); | 829 ss_->Remove(this); |
| 829 close(afd_[0]); | 830 close(afd_[0]); |
| 830 close(afd_[1]); | 831 close(afd_[1]); |
| 831 } | 832 } |
| 832 | 833 |
| 833 virtual void Signal() { | 834 virtual void Signal() { |
| 834 CritScope cs(&crit_); | 835 CritScope cs(&crit_); |
| 835 if (!fSignaled_) { | 836 if (!fSignaled_) { |
| 836 const uint8_t b[1] = {0}; | 837 const uint8_t b[1] = {0}; |
| 837 if (VERIFY(1 == write(afd_[1], b, sizeof(b)))) { | 838 ssize_t res = write(afd_[1], b, sizeof(b)); |
| 839 RTC_DCHECK(1 == res); | |
| 840 if (res == 1) { | |
| 838 fSignaled_ = true; | 841 fSignaled_ = true; |
| 839 } | 842 } |
|
kwiberg-webrtc
2017/02/07 09:39:49
Hmm. You're not supposed to handle DCHECK failures
nisse-webrtc
2017/02/07 10:48:15
I'm deleting the if. And changing to const and DCH
| |
| 840 } | 843 } |
| 841 } | 844 } |
| 842 | 845 |
| 843 uint32_t GetRequestedEvents() override { return DE_READ; } | 846 uint32_t GetRequestedEvents() override { return DE_READ; } |
| 844 | 847 |
| 845 void OnPreEvent(uint32_t ff) override { | 848 void OnPreEvent(uint32_t ff) override { |
| 846 // It is not possible to perfectly emulate an auto-resetting event with | 849 // It is not possible to perfectly emulate an auto-resetting event with |
| 847 // pipes. This simulates it by resetting before the event is handled. | 850 // pipes. This simulates it by resetting before the event is handled. |
| 848 | 851 |
| 849 CritScope cs(&crit_); | 852 CritScope cs(&crit_); |
| 850 if (fSignaled_) { | 853 if (fSignaled_) { |
| 851 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. | 854 uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. |
| 852 VERIFY(1 == read(afd_[0], b, sizeof(b))); | 855 ssize_t res = read(afd_[0], b, sizeof(b)); |
|
kwiberg-webrtc
2017/02/07 09:39:49
const? (You don't *have* to, but I recommend const
nisse-webrtc
2017/02/07 10:48:15
Done.
| |
| 856 RTC_DCHECK(1 == res); | |
|
kwiberg-webrtc
2017/02/07 09:39:49
RTC_DCHECK_EQ, especially if you want the argument
nisse-webrtc
2017/02/07 10:48:15
Done.
| |
| 853 fSignaled_ = false; | 857 fSignaled_ = false; |
| 854 } | 858 } |
| 855 } | 859 } |
| 856 | 860 |
| 857 void OnEvent(uint32_t ff, int err) override { RTC_NOTREACHED(); } | 861 void OnEvent(uint32_t ff, int err) override { RTC_NOTREACHED(); } |
| 858 | 862 |
| 859 int GetDescriptor() override { return afd_[0]; } | 863 int GetDescriptor() override { return afd_[0]; } |
| 860 | 864 |
| 861 bool IsDescriptorClosed() override { return false; } | 865 bool IsDescriptorClosed() override { return false; } |
| 862 | 866 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1596 break; | 1600 break; |
| 1597 } | 1601 } |
| 1598 } | 1602 } |
| 1599 | 1603 |
| 1600 // Done | 1604 // Done |
| 1601 return true; | 1605 return true; |
| 1602 } | 1606 } |
| 1603 #endif // WEBRTC_WIN | 1607 #endif // WEBRTC_WIN |
| 1604 | 1608 |
| 1605 } // namespace rtc | 1609 } // namespace rtc |
| OLD | NEW |