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

Side by Side Diff: remoting/protocol/stream_message_pipe_adapter.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/protocol/stream_message_pipe_adapter.h" 5 #include "remoting/protocol/stream_message_pipe_adapter.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/memory/ptr_util.h"
11 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
12 #include "remoting/base/buffered_socket_writer.h" 13 #include "remoting/base/buffered_socket_writer.h"
13 #include "remoting/base/compound_buffer.h" 14 #include "remoting/base/compound_buffer.h"
14 #include "remoting/protocol/message_serialization.h" 15 #include "remoting/protocol/message_serialization.h"
15 #include "remoting/protocol/p2p_stream_socket.h" 16 #include "remoting/protocol/p2p_stream_socket.h"
16 #include "remoting/protocol/stream_channel_factory.h" 17 #include "remoting/protocol/stream_channel_factory.h"
17 18
18 namespace remoting { 19 namespace remoting {
19 namespace protocol { 20 namespace protocol {
20 21
21 StreamMessagePipeAdapter::StreamMessagePipeAdapter( 22 StreamMessagePipeAdapter::StreamMessagePipeAdapter(
22 scoped_ptr<P2PStreamSocket> socket, 23 std::unique_ptr<P2PStreamSocket> socket,
23 const ErrorCallback& error_callback) 24 const ErrorCallback& error_callback)
24 : socket_(std::move(socket)), 25 : socket_(std::move(socket)),
25 error_callback_(error_callback), 26 error_callback_(error_callback),
26 writer_(new BufferedSocketWriter()) { 27 writer_(new BufferedSocketWriter()) {
27 DCHECK(socket_); 28 DCHECK(socket_);
28 DCHECK(!error_callback_.is_null()); 29 DCHECK(!error_callback_.is_null());
29 30
30 writer_->Start( 31 writer_->Start(
31 base::Bind(&P2PStreamSocket::Write, base::Unretained(socket_.get())), 32 base::Bind(&P2PStreamSocket::Write, base::Unretained(socket_.get())),
32 base::Bind(&StreamMessagePipeAdapter::CloseOnError, 33 base::Bind(&StreamMessagePipeAdapter::CloseOnError,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 base::Unretained(this), callback)); 73 base::Unretained(this), callback));
73 } 74 }
74 75
75 void StreamMessageChannelFactoryAdapter::CancelChannelCreation( 76 void StreamMessageChannelFactoryAdapter::CancelChannelCreation(
76 const std::string& name) { 77 const std::string& name) {
77 stream_channel_factory_->CancelChannelCreation(name); 78 stream_channel_factory_->CancelChannelCreation(name);
78 } 79 }
79 80
80 void StreamMessageChannelFactoryAdapter::OnChannelCreated( 81 void StreamMessageChannelFactoryAdapter::OnChannelCreated(
81 const ChannelCreatedCallback& callback, 82 const ChannelCreatedCallback& callback,
82 scoped_ptr<P2PStreamSocket> socket) { 83 std::unique_ptr<P2PStreamSocket> socket) {
83 if (!socket) { 84 if (!socket) {
84 error_callback_.Run(net::ERR_FAILED); 85 error_callback_.Run(net::ERR_FAILED);
85 return; 86 return;
86 } 87 }
87 callback.Run(make_scoped_ptr( 88 callback.Run(base::WrapUnique(
88 new StreamMessagePipeAdapter(std::move(socket), error_callback_))); 89 new StreamMessagePipeAdapter(std::move(socket), error_callback_)));
89 } 90 }
90 91
91 } // namespace protocol 92 } // namespace protocol
92 } // namespace remoting 93 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/stream_message_pipe_adapter.h ('k') | remoting/protocol/third_party_authenticator_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698