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

Side by Side Diff: Source/modules/websockets/WebSocketHandshake.cpp

Issue 49093004: Move more arrays of strings to shareable memory (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 1 month 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
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 static String generateSecWebSocketKey() 115 static String generateSecWebSocketKey()
116 { 116 {
117 static const size_t nonceSize = 16; 117 static const size_t nonceSize = 16;
118 unsigned char key[nonceSize]; 118 unsigned char key[nonceSize];
119 cryptographicallyRandomValues(key, nonceSize); 119 cryptographicallyRandomValues(key, nonceSize);
120 return base64Encode(reinterpret_cast<char*>(key), nonceSize); 120 return base64Encode(reinterpret_cast<char*>(key), nonceSize);
121 } 121 }
122 122
123 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket Key) 123 String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocket Key)
124 { 124 {
125 static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC 85B11"; 125 static const char webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11 ";
126 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S HA1.h. 126 static const size_t sha1HashSize = 20; // FIXME: This should be defined in S HA1.h.
127 SHA1 sha1; 127 SHA1 sha1;
128 CString keyData = secWebSocketKey.ascii(); 128 CString keyData = secWebSocketKey.ascii();
129 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng th()); 129 sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.leng th());
130 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web SocketKeyGUID)); 130 sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(web SocketKeyGUID));
131 Vector<uint8_t, sha1HashSize> hash; 131 Vector<uint8_t, sha1HashSize> hash;
132 sha1.computeHash(hash); 132 sha1.computeHash(hash);
133 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize ); 133 return base64Encode(reinterpret_cast<const char*>(hash.data()), sha1HashSize );
134 } 134 }
135 135
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 583 }
584 if (!match) { 584 if (!match) {
585 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec- WebSocket-Protocol' header but no response is received"); 585 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec- WebSocket-Protocol' header but no response is received");
586 return false; 586 return false;
587 } 587 }
588 } 588 }
589 return true; 589 return true;
590 } 590 }
591 591
592 } // namespace WebCore 592 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocketDeflater.cpp ('k') | Source/platform/text/TextBreakIteratorICU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698