Index: content/renderer/p2p/ipc_socket_factory.cc |
diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc |
index 4563aa3a8821c938c7003687458eaafb1246dea7..e0d93d343ba0157db53cdf56e4e46a2d97396c58 100644 |
--- a/content/renderer/p2p/ipc_socket_factory.cc |
+++ b/content/renderer/p2p/ipc_socket_factory.cc |
@@ -10,14 +10,13 @@ |
#include <list> |
#include "base/compiler_specific.h" |
-#include "base/logging.h" |
#include "base/macros.h" |
+#include "base/message_loop/message_loop.h" |
#include "base/metrics/field_trial.h" |
#include "base/metrics/histogram.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/stringprintf.h" |
#include "base/threading/non_thread_safe.h" |
-#include "base/threading/thread_checker.h" |
#include "base/trace_event/trace_event.h" |
#include "content/renderer/media/webrtc_logging.h" |
#include "content/renderer/p2p/host_address_request.h" |
@@ -156,8 +155,8 @@ |
P2PSocketType type_; |
- // Used to verify that a method runs on the thread that created this socket. |
- base::ThreadChecker thread_checker_; |
+ // Message loop on which this socket was created and being used. |
+ base::MessageLoop* message_loop_; |
// Corresponding P2P socket client. |
scoped_refptr<P2PSocketClient> client_; |
@@ -233,6 +232,7 @@ |
IpcPacketSocket::IpcPacketSocket() |
: type_(P2P_SOCKET_UDP), |
+ message_loop_(base::MessageLoop::current()), |
state_(IS_UNINITIALIZED), |
send_bytes_available_(kMaximumInFlightBytes), |
writable_signal_expected_(false), |
@@ -293,7 +293,7 @@ |
P2PSocketClientImpl* client, |
const rtc::SocketAddress& local_address, |
const rtc::SocketAddress& remote_address) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
DCHECK_EQ(state_, IS_UNINITIALIZED); |
type_ = type; |
@@ -341,7 +341,7 @@ |
P2PSocketClient* client, |
const rtc::SocketAddress& local_address, |
const rtc::SocketAddress& remote_address) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
DCHECK_EQ(state_, IS_UNINITIALIZED); |
client_ = client; |
@@ -354,25 +354,25 @@ |
// rtc::AsyncPacketSocket interface. |
rtc::SocketAddress IpcPacketSocket::GetLocalAddress() const { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
return local_address_; |
} |
rtc::SocketAddress IpcPacketSocket::GetRemoteAddress() const { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
return remote_address_; |
} |
int IpcPacketSocket::Send(const void *data, size_t data_size, |
const rtc::PacketOptions& options) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
return SendTo(data, data_size, remote_address_, options); |
} |
int IpcPacketSocket::SendTo(const void *data, size_t data_size, |
const rtc::SocketAddress& address, |
const rtc::PacketOptions& options) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
switch (state_) { |
case IS_UNINITIALIZED: |
@@ -453,7 +453,7 @@ |
} |
int IpcPacketSocket::Close() { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
client_->Close(); |
state_ = IS_CLOSED; |
@@ -462,7 +462,7 @@ |
} |
rtc::AsyncPacketSocket::State IpcPacketSocket::GetState() const { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
switch (state_) { |
case IS_UNINITIALIZED: |
@@ -500,7 +500,7 @@ |
} |
int IpcPacketSocket::SetOption(rtc::Socket::Option option, int value) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
P2PSocketOption p2p_socket_option = P2P_SOCKET_OPT_MAX; |
if (!JingleSocketOptionToP2PSocketOption(option, &p2p_socket_option)) { |
@@ -518,7 +518,7 @@ |
} |
int IpcPacketSocket::DoSetOption(P2PSocketOption option, int value) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
DCHECK_EQ(state_, IS_OPEN); |
client_->SetOption(option, value); |
@@ -526,18 +526,18 @@ |
} |
int IpcPacketSocket::GetError() const { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
return error_; |
} |
void IpcPacketSocket::SetError(int error) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
error_ = error; |
} |
void IpcPacketSocket::OnOpen(const net::IPEndPoint& local_address, |
const net::IPEndPoint& remote_address) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
if (!jingle_glue::IPEndPointToSocketAddress(local_address, &local_address_)) { |
// Always expect correct IPv4 address to be allocated. |
@@ -581,7 +581,7 @@ |
void IpcPacketSocket::OnIncomingTcpConnection( |
const net::IPEndPoint& address, |
P2PSocketClient* client) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
std::unique_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
@@ -595,7 +595,7 @@ |
} |
void IpcPacketSocket::OnSendComplete(const P2PSendPacketMetrics& send_metrics) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
CHECK(!in_flight_packet_records_.empty()); |
@@ -632,7 +632,7 @@ |
} |
void IpcPacketSocket::OnError() { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
bool was_closed = (state_ == IS_ERROR || state_ == IS_CLOSED); |
state_ = IS_ERROR; |
error_ = ECONNABORTED; |
@@ -644,7 +644,7 @@ |
void IpcPacketSocket::OnDataReceived(const net::IPEndPoint& address, |
const std::vector<char>& data, |
const base::TimeTicks& timestamp) { |
- DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
rtc::SocketAddress address_lj; |