| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 // WebSocket protocol implementation in chromium. | 5 // WebSocket protocol implementation in chromium. |
| 6 // It is intended to be used for live experiment of WebSocket connectivity | 6 // It is intended to be used for live experiment of WebSocket connectivity |
| 7 // metrics. | 7 // metrics. |
| 8 // Note that it is not used for WebKit's WebSocket communication. | 8 // Note that it is not used for WebKit's WebSocket communication. |
| 9 // See third_party/WebKit/WebCore/websockets/ instead. | 9 // See third_party/WebKit/WebCore/websockets/ instead. |
| 10 | 10 |
| 11 #ifndef NET_WEBSOCKETS_WEBSOCKET_H_ | 11 #ifndef NET_WEBSOCKETS_WEBSOCKET_H_ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 }; | 67 }; |
| 68 enum ProtocolVersion { | 68 enum ProtocolVersion { |
| 69 DEFAULT_VERSION = 0, | 69 DEFAULT_VERSION = 0, |
| 70 DRAFT75 = 1, | 70 DRAFT75 = 1, |
| 71 }; | 71 }; |
| 72 class Request { | 72 class Request { |
| 73 public: | 73 public: |
| 74 Request(const GURL& url, const std::string protocol, | 74 Request(const GURL& url, const std::string protocol, |
| 75 const std::string origin, const std::string location, | 75 const std::string origin, const std::string location, |
| 76 ProtocolVersion version, | 76 ProtocolVersion version, |
| 77 URLRequestContext* context) | 77 net::URLRequestContext* context) |
| 78 : url_(url), | 78 : url_(url), |
| 79 protocol_(protocol), | 79 protocol_(protocol), |
| 80 origin_(origin), | 80 origin_(origin), |
| 81 location_(location), | 81 location_(location), |
| 82 version_(version), | 82 version_(version), |
| 83 context_(context), | 83 context_(context), |
| 84 host_resolver_(NULL), | 84 host_resolver_(NULL), |
| 85 client_socket_factory_(NULL) {} | 85 client_socket_factory_(NULL) {} |
| 86 ~Request() {} | 86 ~Request() {} |
| 87 | 87 |
| 88 const GURL& url() const { return url_; } | 88 const GURL& url() const { return url_; } |
| 89 const std::string& protocol() const { return protocol_; } | 89 const std::string& protocol() const { return protocol_; } |
| 90 const std::string& origin() const { return origin_; } | 90 const std::string& origin() const { return origin_; } |
| 91 const std::string& location() const { return location_; } | 91 const std::string& location() const { return location_; } |
| 92 ProtocolVersion version() const { return version_; } | 92 ProtocolVersion version() const { return version_; } |
| 93 URLRequestContext* context() const { return context_; } | 93 net::URLRequestContext* context() const { return context_; } |
| 94 | 94 |
| 95 // Sets an alternative HostResolver. For testing purposes only. | 95 // Sets an alternative HostResolver. For testing purposes only. |
| 96 void SetHostResolver(HostResolver* host_resolver) { | 96 void SetHostResolver(HostResolver* host_resolver) { |
| 97 host_resolver_ = host_resolver; | 97 host_resolver_ = host_resolver; |
| 98 } | 98 } |
| 99 HostResolver* host_resolver() const { return host_resolver_; } | 99 HostResolver* host_resolver() const { return host_resolver_; } |
| 100 | 100 |
| 101 // Sets an alternative ClientSocketFactory. Doesn't take ownership of | 101 // Sets an alternative ClientSocketFactory. Doesn't take ownership of |
| 102 // |factory|. For testing purposes only. | 102 // |factory|. For testing purposes only. |
| 103 void SetClientSocketFactory(ClientSocketFactory* factory) { | 103 void SetClientSocketFactory(ClientSocketFactory* factory) { |
| 104 client_socket_factory_ = factory; | 104 client_socket_factory_ = factory; |
| 105 } | 105 } |
| 106 ClientSocketFactory* client_socket_factory() const { | 106 ClientSocketFactory* client_socket_factory() const { |
| 107 return client_socket_factory_; | 107 return client_socket_factory_; |
| 108 } | 108 } |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 GURL url_; | 111 GURL url_; |
| 112 std::string protocol_; | 112 std::string protocol_; |
| 113 std::string origin_; | 113 std::string origin_; |
| 114 std::string location_; | 114 std::string location_; |
| 115 ProtocolVersion version_; | 115 ProtocolVersion version_; |
| 116 scoped_refptr<URLRequestContext> context_; | 116 scoped_refptr<net::URLRequestContext> context_; |
| 117 | 117 |
| 118 HostResolver* host_resolver_; | 118 HostResolver* host_resolver_; |
| 119 ClientSocketFactory* client_socket_factory_; | 119 ClientSocketFactory* client_socket_factory_; |
| 120 | 120 |
| 121 DISALLOW_COPY_AND_ASSIGN(Request); | 121 DISALLOW_COPY_AND_ASSIGN(Request); |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 // Constructs new WebSocket. | 124 // Constructs new WebSocket. |
| 125 // It takes ownership of |req|. | 125 // It takes ownership of |req|. |
| 126 // |delegate| must be alive while this object is alive. | 126 // |delegate| must be alive while this object is alive. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // |closing_handshake_timeout_|. | 223 // |closing_handshake_timeout_|. |
| 224 CancelableTask* force_close_task_; | 224 CancelableTask* force_close_task_; |
| 225 int64 closing_handshake_timeout_; | 225 int64 closing_handshake_timeout_; |
| 226 | 226 |
| 227 DISALLOW_COPY_AND_ASSIGN(WebSocket); | 227 DISALLOW_COPY_AND_ASSIGN(WebSocket); |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 } // namespace net | 230 } // namespace net |
| 231 | 231 |
| 232 #endif // NET_WEBSOCKETS_WEBSOCKET_H_ | 232 #endif // NET_WEBSOCKETS_WEBSOCKET_H_ |
| OLD | NEW |