| 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 "remoting/client/plugin/pepper_packet_socket_factory.h" | 5 #include "remoting/client/plugin/pepper_packet_socket_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 case PP_ERROR_ADDRESS_IN_USE: | 79 case PP_ERROR_ADDRESS_IN_USE: |
| 80 return net::ERR_ADDRESS_IN_USE; | 80 return net::ERR_ADDRESS_IN_USE; |
| 81 default: | 81 default: |
| 82 return net::ERR_FAILED; | 82 return net::ERR_FAILED; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 class UdpPacketSocket : public rtc::AsyncPacketSocket { | 86 class UdpPacketSocket : public rtc::AsyncPacketSocket { |
| 87 public: | 87 public: |
| 88 explicit UdpPacketSocket(const pp::InstanceHandle& instance); | 88 explicit UdpPacketSocket(const pp::InstanceHandle& instance); |
| 89 virtual ~UdpPacketSocket(); | 89 ~UdpPacketSocket() override; |
| 90 | 90 |
| 91 // |min_port| and |max_port| are set to zero if the port number | 91 // |min_port| and |max_port| are set to zero if the port number |
| 92 // should be assigned by the OS. | 92 // should be assigned by the OS. |
| 93 bool Init(const rtc::SocketAddress& local_address, | 93 bool Init(const rtc::SocketAddress& local_address, |
| 94 int min_port, | 94 int min_port, |
| 95 int max_port); | 95 int max_port); |
| 96 | 96 |
| 97 // rtc::AsyncPacketSocket interface. | 97 // rtc::AsyncPacketSocket interface. |
| 98 virtual rtc::SocketAddress GetLocalAddress() const override; | 98 rtc::SocketAddress GetLocalAddress() const override; |
| 99 virtual rtc::SocketAddress GetRemoteAddress() const override; | 99 rtc::SocketAddress GetRemoteAddress() const override; |
| 100 virtual int Send(const void* data, size_t data_size, | 100 int Send(const void* data, |
| 101 const rtc::PacketOptions& options) override; | 101 size_t data_size, |
| 102 virtual int SendTo(const void* data, | 102 const rtc::PacketOptions& options) override; |
| 103 size_t data_size, | 103 int SendTo(const void* data, |
| 104 const rtc::SocketAddress& address, | 104 size_t data_size, |
| 105 const rtc::PacketOptions& options) override; | 105 const rtc::SocketAddress& address, |
| 106 virtual int Close() override; | 106 const rtc::PacketOptions& options) override; |
| 107 virtual State GetState() const override; | 107 int Close() override; |
| 108 virtual int GetOption(rtc::Socket::Option opt, int* value) override; | 108 State GetState() const override; |
| 109 virtual int SetOption(rtc::Socket::Option opt, int value) override; | 109 int GetOption(rtc::Socket::Option opt, int* value) override; |
| 110 virtual int GetError() const override; | 110 int SetOption(rtc::Socket::Option opt, int value) override; |
| 111 virtual void SetError(int error) override; | 111 int GetError() const override; |
| 112 void SetError(int error) override; |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 struct PendingPacket { | 115 struct PendingPacket { |
| 115 PendingPacket(const void* buffer, | 116 PendingPacket(const void* buffer, |
| 116 int buffer_size, | 117 int buffer_size, |
| 117 const pp::NetAddress& address); | 118 const pp::NetAddress& address); |
| 118 | 119 |
| 119 scoped_refptr<net::IOBufferWithSize> data; | 120 scoped_refptr<net::IOBufferWithSize> data; |
| 120 pp::NetAddress address; | 121 pp::NetAddress address; |
| 121 bool retried; | 122 bool retried; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 NOTREACHED(); | 437 NOTREACHED(); |
| 437 return NULL; | 438 return NULL; |
| 438 } | 439 } |
| 439 | 440 |
| 440 rtc::AsyncResolverInterface* | 441 rtc::AsyncResolverInterface* |
| 441 PepperPacketSocketFactory::CreateAsyncResolver() { | 442 PepperPacketSocketFactory::CreateAsyncResolver() { |
| 442 return new PepperAddressResolver(pp_instance_); | 443 return new PepperAddressResolver(pp_instance_); |
| 443 } | 444 } |
| 444 | 445 |
| 445 } // namespace remoting | 446 } // namespace remoting |
| OLD | NEW |