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

Unified Diff: content/browser/websockets/websocket_impl.cc

Issue 2267233002: Change WebSocketChannel to pass data via IOBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make it const char* Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/websockets/websocket_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/websockets/websocket_impl.cc
diff --git a/content/browser/websockets/websocket_impl.cc b/content/browser/websockets/websocket_impl.cc
index 28bbd8c571e6c90faa07607b297e30832a5d509b..6ea179da37116fb599c2e530ba171ee56b5bfe87 100644
--- a/content/browser/websockets/websocket_impl.cc
+++ b/content/browser/websockets/websocket_impl.cc
@@ -24,6 +24,7 @@
#include "content/browser/ssl/ssl_manager.h"
#include "content/public/browser/storage_partition.h"
#include "ipc/ipc_message.h"
+#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
@@ -93,7 +94,8 @@ class WebSocketImpl::WebSocketEventHandler final
const std::string& extensions) override;
ChannelState OnDataFrame(bool fin,
WebSocketMessageType type,
- const std::vector<char>& data) override;
+ scoped_refptr<net::IOBuffer> buffer,
+ size_t buffer_size) override;
ChannelState OnClosingHandshake() override;
ChannelState OnFlowControl(int64_t quota) override;
ChannelState OnDropChannel(bool was_clean,
@@ -167,15 +169,19 @@ ChannelState WebSocketImpl::WebSocketEventHandler::OnAddChannelResponse(
ChannelState WebSocketImpl::WebSocketEventHandler::OnDataFrame(
bool fin,
net::WebSocketFrameHeader::OpCode type,
- const std::vector<char>& data) {
+ scoped_refptr<net::IOBuffer> buffer,
+ size_t buffer_size) {
DVLOG(3) << "WebSocketEventHandler::OnDataFrame @"
<< reinterpret_cast<void*>(this)
<< " fin=" << fin
- << " type=" << type << " data is " << data.size() << " bytes";
+ << " type=" << type << " data is " << buffer_size << " bytes";
// TODO(darin): Avoid this copy.
- std::vector<uint8_t> data_to_pass(data.size());
- std::copy(data.begin(), data.end(), data_to_pass.begin());
+ std::vector<uint8_t> data_to_pass(buffer_size);
+ if (buffer_size > 0) {
+ std::copy(buffer->data(), buffer->data() + buffer_size,
+ data_to_pass.begin());
+ }
impl_->client_->OnDataFrame(fin, OpCodeToMessageType(type), data_to_pass);
@@ -435,10 +441,11 @@ void WebSocketImpl::SendFrame(bool fin,
}
// TODO(darin): Avoid this copy.
- std::vector<char> data_to_pass(data.size());
- std::copy(data.begin(), data.end(), data_to_pass.begin());
+ scoped_refptr<net::IOBuffer> data_to_pass(new net::IOBuffer(data.size()));
+ std::copy(data.begin(), data.end(), data_to_pass->data());
- channel_->SendFrame(fin, MessageTypeToOpCode(type), data_to_pass);
+ channel_->SendFrame(fin, MessageTypeToOpCode(type), std::move(data_to_pass),
+ data.size());
}
void WebSocketImpl::SendFlowControl(int64_t quota) {
« no previous file with comments | « no previous file | net/websockets/websocket_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698