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

Side by Side Diff: mojo/edk/system/data_pipe.cc

Issue 1350503004: Some easy conversions of scoped_ptr -> std::unique_ptr in the EDK. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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 | « mojo/edk/system/data_pipe.h ('k') | mojo/edk/system/local_data_pipe_impl.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 "mojo/edk/system/data_pipe.h" 5 #include "mojo/edk/system/data_pipe.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 #include <memory>
12 #include <utility>
11 13
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/memory/aligned_memory.h" 15 #include "base/memory/aligned_memory.h"
14 #include "mojo/edk/system/awakable_list.h" 16 #include "mojo/edk/system/awakable_list.h"
15 #include "mojo/edk/system/channel.h" 17 #include "mojo/edk/system/channel.h"
16 #include "mojo/edk/system/configuration.h" 18 #include "mojo/edk/system/configuration.h"
17 #include "mojo/edk/system/data_pipe_impl.h" 19 #include "mojo/edk/system/data_pipe_impl.h"
18 #include "mojo/edk/system/incoming_endpoint.h" 20 #include "mojo/edk/system/incoming_endpoint.h"
19 #include "mojo/edk/system/local_data_pipe_impl.h" 21 #include "mojo/edk/system/local_data_pipe_impl.h"
20 #include "mojo/edk/system/memory.h" 22 #include "mojo/edk/system/memory.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const MojoCreateDataPipeOptions& validated_options) { 97 const MojoCreateDataPipeOptions& validated_options) {
96 return new DataPipe(true, true, validated_options, 98 return new DataPipe(true, true, validated_options,
97 make_scoped_ptr(new LocalDataPipeImpl())); 99 make_scoped_ptr(new LocalDataPipeImpl()));
98 } 100 }
99 101
100 // static 102 // static
101 DataPipe* DataPipe::CreateRemoteProducerFromExisting( 103 DataPipe* DataPipe::CreateRemoteProducerFromExisting(
102 const MojoCreateDataPipeOptions& validated_options, 104 const MojoCreateDataPipeOptions& validated_options,
103 MessageInTransitQueue* message_queue, 105 MessageInTransitQueue* message_queue,
104 ChannelEndpoint* channel_endpoint) { 106 ChannelEndpoint* channel_endpoint) {
105 scoped_ptr<char, base::AlignedFreeDeleter> buffer; 107 std::unique_ptr<char, base::AlignedFreeDeleter> buffer;
106 size_t buffer_num_bytes = 0; 108 size_t buffer_num_bytes = 0;
107 if (!RemoteProducerDataPipeImpl::ProcessMessagesFromIncomingEndpoint( 109 if (!RemoteProducerDataPipeImpl::ProcessMessagesFromIncomingEndpoint(
108 validated_options, message_queue, &buffer, &buffer_num_bytes)) 110 validated_options, message_queue, &buffer, &buffer_num_bytes))
109 return nullptr; 111 return nullptr;
110 112
111 // Important: This is called under |IncomingEndpoint|'s (which is a 113 // Important: This is called under |IncomingEndpoint|'s (which is a
112 // |ChannelEndpointClient|) lock, in particular from 114 // |ChannelEndpointClient|) lock, in particular from
113 // |IncomingEndpoint::ConvertToDataPipeConsumer()|. Before releasing that 115 // |IncomingEndpoint::ConvertToDataPipeConsumer()|. Before releasing that
114 // lock, it will reset its |endpoint_| member, which makes any later or 116 // lock, it will reset its |endpoint_| member, which makes any later or
115 // ongoing call to |IncomingEndpoint::OnReadMessage()| return false. This will 117 // ongoing call to |IncomingEndpoint::OnReadMessage()| return false. This will
116 // make |ChannelEndpoint::OnReadMessage()| retry, until its |ReplaceClient()| 118 // make |ChannelEndpoint::OnReadMessage()| retry, until its |ReplaceClient()|
117 // is called. 119 // is called.
118 DataPipe* data_pipe = 120 DataPipe* data_pipe = new DataPipe(
119 new DataPipe(false, true, validated_options, 121 false, true, validated_options,
120 make_scoped_ptr(new RemoteProducerDataPipeImpl( 122 make_scoped_ptr(new RemoteProducerDataPipeImpl(
121 channel_endpoint, buffer.Pass(), 0, buffer_num_bytes))); 123 channel_endpoint, std::move(buffer), 0, buffer_num_bytes)));
122 if (channel_endpoint) { 124 if (channel_endpoint) {
123 if (!channel_endpoint->ReplaceClient(data_pipe, 0)) 125 if (!channel_endpoint->ReplaceClient(data_pipe, 0))
124 data_pipe->OnDetachFromChannel(0); 126 data_pipe->OnDetachFromChannel(0);
125 } else { 127 } else {
126 data_pipe->SetProducerClosed(); 128 data_pipe->SetProducerClosed();
127 } 129 }
128 return data_pipe; 130 return data_pipe;
129 } 131 }
130 132
131 // static 133 // static
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 SetProducerClosedNoLock(); 818 SetProducerClosedNoLock();
817 } 819 }
818 820
819 void DataPipe::SetConsumerClosed() { 821 void DataPipe::SetConsumerClosed() {
820 MutexLocker locker(&mutex_); 822 MutexLocker locker(&mutex_);
821 SetConsumerClosedNoLock(); 823 SetConsumerClosedNoLock();
822 } 824 }
823 825
824 } // namespace system 826 } // namespace system
825 } // namespace mojo 827 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/data_pipe.h ('k') | mojo/edk/system/local_data_pipe_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698