Index: remoting/protocol/pepper_transport_socket_adaptor.h |
diff --git a/remoting/protocol/pepper_transport_socket_adaptor.h b/remoting/protocol/pepper_transport_socket_adaptor.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d17583f0e2f7faf8cd636a9a1b7e8900e33c091f |
--- /dev/null |
+++ b/remoting/protocol/pepper_transport_socket_adaptor.h |
@@ -0,0 +1,115 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTOR_H_ |
Wez
2011/08/02 23:13:24
nit: adapter seems to be the more common spelling
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+#define REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTOR_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/threading/non_thread_safe.h" |
+#include "net/base/net_log.h" |
+#include "net/socket/stream_socket.h" |
+#include "ppapi/c/pp_stdint.h" |
+#include "ppapi/cpp/completion_callback.h" |
+ |
+namespace pp { |
+class Instance; |
+class Transport_Dev; |
+} // namespace pp |
+ |
+namespace remoting { |
+namespace protocol { |
+ |
+// This class implements net::StreamSocket interface the Pepper P2P |
Wez
2011/08/02 23:13:24
nit: Couple of missing words from this comment.
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+// Transport API. |
+class PepperTransportSocketAdaptor : public base::NonThreadSafe, |
+ public net::StreamSocket { |
+ public: |
+ enum ChannelType { |
+ STREAM, |
+ DATAGRAM, |
+ }; |
Wez
2011/08/02 23:13:24
If this adaptor implements net::StreamSocket, it s
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+ |
+ // Observer is used to notify about new outgoing candidates and |
Wez
2011/08/02 23:13:24
nit: They're "local" candidates, I think, not nece
Sergey Ulanov
2011/08/03 00:55:23
they are "outgoing" because they need to be sent t
|
+ // deletion of the adapter. |
Wez
2011/08/02 23:13:24
nit: adapter vs adaptor.
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+ class Observer { |
+ public: |
+ Observer() { } |
+ virtual ~Observer() { } |
+ virtual void OnChannelDeleted() = 0; |
+ virtual void OnChannelNewCandidate(const std::string& candidate) = 0; |
Wez
2011/08/02 23:13:24
nit: NewCandidate->NewLocalCandidate?
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+ }; |
+ |
+ PepperTransportSocketAdaptor(pp::Instance* pp_instance, |
+ const std::string& name, |
+ ChannelType type, |
Wez
2011/08/02 23:13:24
See above.
Sergey Ulanov
2011/08/03 00:55:23
Done.
|
+ Observer* observer); |
+ virtual ~PepperTransportSocketAdaptor(); |
+ |
+ const std::string& name() { return name_; } |
+ |
+ // Adds candidate received from the peer. |
+ void AddRemoteCandidate(const std::string& candidate); |
+ |
+ // net::Socket interface. |
+ virtual int Read(net::IOBuffer* buf, int buf_len, |
+ net::CompletionCallback* callback) OVERRIDE; |
+ virtual int Write(net::IOBuffer* buf, int buf_len, |
+ net::CompletionCallback* callback) OVERRIDE; |
+ virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; |
+ virtual bool SetSendBufferSize(int32 size) OVERRIDE; |
+ |
+ // net::StreamSocket interface. |
+ virtual int Connect(net::CompletionCallback* callback) OVERRIDE; |
+ virtual void Disconnect() OVERRIDE; |
+ virtual bool IsConnected() const OVERRIDE; |
+ virtual bool IsConnectedAndIdle() const OVERRIDE; |
+ virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE; |
+ virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE; |
+ virtual const net::BoundNetLog& NetLog() const OVERRIDE; |
+ virtual void SetSubresourceSpeculation() OVERRIDE; |
+ virtual void SetOmniboxSpeculation() OVERRIDE; |
+ virtual bool WasEverUsed() const OVERRIDE; |
+ virtual bool UsingTCPFastOpen() const OVERRIDE; |
+ virtual int64 NumBytesRead() const OVERRIDE; |
+ virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; |
+ |
+ private: |
+ // Callbacks for PPAPI calls. |
+ void OnConnect(int result); |
+ void OnNextAddress(int32_t result); |
+ void OnRead(int32_t result); |
+ void OnWrite(int32_t result); |
+ |
+ bool ProcessCandidates(); |
+ |
+ std::string name_; |
+ Observer* observer_; |
+ |
+ scoped_ptr<pp::Transport_Dev> transport_; |
+ |
+ net::CompletionCallback* connect_callback_; |
+ bool connected_; |
+ |
+ bool get_address_pending_; |
+ |
+ net::CompletionCallback* read_callback_; |
+ scoped_refptr<net::IOBuffer> read_buffer_; |
+ |
+ net::CompletionCallback* write_callback_; |
+ scoped_refptr<net::IOBuffer> write_buffer_; |
+ |
+ net::BoundNetLog net_log_; |
+ |
+ pp::CompletionCallbackFactory<PepperTransportSocketAdaptor> callback_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PepperTransportSocketAdaptor); |
+}; |
+ |
+} // namespace protocol |
+} // namespace remoting |
+ |
+#endif // REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTOR_H_ |