Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 | 33 |
| 34 #include "modules/websockets/WebSocket.h" | 34 #include "modules/websockets/WebSocket.h" |
| 35 #include "modules/websockets/WebSocketHandshake.h" | 35 #include "modules/websockets/WebSocketHandshake.h" |
| 36 | 36 |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/ScriptExecutionContext.h" | 38 #include "core/dom/ScriptExecutionContext.h" |
| 39 #include "core/inspector/ScriptCallStack.h" | 39 #include "core/inspector/ScriptCallStack.h" |
| 40 #include "core/loader/CookieJar.h" | 40 #include "core/loader/CookieJar.h" |
| 41 #include "core/platform/Cookie.h" | 41 #include "core/platform/Cookie.h" |
| 42 #include "core/platform/HistogramSupport.h" | |
| 42 #include "core/platform/KURL.h" | 43 #include "core/platform/KURL.h" |
| 43 #include "core/platform/Logging.h" | 44 #include "core/platform/Logging.h" |
| 44 #include "core/platform/network/HTTPHeaderMap.h" | 45 #include "core/platform/network/HTTPHeaderMap.h" |
| 45 #include "core/platform/network/HTTPParsers.h" | 46 #include "core/platform/network/HTTPParsers.h" |
| 46 #include "weborigin/SecurityOrigin.h" | 47 #include "weborigin/SecurityOrigin.h" |
| 47 #include "wtf/CryptographicallyRandomNumber.h" | 48 #include "wtf/CryptographicallyRandomNumber.h" |
| 48 #include "wtf/MD5.h" | 49 #include "wtf/MD5.h" |
| 49 #include "wtf/SHA1.h" | 50 #include "wtf/SHA1.h" |
| 50 #include "wtf/StdLibExtras.h" | 51 #include "wtf/StdLibExtras.h" |
| 51 #include "wtf/StringExtras.h" | 52 #include "wtf/StringExtras.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 , m_secure(m_url.protocolIs("wss")) | 125 , m_secure(m_url.protocolIs("wss")) |
| 125 , m_context(context) | 126 , m_context(context) |
| 126 , m_mode(Incomplete) | 127 , m_mode(Incomplete) |
| 127 { | 128 { |
| 128 m_secWebSocketKey = generateSecWebSocketKey(); | 129 m_secWebSocketKey = generateSecWebSocketKey(); |
| 129 m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey); | 130 m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey); |
| 130 } | 131 } |
| 131 | 132 |
| 132 WebSocketHandshake::~WebSocketHandshake() | 133 WebSocketHandshake::~WebSocketHandshake() |
| 133 { | 134 { |
| 135 HistogramSupport::histogramEnumeration("WebCore.WebSocket.HandshakeResult", m_mode, WebSocketHandshake::ModeMax); | |
| 134 } | 136 } |
| 135 | 137 |
| 136 const KURL& WebSocketHandshake::url() const | 138 const KURL& WebSocketHandshake::url() const |
| 137 { | 139 { |
| 138 return m_url; | 140 return m_url; |
| 139 } | 141 } |
| 140 | 142 |
| 141 void WebSocketHandshake::setURL(const KURL& url) | 143 void WebSocketHandshake::setURL(const KURL& url) |
| 142 { | 144 { |
| 143 m_url = url.copy(); | 145 m_url = url.copy(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 const String extensionValue = m_extensionDispatcher.createHeaderValue(); | 266 const String extensionValue = m_extensionDispatcher.createHeaderValue(); |
| 265 if (extensionValue.length()) | 267 if (extensionValue.length()) |
| 266 request->addHeaderField("Sec-WebSocket-Extensions", extensionValue); | 268 request->addHeaderField("Sec-WebSocket-Extensions", extensionValue); |
| 267 | 269 |
| 268 // Add a User-Agent header. | 270 // Add a User-Agent header. |
| 269 request->addHeaderField("User-Agent", m_context->userAgent(m_context->url()) ); | 271 request->addHeaderField("User-Agent", m_context->userAgent(m_context->url()) ); |
| 270 | 272 |
| 271 return request.release(); | 273 return request.release(); |
| 272 } | 274 } |
| 273 | 275 |
| 274 void WebSocketHandshake::reset() | 276 void WebSocketHandshake::reset() |
|
yhirano
2013/05/20 09:44:02
(optional) Adding a comment (here or at the header
tyoshino (SeeGerritForStatus)
2013/05/20 09:57:13
Good catch. Done
| |
| 275 { | 277 { |
| 276 m_mode = Incomplete; | 278 m_mode = Incomplete; |
| 277 m_extensionDispatcher.reset(); | 279 m_extensionDispatcher.reset(); |
| 278 } | 280 } |
| 279 | 281 |
| 280 void WebSocketHandshake::clearScriptExecutionContext() | 282 void WebSocketHandshake::clearScriptExecutionContext() |
| 281 { | 283 { |
| 282 m_context = 0; | 284 m_context = 0; |
| 283 } | 285 } |
| 284 | 286 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 m_clientProtocol.split(String(WebSocket::subProtocolSeperator()), result ); | 547 m_clientProtocol.split(String(WebSocket::subProtocolSeperator()), result ); |
| 546 if (!result.contains(serverWebSocketProtocol)) { | 548 if (!result.contains(serverWebSocketProtocol)) { |
| 547 m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-P rotocol mismatch"; | 549 m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-P rotocol mismatch"; |
| 548 return false; | 550 return false; |
| 549 } | 551 } |
| 550 } | 552 } |
| 551 return true; | 553 return true; |
| 552 } | 554 } |
| 553 | 555 |
| 554 } // namespace WebCore | 556 } // namespace WebCore |
| OLD | NEW |