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

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

Issue 61773005: Rename WebKit namespace to blink (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
49 #include "public/platform/WebSocketHandle.h" 49 #include "public/platform/WebSocketHandle.h"
50 #include "public/platform/WebString.h" 50 #include "public/platform/WebString.h"
51 #include "public/platform/WebURL.h" 51 #include "public/platform/WebURL.h"
52 #include "public/platform/WebVector.h" 52 #include "public/platform/WebVector.h"
53 #include "weborigin/SecurityOrigin.h" 53 #include "weborigin/SecurityOrigin.h"
54 #include "wtf/ArrayBuffer.h" 54 #include "wtf/ArrayBuffer.h"
55 #include "wtf/Vector.h" 55 #include "wtf/Vector.h"
56 #include "wtf/text/WTFString.h" 56 #include "wtf/text/WTFString.h"
57 57
58 using WebKit::WebSocketHandle; 58 using blink::WebSocketHandle;
59 59
60 namespace WebCore { 60 namespace WebCore {
61 61
62 namespace { 62 namespace {
63 63
64 bool isClean(int code) 64 bool isClean(int code)
65 { 65 {
66 return code == WebSocketChannel::CloseEventCodeNormalClosure 66 return code == WebSocketChannel::CloseEventCodeNormalClosure
67 || (WebSocketChannel::CloseEventCodeMinimumUserDefined <= code 67 || (WebSocketChannel::CloseEventCodeMinimumUserDefined <= code
68 && code <= WebSocketChannel::CloseEventCodeMaximumUserDefined); 68 && code <= WebSocketChannel::CloseEventCodeMaximumUserDefined);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 void NewWebSocketChannelImpl::BlobLoader::didFail(FileError::ErrorCode errorCode ) 111 void NewWebSocketChannelImpl::BlobLoader::didFail(FileError::ErrorCode errorCode )
112 { 112 {
113 m_channel->didFailLoadingBlob(errorCode); 113 m_channel->didFailLoadingBlob(errorCode);
114 // |this| is deleted here. 114 // |this| is deleted here.
115 } 115 }
116 116
117 NewWebSocketChannelImpl::NewWebSocketChannelImpl(ExecutionContext* context, WebS ocketChannelClient* client, const String& sourceURL, unsigned lineNumber) 117 NewWebSocketChannelImpl::NewWebSocketChannelImpl(ExecutionContext* context, WebS ocketChannelClient* client, const String& sourceURL, unsigned lineNumber)
118 : ContextLifecycleObserver(context) 118 : ContextLifecycleObserver(context)
119 , m_handle(adoptPtr(WebKit::Platform::current()->createWebSocketHandle())) 119 , m_handle(adoptPtr(blink::Platform::current()->createWebSocketHandle()))
120 , m_client(client) 120 , m_client(client)
121 , m_identifier(0) 121 , m_identifier(0)
122 , m_sendingQuota(0) 122 , m_sendingQuota(0)
123 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota 123 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota
124 , m_bufferedAmount(0) 124 , m_bufferedAmount(0)
125 , m_sentSizeOfTopMessage(0) 125 , m_sentSizeOfTopMessage(0)
126 , m_sourceURLAtConnection(sourceURL) 126 , m_sourceURLAtConnection(sourceURL)
127 , m_lineNumberAtConnection(lineNumber) 127 , m_lineNumberAtConnection(lineNumber)
128 { 128 {
129 if (context->isDocument() && toDocument(context)->page()) 129 if (context->isDocument() && toDocument(context)->page())
(...skipping 12 matching lines...) Expand all
142 return; 142 return;
143 m_url = url; 143 m_url = url;
144 Vector<String> protocols; 144 Vector<String> protocols;
145 // Avoid placing an empty token in the Vector when the protocol string is 145 // Avoid placing an empty token in the Vector when the protocol string is
146 // empty. 146 // empty.
147 if (!protocol.isEmpty()) { 147 if (!protocol.isEmpty()) {
148 // Since protocol is already verified and escaped, we can simply split 148 // Since protocol is already verified and escaped, we can simply split
149 // it. 149 // it.
150 protocol.split(", ", true, protocols); 150 protocol.split(", ", true, protocols);
151 } 151 }
152 WebKit::WebVector<WebKit::WebString> webProtocols(protocols.size()); 152 blink::WebVector<blink::WebString> webProtocols(protocols.size());
153 for (size_t i = 0; i < protocols.size(); ++i) { 153 for (size_t i = 0; i < protocols.size(); ++i) {
154 webProtocols[i] = protocols[i]; 154 webProtocols[i] = protocols[i];
155 } 155 }
156 String origin = executionContext()->securityOrigin()->toString(); 156 String origin = executionContext()->securityOrigin()->toString();
157 m_handle->connect(url, webProtocols, origin, this); 157 m_handle->connect(url, webProtocols, origin, this);
158 flowControlIfNecessary(); 158 flowControlIfNecessary();
159 if (m_identifier) 159 if (m_identifier)
160 InspectorInstrumentation::didCreateWebSocket(document(), m_identifier, u rl, protocol); 160 InspectorInstrumentation::didCreateWebSocket(document(), m_identifier, u rl, protocol);
161 RefPtr<ScriptCallStack> callStack = createScriptCallStack(1, true); 161 RefPtr<ScriptCallStack> callStack = createScriptCallStack(1, true);
162 if (callStack && callStack->size()) { 162 if (callStack && callStack->size()) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 364 }
365 365
366 Document* NewWebSocketChannelImpl::document() 366 Document* NewWebSocketChannelImpl::document()
367 { 367 {
368 ASSERT(m_identifier); 368 ASSERT(m_identifier);
369 ExecutionContext* context = executionContext(); 369 ExecutionContext* context = executionContext();
370 ASSERT(context->isDocument()); 370 ASSERT(context->isDocument());
371 return toDocument(context); 371 return toDocument(context);
372 } 372 }
373 373
374 void NewWebSocketChannelImpl::didConnect(WebSocketHandle* handle, bool fail, con st WebKit::WebString& selectedProtocol, const WebKit::WebString& extensions) 374 void NewWebSocketChannelImpl::didConnect(WebSocketHandle* handle, bool fail, con st blink::WebString& selectedProtocol, const blink::WebString& extensions)
375 { 375 {
376 LOG(Network, "NewWebSocketChannelImpl %p didConnect(%p, %d, %s, %s)", this, handle, fail, selectedProtocol.utf8().data(), extensions.utf8().data()); 376 LOG(Network, "NewWebSocketChannelImpl %p didConnect(%p, %d, %s, %s)", this, handle, fail, selectedProtocol.utf8().data(), extensions.utf8().data());
377 ASSERT(m_handle); 377 ASSERT(m_handle);
378 ASSERT(handle == m_handle); 378 ASSERT(handle == m_handle);
379 ASSERT(m_client); 379 ASSERT(m_client);
380 if (fail) { 380 if (fail) {
381 failAsError("Cannot connect to " + m_url.string() + "."); 381 failAsError("Cannot connect to " + m_url.string() + ".");
382 // failAsError may delete this object. 382 // failAsError may delete this object.
383 return; 383 return;
384 } 384 }
385 // FIXME: We should have Request / Response information to be output. 385 // FIXME: We should have Request / Response information to be output.
386 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m _identifier, ""); 386 // InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m _identifier, "");
387 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document() , m_identifier, ""); 387 // InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document() , m_identifier, "");
388 388
389 m_subprotocol = selectedProtocol; 389 m_subprotocol = selectedProtocol;
390 m_extensions = extensions; 390 m_extensions = extensions;
391 m_client->didConnect(); 391 m_client->didConnect();
392 } 392 }
393 393
394 void NewWebSocketChannelImpl::didFail(WebSocketHandle* handle, const WebKit::Web String& message) 394 void NewWebSocketChannelImpl::didFail(WebSocketHandle* handle, const blink::WebS tring& message)
395 { 395 {
396 LOG(Network, "NewWebSocketChannelImpl %p didFail(%p, %s)", this, handle, mes sage.utf8().data()); 396 LOG(Network, "NewWebSocketChannelImpl %p didFail(%p, %s)", this, handle, mes sage.utf8().data());
397 // FIXME: Hande the failure correctly. 397 // FIXME: Hande the failure correctly.
398 // CloseEventCodeAbnormalClosure is the closing code for the closure 398 // CloseEventCodeAbnormalClosure is the closing code for the closure
399 // without sending or receiving a Close control frame. 399 // without sending or receiving a Close control frame.
400 didClose(handle, false, CloseEventCodeAbnormalClosure, WebKit::WebString()); 400 didClose(handle, false, CloseEventCodeAbnormalClosure, blink::WebString());
401 // |this| may be deleted. 401 // |this| may be deleted.
402 } 402 }
403 403
404 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) 404 void NewWebSocketChannelImpl::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size)
405 { 405 {
406 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size); 406 LOG(Network, "NewWebSocketChannelImpl %p didReceiveData(%p, %d, %d, (%p, %zu ))", this, handle, fin, type, data, size);
407 ASSERT(m_handle); 407 ASSERT(m_handle);
408 ASSERT(handle == m_handle); 408 ASSERT(handle == m_handle);
409 ASSERT(m_client); 409 ASSERT(m_client);
410 // Non-final frames cannot be empty. 410 // Non-final frames cannot be empty.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } else { 445 } else {
446 m_client->didReceiveMessage(message); 446 m_client->didReceiveMessage(message);
447 } 447 }
448 } else { 448 } else {
449 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); 449 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>);
450 binaryData->swap(m_receivingMessageData); 450 binaryData->swap(m_receivingMessageData);
451 m_client->didReceiveBinaryData(binaryData.release()); 451 m_client->didReceiveBinaryData(binaryData.release());
452 } 452 }
453 } 453 }
454 454
455 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, bool wasClean, u nsigned short code, const WebKit::WebString& reason) 455 void NewWebSocketChannelImpl::didClose(WebSocketHandle* handle, bool wasClean, u nsigned short code, const blink::WebString& reason)
456 { 456 {
457 // FIXME: Use |wasClean| appropriately. 457 // FIXME: Use |wasClean| appropriately.
458 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %d, %u, %s)", this, ha ndle, wasClean, code, String(reason).utf8().data()); 458 LOG(Network, "NewWebSocketChannelImpl %p didClose(%p, %d, %u, %s)", this, ha ndle, wasClean, code, String(reason).utf8().data());
459 ASSERT(m_handle); 459 ASSERT(m_handle);
460 m_handle.clear(); 460 m_handle.clear();
461 if (m_identifier) { 461 if (m_identifier) {
462 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); 462 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier);
463 m_identifier = 0; 463 m_identifier = 0;
464 } 464 }
465 465
(...skipping 27 matching lines...) Expand all
493 if (errorCode == FileError::ABORT_ERR) { 493 if (errorCode == FileError::ABORT_ERR) {
494 // The error is caused by cancel(). 494 // The error is caused by cancel().
495 return; 495 return;
496 } 496 }
497 // FIXME: Generate human-friendly reason message. 497 // FIXME: Generate human-friendly reason message.
498 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); 498 failAsError("Failed to load Blob: error code = " + String::number(errorCode) );
499 // |this| can be deleted here. 499 // |this| can be deleted here.
500 } 500 }
501 501
502 } // namespace WebCore 502 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/websockets/NewWebSocketChannelImpl.h ('k') | Source/modules/websockets/WebSocketHandshake.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698