OLD | NEW |
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 "content/renderer/p2p/ipc_socket_factory.h" | 5 #include "content/renderer/p2p/ipc_socket_factory.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/renderer/p2p/socket_client.h" | 10 #include "content/renderer/p2p/socket_client.h" |
11 #include "content/renderer/p2p/socket_dispatcher.h" | 11 #include "content/renderer/p2p/socket_dispatcher.h" |
12 #include "jingle/glue/utils.h" | 12 #include "jingle/glue/utils.h" |
13 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" | 13 #include "third_party/libjingle/source/talk/base/asyncpacketsocket.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // TODO(sergeyu): Try adjusting these parameters to achieve optimal performance. | 19 // TODO(hclam): This shouldn't be a pre-defined value. Bug: crbug.com/181321. |
20 const int kMaxPendingPackets = 8; | 20 const int kMaxPendingPackets = 32; |
21 const int kWritableSignalThreshold = 0; | 21 const int kWritableSignalThreshold = 0; |
22 | 22 |
23 // IpcPacketSocket implements talk_base::AsyncPacketSocket interface | 23 // IpcPacketSocket implements talk_base::AsyncPacketSocket interface |
24 // using P2PSocketClient that works over IPC-channel. It must be used | 24 // using P2PSocketClient that works over IPC-channel. It must be used |
25 // on the thread it was created. | 25 // on the thread it was created. |
26 class IpcPacketSocket : public talk_base::AsyncPacketSocket, | 26 class IpcPacketSocket : public talk_base::AsyncPacketSocket, |
27 public P2PSocketClient::Delegate { | 27 public P2PSocketClient::Delegate { |
28 public: | 28 public: |
29 IpcPacketSocket(); | 29 IpcPacketSocket(); |
30 virtual ~IpcPacketSocket(); | 30 virtual ~IpcPacketSocket(); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 talk_base::SocketAddress crome_address; | 396 talk_base::SocketAddress crome_address; |
397 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); | 397 P2PSocketClient* socket_client = new P2PSocketClient(socket_dispatcher_); |
398 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); | 398 scoped_ptr<IpcPacketSocket> socket(new IpcPacketSocket()); |
399 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, | 399 if (!socket->Init(P2P_SOCKET_TCP_CLIENT, socket_client, local_address, |
400 remote_address)) | 400 remote_address)) |
401 return NULL; | 401 return NULL; |
402 return socket.release(); | 402 return socket.release(); |
403 } | 403 } |
404 | 404 |
405 } // namespace content | 405 } // namespace content |
OLD | NEW |