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

Side by Side Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 | « net/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_basic_stream.cc » ('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 "net/websockets/websocket_basic_handshake_stream.h" 5 #include "net/websockets/websocket_basic_handshake_stream.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/base64.h" 15 #include "base/base64.h"
15 #include "base/bind.h" 16 #include "base/bind.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/containers/hash_tables.h" 18 #include "base/containers/hash_tables.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
20 #include "base/metrics/sparse_histogram.h" 21 #include "base/metrics/sparse_histogram.h"
21 #include "base/stl_util.h" 22 #include "base/stl_util.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 requested_sub_protocols_, 351 requested_sub_protocols_,
351 &enriched_headers); 352 &enriched_headers);
352 353
353 handshake_challenge_response_ = 354 handshake_challenge_response_ =
354 ComputeSecWebSocketAccept(handshake_challenge); 355 ComputeSecWebSocketAccept(handshake_challenge);
355 356
356 DCHECK(connect_delegate_); 357 DCHECK(connect_delegate_);
357 scoped_ptr<WebSocketHandshakeRequestInfo> request( 358 scoped_ptr<WebSocketHandshakeRequestInfo> request(
358 new WebSocketHandshakeRequestInfo(url_, base::Time::Now())); 359 new WebSocketHandshakeRequestInfo(url_, base::Time::Now()));
359 request->headers.CopyFrom(enriched_headers); 360 request->headers.CopyFrom(enriched_headers);
360 connect_delegate_->OnStartOpeningHandshake(request.Pass()); 361 connect_delegate_->OnStartOpeningHandshake(std::move(request));
361 362
362 return parser()->SendRequest( 363 return parser()->SendRequest(
363 state_.GenerateRequestLine(), enriched_headers, response, callback); 364 state_.GenerateRequestLine(), enriched_headers, response, callback);
364 } 365 }
365 366
366 int WebSocketBasicHandshakeStream::ReadResponseHeaders( 367 int WebSocketBasicHandshakeStream::ReadResponseHeaders(
367 const CompletionCallback& callback) { 368 const CompletionCallback& callback) {
368 // HttpStreamParser uses a weak pointer when reading from the 369 // HttpStreamParser uses a weak pointer when reading from the
369 // socket, so it won't be called back after being destroyed. The 370 // socket, so it won't be called back after being destroyed. The
370 // HttpStreamParser is owned by HttpBasicState which is owned by this object, 371 // HttpStreamParser is owned by HttpBasicState which is owned by this object,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 sub_protocol_, 475 sub_protocol_,
475 extensions_)); 476 extensions_));
476 DCHECK(extension_params_.get()); 477 DCHECK(extension_params_.get());
477 if (extension_params_->deflate_enabled) { 478 if (extension_params_->deflate_enabled) {
478 UMA_HISTOGRAM_ENUMERATION( 479 UMA_HISTOGRAM_ENUMERATION(
479 "Net.WebSocket.DeflateMode", 480 "Net.WebSocket.DeflateMode",
480 extension_params_->deflate_parameters.client_context_take_over_mode(), 481 extension_params_->deflate_parameters.client_context_take_over_mode(),
481 WebSocketDeflater::NUM_CONTEXT_TAKEOVER_MODE_TYPES); 482 WebSocketDeflater::NUM_CONTEXT_TAKEOVER_MODE_TYPES);
482 483
483 return scoped_ptr<WebSocketStream>(new WebSocketDeflateStream( 484 return scoped_ptr<WebSocketStream>(new WebSocketDeflateStream(
484 basic_stream.Pass(), extension_params_->deflate_parameters, 485 std::move(basic_stream), extension_params_->deflate_parameters,
485 scoped_ptr<WebSocketDeflatePredictor>( 486 scoped_ptr<WebSocketDeflatePredictor>(
486 new WebSocketDeflatePredictorImpl))); 487 new WebSocketDeflatePredictorImpl)));
487 } else { 488 } else {
488 return basic_stream.Pass(); 489 return basic_stream;
489 } 490 }
490 } 491 }
491 492
492 void WebSocketBasicHandshakeStream::SetWebSocketKeyForTesting( 493 void WebSocketBasicHandshakeStream::SetWebSocketKeyForTesting(
493 const std::string& key) { 494 const std::string& key) {
494 handshake_challenge_for_testing_.reset(new std::string(key)); 495 handshake_challenge_for_testing_.reset(new std::string(key));
495 } 496 }
496 497
497 void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback( 498 void WebSocketBasicHandshakeStream::ReadResponseHeadersCallback(
498 const CompletionCallback& callback, 499 const CompletionCallback& callback,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 set_failure_message("Error during WebSocket handshake: " + failure_message); 590 set_failure_message("Error during WebSocket handshake: " + failure_message);
590 return ERR_INVALID_RESPONSE; 591 return ERR_INVALID_RESPONSE;
591 } 592 }
592 593
593 void WebSocketBasicHandshakeStream::set_failure_message( 594 void WebSocketBasicHandshakeStream::set_failure_message(
594 const std::string& failure_message) { 595 const std::string& failure_message) {
595 *failure_message_ = failure_message; 596 *failure_message_ = failure_message;
596 } 597 }
597 598
598 } // namespace net 599 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_basic_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698