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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 2003253002: [Devtools] Allow User-Agent header override for Websockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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) 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // it. 175 // it.
176 protocol.split(", ", true, protocols); 176 protocol.split(", ", true, protocols);
177 } 177 }
178 WebVector<WebString> webProtocols(protocols.size()); 178 WebVector<WebString> webProtocols(protocols.size());
179 for (size_t i = 0; i < protocols.size(); ++i) { 179 for (size_t i = 0; i < protocols.size(); ++i) {
180 webProtocols[i] = protocols[i]; 180 webProtocols[i] = protocols[i];
181 } 181 }
182 182
183 if (document()->frame()) 183 if (document()->frame())
184 document()->frame()->loader().client()->dispatchWillOpenWebSocket(m_hand le.get()); 184 document()->frame()->loader().client()->dispatchWillOpenWebSocket(m_hand le.get());
185 m_handle->connect(url, webProtocols, WebSecurityOrigin(getExecutionContext() ->getSecurityOrigin()), this); 185
186 m_handle->connect(url, webProtocols, WebSecurityOrigin(getExecutionContext() ->getSecurityOrigin()), additionalHeaders(), this);
186 187
187 flowControlIfNecessary(); 188 flowControlIfNecessary();
188 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketCreate", TRACE_EVENT_SCO PE_THREAD, "data", InspectorWebSocketCreateEvent::data(document(), m_identifier, url, protocol)); 189 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketCreate", TRACE_EVENT_SCO PE_THREAD, "data", InspectorWebSocketCreateEvent::data(document(), m_identifier, url, protocol));
189 InspectorInstrumentation::didCreateWebSocket(document(), m_identifier, url, protocol); 190 InspectorInstrumentation::didCreateWebSocket(document(), m_identifier, url, protocol);
190 return true; 191 return true;
191 } 192 }
192 193
193 void DocumentWebSocketChannel::send(const CString& message) 194 void DocumentWebSocketChannel::send(const CString& message)
194 { 195 {
195 WTF_LOG(Network, "DocumentWebSocketChannel %p sendText(%s)", this, message.d ata()); 196 WTF_LOG(Network, "DocumentWebSocketChannel %p sendText(%s)", this, message.d ata());
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 m_blobLoader.clear(); 570 m_blobLoader.clear();
570 if (errorCode == FileError::ABORT_ERR) { 571 if (errorCode == FileError::ABORT_ERR) {
571 // The error is caused by cancel(). 572 // The error is caused by cancel().
572 return; 573 return;
573 } 574 }
574 // FIXME: Generate human-friendly reason message. 575 // FIXME: Generate human-friendly reason message.
575 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); 576 failAsError("Failed to load Blob: error code = " + String::number(errorCode) );
576 // |this| can be deleted here. 577 // |this| can be deleted here.
577 } 578 }
578 579
580 String DocumentWebSocketChannel::additionalHeaders()
581 {
582 StringBuilder headers;
583 headers.append(HTTPNames::User_Agent);
584 headers.append(':');
585 headers.append(document()->userAgent());
586 return headers.toString();
587 }
588
579 DEFINE_TRACE(DocumentWebSocketChannel) 589 DEFINE_TRACE(DocumentWebSocketChannel)
580 { 590 {
581 visitor->trace(m_blobLoader); 591 visitor->trace(m_blobLoader);
582 visitor->trace(m_messages); 592 visitor->trace(m_messages);
583 visitor->trace(m_client); 593 visitor->trace(m_client);
584 WebSocketChannel::trace(visitor); 594 WebSocketChannel::trace(visitor);
585 ContextLifecycleObserver::trace(visitor); 595 ContextLifecycleObserver::trace(visitor);
586 } 596 }
587 597
588 } // namespace blink 598 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698