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

Side by Side Diff: jingle/glue/channel_socket_adapter.h

Issue 9433027: Delete Session and SessionManager object synchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add tests Created 8 years, 10 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
« no previous file with comments | « no previous file | jingle/glue/channel_socket_adapter.cc » ('j') | jingle/glue/pseudotcp_adapter.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_ 5 #ifndef JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_
6 #define JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_ 6 #define JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "net/socket/socket.h" 10 #include "net/socket/socket.h"
(...skipping 11 matching lines...) Expand all
22 // TransportChannelSocketAdapter implements net::Socket interface on 22 // TransportChannelSocketAdapter implements net::Socket interface on
23 // top of libjingle's TransportChannel. It is used by 23 // top of libjingle's TransportChannel. It is used by
24 // JingleChromotocolConnection to provide net::Socket interface for channels. 24 // JingleChromotocolConnection to provide net::Socket interface for channels.
25 class TransportChannelSocketAdapter : public net::Socket, 25 class TransportChannelSocketAdapter : public net::Socket,
26 public sigslot::has_slots<> { 26 public sigslot::has_slots<> {
27 public: 27 public:
28 // TransportChannel object is always owned by the corresponding session. 28 // TransportChannel object is always owned by the corresponding session.
29 explicit TransportChannelSocketAdapter(cricket::TransportChannel* channel); 29 explicit TransportChannelSocketAdapter(cricket::TransportChannel* channel);
30 virtual ~TransportChannelSocketAdapter(); 30 virtual ~TransportChannelSocketAdapter();
31 31
32 // Sets callback that should be called when the adapter is being
33 // destroyed. The callback is not allowed to touch the adapter, but
34 // can do anything else, e.g. destroy the TransportChannel.
35 void SetOnDestroyedCallback(const base::Closure& callback);
36
37 // Closes the stream. |error_code| specifies error code that will 32 // Closes the stream. |error_code| specifies error code that will
38 // be returned by Read() and Write() after the stream is closed. 33 // be returned by Read() and Write() after the stream is closed.
39 // Must be called before the session and the channel are destroyed. 34 // Must be called before the session and the channel are destroyed.
40 void Close(int error_code); 35 void Close(int error_code);
41 36
42 // Socket implementation. 37 // Socket implementation.
43 virtual int Read(net::IOBuffer* buf, int buf_len, 38 virtual int Read(net::IOBuffer* buf, int buf_len,
44 const net::CompletionCallback& callback) OVERRIDE; 39 const net::CompletionCallback& callback) OVERRIDE;
45 virtual int Write(net::IOBuffer* buf, int buf_len, 40 virtual int Write(net::IOBuffer* buf, int buf_len,
46 const net::CompletionCallback& callback) OVERRIDE; 41 const net::CompletionCallback& callback) OVERRIDE;
47 42
48 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; 43 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
49 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 44 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
50 45
51 private: 46 private:
52 void OnNewPacket(cricket::TransportChannel* channel, 47 void OnNewPacket(cricket::TransportChannel* channel,
53 const char* data, size_t data_size); 48 const char* data, size_t data_size);
54 void OnWritableState(cricket::TransportChannel* channel); 49 void OnWritableState(cricket::TransportChannel* channel);
55 void OnChannelDestroyed(cricket::TransportChannel* channel); 50 void OnChannelDestroyed(cricket::TransportChannel* channel);
56 51
57 MessageLoop* message_loop_; 52 MessageLoop* message_loop_;
58 53
59 cricket::TransportChannel* channel_; 54 cricket::TransportChannel* channel_;
60 55
61 base::Closure destruction_callback_;
62
63 net::CompletionCallback read_callback_; 56 net::CompletionCallback read_callback_;
64 scoped_refptr<net::IOBuffer> read_buffer_; 57 scoped_refptr<net::IOBuffer> read_buffer_;
65 int read_buffer_size_; 58 int read_buffer_size_;
66 59
67 net::CompletionCallback write_callback_; 60 net::CompletionCallback write_callback_;
68 scoped_refptr<net::IOBuffer> write_buffer_; 61 scoped_refptr<net::IOBuffer> write_buffer_;
69 int write_buffer_size_; 62 int write_buffer_size_;
70 63
71 int closed_error_code_; 64 int closed_error_code_;
72 65
73 DISALLOW_COPY_AND_ASSIGN(TransportChannelSocketAdapter); 66 DISALLOW_COPY_AND_ASSIGN(TransportChannelSocketAdapter);
74 }; 67 };
75 68
76 } // namespace jingle_glue 69 } // namespace jingle_glue
77 70
78 #endif // JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_ 71 #endif // JINGLE_GLUE_CHANNEL_SOCKET_ADAPTER_H_
OLDNEW
« no previous file with comments | « no previous file | jingle/glue/channel_socket_adapter.cc » ('j') | jingle/glue/pseudotcp_adapter.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698