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 #ifndef CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // kNoSocketId, there is no SocketStreamHost. Each SocketStreamHost has | 27 // kNoSocketId, there is no SocketStreamHost. Each SocketStreamHost has |
28 // SocketStream to manage bi-directional communication over socket stream. The | 28 // SocketStream to manage bi-directional communication over socket stream. The |
29 // lifetime of an instance of this class is completely controlled by the | 29 // lifetime of an instance of this class is completely controlled by the |
30 // SocketStreamDispatcherHost. | 30 // SocketStreamDispatcherHost. |
31 class SocketStreamHost : public SSLErrorHandler::Delegate { | 31 class SocketStreamHost : public SSLErrorHandler::Delegate { |
32 public: | 32 public: |
33 SocketStreamHost(net::SocketStream::Delegate* delegate, | 33 SocketStreamHost(net::SocketStream::Delegate* delegate, |
34 int child_id, | 34 int child_id, |
35 int render_frame_id, | 35 int render_frame_id, |
36 int socket_id); | 36 int socket_id); |
37 virtual ~SocketStreamHost(); | 37 ~SocketStreamHost() override; |
38 | 38 |
39 // Gets socket_id associated with |socket|. | 39 // Gets socket_id associated with |socket|. |
40 static int SocketIdFromSocketStream(const net::SocketStream* socket); | 40 static int SocketIdFromSocketStream(const net::SocketStream* socket); |
41 | 41 |
42 int render_frame_id() const { return render_frame_id_; } | 42 int render_frame_id() const { return render_frame_id_; } |
43 int socket_id() const { return socket_id_; } | 43 int socket_id() const { return socket_id_; } |
44 | 44 |
45 // Starts to open connection to |url|. | 45 // Starts to open connection to |url|. |
46 void Connect(const GURL& url, net::URLRequestContext* request_context); | 46 void Connect(const GURL& url, net::URLRequestContext* request_context); |
47 | 47 |
48 // Sends |data| over the socket stream. | 48 // Sends |data| over the socket stream. |
49 // socket stream must be open to send data. | 49 // socket stream must be open to send data. |
50 // Returns true if the data is put in transmit buffer in socket stream. | 50 // Returns true if the data is put in transmit buffer in socket stream. |
51 // Returns false otherwise (transmit buffer exceeds limit, or socket | 51 // Returns false otherwise (transmit buffer exceeds limit, or socket |
52 // stream is closed). | 52 // stream is closed). |
53 bool SendData(const std::vector<char>& data); | 53 bool SendData(const std::vector<char>& data); |
54 | 54 |
55 // Closes the socket stream. | 55 // Closes the socket stream. |
56 void Close(); | 56 void Close(); |
57 | 57 |
58 base::WeakPtr<SSLErrorHandler::Delegate> AsSSLErrorHandlerDelegate(); | 58 base::WeakPtr<SSLErrorHandler::Delegate> AsSSLErrorHandlerDelegate(); |
59 | 59 |
60 // SSLErrorHandler::Delegate methods: | 60 // SSLErrorHandler::Delegate methods: |
61 virtual void CancelSSLRequest(int error, | 61 void CancelSSLRequest(int error, const net::SSLInfo* ssl_info) override; |
62 const net::SSLInfo* ssl_info) override; | 62 void ContinueSSLRequest() override; |
63 virtual void ContinueSSLRequest() override; | |
64 | 63 |
65 private: | 64 private: |
66 net::SocketStream::Delegate* delegate_; | 65 net::SocketStream::Delegate* delegate_; |
67 int child_id_; | 66 int child_id_; |
68 int render_frame_id_; | 67 int render_frame_id_; |
69 int socket_id_; | 68 int socket_id_; |
70 | 69 |
71 scoped_refptr<net::SocketStreamJob> job_; | 70 scoped_refptr<net::SocketStreamJob> job_; |
72 | 71 |
73 base::WeakPtrFactory<SocketStreamHost> weak_ptr_factory_; | 72 base::WeakPtrFactory<SocketStreamHost> weak_ptr_factory_; |
74 | 73 |
75 DISALLOW_COPY_AND_ASSIGN(SocketStreamHost); | 74 DISALLOW_COPY_AND_ASSIGN(SocketStreamHost); |
76 }; | 75 }; |
77 | 76 |
78 } // namespace content | 77 } // namespace content |
79 | 78 |
80 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ | 79 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ |
OLD | NEW |