Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: remoting/protocol/pepper_transport_socket_adaptor.h

Issue 7549027: Rename PepperP2PChannel to PepperTransportSocketAdaptor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #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.
6 #define REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTOR_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "net/base/net_log.h"
14 #include "net/socket/stream_socket.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/cpp/completion_callback.h"
17
18 namespace pp {
19 class Instance;
20 class Transport_Dev;
21 } // namespace pp
22
23 namespace remoting {
24 namespace protocol {
25
26 // 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.
27 // Transport API.
28 class PepperTransportSocketAdaptor : public base::NonThreadSafe,
29 public net::StreamSocket {
30 public:
31 enum ChannelType {
32 STREAM,
33 DATAGRAM,
34 };
Wez 2011/08/02 23:13:24 If this adaptor implements net::StreamSocket, it s
Sergey Ulanov 2011/08/03 00:55:23 Done.
35
36 // 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
37 // deletion of the adapter.
Wez 2011/08/02 23:13:24 nit: adapter vs adaptor.
Sergey Ulanov 2011/08/03 00:55:23 Done.
38 class Observer {
39 public:
40 Observer() { }
41 virtual ~Observer() { }
42 virtual void OnChannelDeleted() = 0;
43 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.
44 };
45
46 PepperTransportSocketAdaptor(pp::Instance* pp_instance,
47 const std::string& name,
48 ChannelType type,
Wez 2011/08/02 23:13:24 See above.
Sergey Ulanov 2011/08/03 00:55:23 Done.
49 Observer* observer);
50 virtual ~PepperTransportSocketAdaptor();
51
52 const std::string& name() { return name_; }
53
54 // Adds candidate received from the peer.
55 void AddRemoteCandidate(const std::string& candidate);
56
57 // net::Socket interface.
58 virtual int Read(net::IOBuffer* buf, int buf_len,
59 net::CompletionCallback* callback) OVERRIDE;
60 virtual int Write(net::IOBuffer* buf, int buf_len,
61 net::CompletionCallback* callback) OVERRIDE;
62 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
63 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
64
65 // net::StreamSocket interface.
66 virtual int Connect(net::CompletionCallback* callback) OVERRIDE;
67 virtual void Disconnect() OVERRIDE;
68 virtual bool IsConnected() const OVERRIDE;
69 virtual bool IsConnectedAndIdle() const OVERRIDE;
70 virtual int GetPeerAddress(net::AddressList* address) const OVERRIDE;
71 virtual int GetLocalAddress(net::IPEndPoint* address) const OVERRIDE;
72 virtual const net::BoundNetLog& NetLog() const OVERRIDE;
73 virtual void SetSubresourceSpeculation() OVERRIDE;
74 virtual void SetOmniboxSpeculation() OVERRIDE;
75 virtual bool WasEverUsed() const OVERRIDE;
76 virtual bool UsingTCPFastOpen() const OVERRIDE;
77 virtual int64 NumBytesRead() const OVERRIDE;
78 virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE;
79
80 private:
81 // Callbacks for PPAPI calls.
82 void OnConnect(int result);
83 void OnNextAddress(int32_t result);
84 void OnRead(int32_t result);
85 void OnWrite(int32_t result);
86
87 bool ProcessCandidates();
88
89 std::string name_;
90 Observer* observer_;
91
92 scoped_ptr<pp::Transport_Dev> transport_;
93
94 net::CompletionCallback* connect_callback_;
95 bool connected_;
96
97 bool get_address_pending_;
98
99 net::CompletionCallback* read_callback_;
100 scoped_refptr<net::IOBuffer> read_buffer_;
101
102 net::CompletionCallback* write_callback_;
103 scoped_refptr<net::IOBuffer> write_buffer_;
104
105 net::BoundNetLog net_log_;
106
107 pp::CompletionCallbackFactory<PepperTransportSocketAdaptor> callback_factory_;
108
109 DISALLOW_COPY_AND_ASSIGN(PepperTransportSocketAdaptor);
110 };
111
112 } // namespace protocol
113 } // namespace remoting
114
115 #endif // REMOTING_PROTOCOL_PEPPER_TRANSPORT_SOCKET_ADAPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698