Chromium Code Reviews| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 // Host of SocketStreamHandle. | 21 // Host of SocketStreamHandle. |
| 22 // Each SocketStreamHandle will have an unique socket_id assigned by | 22 // Each SocketStreamHandle will have an unique socket_id assigned by |
| 23 // SocketStreamHost constructor. If socket id is content::kNoSocketId, | 23 // SocketStreamHost constructor. If socket id is content::kNoSocketId, |
| 24 // there is no SocketStreamHost. | 24 // there is no SocketStreamHost. |
| 25 // Each SocketStreamHost has SocketStream to manage bi-directional | 25 // Each SocketStreamHost has SocketStream to manage bi-directional |
| 26 // communication over socket stream. | 26 // communication over socket stream. |
| 27 // The lifetime of an instance of this class is completely controlled by the | 27 // The lifetime of an instance of this class is completely controlled by the |
| 28 // SocketStreamDispatcherHost. | 28 // SocketStreamDispatcherHost. |
| 29 class SocketStreamHost { | 29 class SocketStreamHost { |
| 30 public: | 30 public: |
| 31 SocketStreamHost(net::SocketStream::Delegate* delegate, int socket_id); | 31 SocketStreamHost(net::SocketStream::Delegate* delegate, |
| 32 int routing_id, | |
|
wtc
2012/03/19 23:21:03
Why don't you call this render_view_id? Is it bec
Takashi Toyoshima
2012/03/20 00:18:03
No. render_view_id is the only one as routing_id h
| |
| 33 int socket_id); | |
| 32 ~SocketStreamHost(); | 34 ~SocketStreamHost(); |
| 33 | 35 |
| 34 // Gets socket_id associated with |socket|. | 36 // Gets socket_id associated with |socket|. |
| 35 static int SocketIdFromSocketStream(net::SocketStream* socket); | 37 static int SocketIdFromSocketStream(net::SocketStream* socket); |
| 36 | 38 |
| 39 int routing_id() const { return routing_id_; } | |
| 37 int socket_id() const { return socket_id_; } | 40 int socket_id() const { return socket_id_; } |
| 38 | 41 |
| 39 // Starts to open connection to |url|. | 42 // Starts to open connection to |url|. |
| 40 void Connect(const GURL& url, net::URLRequestContext* request_context); | 43 void Connect(const GURL& url, net::URLRequestContext* request_context); |
| 41 | 44 |
| 42 // Sends |data| over the socket stream. | 45 // Sends |data| over the socket stream. |
| 43 // socket stream must be open to send data. | 46 // socket stream must be open to send data. |
| 44 // Returns true if the data is put in transmit buffer in socket stream. | 47 // Returns true if the data is put in transmit buffer in socket stream. |
| 45 // Returns false otherwise (transmit buffer exceeds limit, or socket | 48 // Returns false otherwise (transmit buffer exceeds limit, or socket |
| 46 // stream is closed). | 49 // stream is closed). |
| 47 bool SendData(const std::vector<char>& data); | 50 bool SendData(const std::vector<char>& data); |
| 48 | 51 |
| 49 // Closes the socket stream. | 52 // Closes the socket stream. |
| 50 void Close(); | 53 void Close(); |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 net::SocketStream::Delegate* delegate_; | 56 net::SocketStream::Delegate* delegate_; |
| 57 int routing_id_; | |
| 54 int socket_id_; | 58 int socket_id_; |
| 55 | 59 |
| 56 scoped_refptr<net::SocketStreamJob> socket_; | 60 scoped_refptr<net::SocketStreamJob> socket_; |
| 57 | 61 |
| 58 DISALLOW_COPY_AND_ASSIGN(SocketStreamHost); | 62 DISALLOW_COPY_AND_ASSIGN(SocketStreamHost); |
| 59 }; | 63 }; |
| 60 | 64 |
| 61 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ | 65 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_HOST_H_ |
| OLD | NEW |