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

Side by Side Diff: content/browser/renderer_host/websocket_host.cc

Issue 1461283002: [DO NOT COMMIT] mojo datapipe performance measurement Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
« no previous file with comments | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/websocket_host.h" 5 #include "content/browser/renderer_host/websocket_host.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 WebSocketHost::WebSocketHost(int routing_id, 364 WebSocketHost::WebSocketHost(int routing_id,
365 WebSocketDispatcherHost* dispatcher, 365 WebSocketDispatcherHost* dispatcher,
366 net::URLRequestContext* url_request_context, 366 net::URLRequestContext* url_request_context,
367 base::TimeDelta delay) 367 base::TimeDelta delay)
368 : dispatcher_(dispatcher), 368 : dispatcher_(dispatcher),
369 url_request_context_(url_request_context), 369 url_request_context_(url_request_context),
370 routing_id_(routing_id), 370 routing_id_(routing_id),
371 delay_(delay), 371 delay_(delay),
372 pending_flow_control_quota_(0), 372 pending_flow_control_quota_(0),
373 handshake_succeeded_(false), 373 handshake_succeeded_(false),
374 loader_test_num_read_bytes_(0),
374 weak_ptr_factory_(this) { 375 weak_ptr_factory_(this) {
375 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id; 376 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id;
376 } 377 }
377 378
378 WebSocketHost::~WebSocketHost() {} 379 WebSocketHost::~WebSocketHost() {}
379 380
380 void WebSocketHost::GoAway() { 381 void WebSocketHost::GoAway() {
381 OnDropChannel(false, static_cast<uint16_t>(net::kWebSocketErrorGoingAway), 382 OnDropChannel(false, static_cast<uint16_t>(net::kWebSocketErrorGoingAway),
382 ""); 383 "");
383 } 384 }
384 385
385 bool WebSocketHost::OnMessageReceived(const IPC::Message& message) { 386 bool WebSocketHost::OnMessageReceived(const IPC::Message& message) {
386 bool handled = true; 387 bool handled = true;
387 IPC_BEGIN_MESSAGE_MAP(WebSocketHost, message) 388 IPC_BEGIN_MESSAGE_MAP(WebSocketHost, message)
388 IPC_MESSAGE_HANDLER(WebSocketHostMsg_AddChannelRequest, OnAddChannelRequest) 389 IPC_MESSAGE_HANDLER(WebSocketHostMsg_AddChannelRequest, OnAddChannelRequest)
389 IPC_MESSAGE_HANDLER(WebSocketHostMsg_SendBlob, OnSendBlob) 390 IPC_MESSAGE_HANDLER(WebSocketHostMsg_SendBlob, OnSendBlob)
390 IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, OnSendFrame) 391 IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, OnSendFrame)
391 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl) 392 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl)
392 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel) 393 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel)
394 IPC_MESSAGE_HANDLER(WebSocketHostMsg_LoaderTransferTest_Setup,
395 OnLoaderTransferTest_Setup)
396 IPC_MESSAGE_HANDLER(WebSocketHostMsg_LoaderTransferTest_Send,
397 OnLoaderTransferTest_Send)
398 IPC_MESSAGE_HANDLER(WebSocketHostMsg_LoaderTransferTest_Close,
399 OnLoaderTransferTest_Close)
393 IPC_MESSAGE_UNHANDLED(handled = false) 400 IPC_MESSAGE_UNHANDLED(handled = false)
394 IPC_END_MESSAGE_MAP() 401 IPC_END_MESSAGE_MAP()
395 return handled; 402 return handled;
396 } 403 }
397 404
398 void WebSocketHost::OnAddChannelRequest( 405 void WebSocketHost::OnAddChannelRequest(
399 const GURL& socket_url, 406 const GURL& socket_url,
400 const std::vector<std::string>& requested_protocols, 407 const std::vector<std::string>& requested_protocols,
401 const url::Origin& origin, 408 const url::Origin& origin,
402 int render_frame_id) { 409 int render_frame_id) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 580
574 default: 581 default:
575 ignore_result(dispatcher_->NotifyFailure( 582 ignore_result(dispatcher_->NotifyFailure(
576 routing_id_, 583 routing_id_,
577 "Failed to load Blob: error code = " + net::ErrorToString(result))); 584 "Failed to load Blob: error code = " + net::ErrorToString(result)));
578 // |this| is destroyed here. 585 // |this| is destroyed here.
579 return; 586 return;
580 } 587 }
581 } 588 }
582 589
590 void WebSocketHost::OnLoaderTransferTest_Setup(int buffer_size) {
591 // fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
592 loader_test_num_read_bytes_ = 0;
593 base::SharedMemoryHandle handle;
594 shared_memory_.reset(new base::SharedMemory);
595 shared_memory_->CreateAndMapAnonymous(buffer_size);
596 shared_memory_->ShareToProcess(dispatcher_->PeerHandle(), &handle);
597 dispatcher_->SendLoaderTransferTest_SetDataBuffer(routing_id_, handle);
598 }
599
600 void WebSocketHost::OnLoaderTransferTest_Send(int offset, int size) {
601 // fprintf(stderr, "%s offset = %d, size = %d\n", __PRETTY_FUNCTION__, offset, size);
602 loader_test_num_read_bytes_ += size;
603 dispatcher_->SendLoaderTransferTest_Ack(routing_id_);
604
605 // const char* p = static_cast<const char*>(shared_memory_->memory()) + offset ;
606 // fprintf(stderr, "*p = 0x%02x\n", *p);
607 }
608
609 void WebSocketHost::OnLoaderTransferTest_Close() {
610 // fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
611 shared_memory_ = nullptr;
612 dispatcher_->SendLoaderTransferTest_Done(routing_id_);
613 fprintf(stderr, "%s done: read %zu bytes\n", __PRETTY_FUNCTION__,
614 loader_test_num_read_bytes_);
615 }
616
617
583 } // namespace content 618 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698