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

Side by Side Diff: ipc/mojo/ipc_message_pipe_reader.cc

Issue 1322253003: ipc: Convert int types from basictypes.h to the ones from stdint.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE 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 | « ipc/mojo/ipc_channel_mojo_unittest.cc ('k') | ipc/mojo/ipc_mojo_bootstrap.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ipc/mojo/ipc_message_pipe_reader.h" 5 #include "ipc/mojo/ipc_message_pipe_reader.h"
6 6
7 #include <stdint.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
13 #include "ipc/mojo/async_handle_waiter.h" 15 #include "ipc/mojo/async_handle_waiter.h"
14 #include "ipc/mojo/ipc_channel_mojo.h" 16 #include "ipc/mojo/ipc_channel_mojo.h"
15 17
16 namespace IPC { 18 namespace IPC {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), 72 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"),
71 "MessagePipeReader::Send", 73 "MessagePipeReader::Send",
72 message->flags(), 74 message->flags(),
73 TRACE_EVENT_FLAG_FLOW_OUT); 75 TRACE_EVENT_FLAG_FLOW_OUT);
74 std::vector<MojoHandle> handles; 76 std::vector<MojoHandle> handles;
75 MojoResult result = MOJO_RESULT_OK; 77 MojoResult result = MOJO_RESULT_OK;
76 result = ChannelMojo::ReadFromMessageAttachmentSet(message.get(), &handles); 78 result = ChannelMojo::ReadFromMessageAttachmentSet(message.get(), &handles);
77 if (result == MOJO_RESULT_OK) { 79 if (result == MOJO_RESULT_OK) {
78 result = MojoWriteMessage(handle(), 80 result = MojoWriteMessage(handle(),
79 message->data(), 81 message->data(),
80 static_cast<uint32>(message->size()), 82 static_cast<uint32_t>(message->size()),
81 handles.empty() ? nullptr : &handles[0], 83 handles.empty() ? nullptr : &handles[0],
82 static_cast<uint32>(handles.size()), 84 static_cast<uint32_t>(handles.size()),
83 MOJO_WRITE_MESSAGE_FLAG_NONE); 85 MOJO_WRITE_MESSAGE_FLAG_NONE);
84 } 86 }
85 87
86 if (result != MOJO_RESULT_OK) { 88 if (result != MOJO_RESULT_OK) {
87 std::for_each(handles.begin(), handles.end(), &MojoClose); 89 std::for_each(handles.begin(), handles.end(), &MojoClose);
88 // We cannot call CloseWithError() here as Send() is protected by 90 // We cannot call CloseWithError() here as Send() is protected by
89 // ChannelMojo's lock and CloseWithError() could re-enter ChannelMojo. We 91 // ChannelMojo's lock and CloseWithError() could re-enter ChannelMojo. We
90 // cannot call CloseWithError() also because Send() can be called from 92 // cannot call CloseWithError() also because Send() can be called from
91 // non-UI thread while OnPipeError() expects to be called on IO thread. 93 // non-UI thread while OnPipeError() expects to be called on IO thread.
92 CloseWithErrorLater(result); 94 CloseWithErrorLater(result);
93 return false; 95 return false;
94 } 96 }
95 97
96 return true; 98 return true;
97 } 99 }
98 100
99 void MessagePipeReader::OnMessageReceived() { 101 void MessagePipeReader::OnMessageReceived() {
100 Message message(data_buffer().empty() ? "" : &data_buffer()[0], 102 Message message(data_buffer().empty() ? "" : &data_buffer()[0],
101 static_cast<uint32>(data_buffer().size())); 103 static_cast<uint32_t>(data_buffer().size()));
102 104
103 std::vector<MojoHandle> handle_buffer; 105 std::vector<MojoHandle> handle_buffer;
104 TakeHandleBuffer(&handle_buffer); 106 TakeHandleBuffer(&handle_buffer);
105 MojoResult write_result = 107 MojoResult write_result =
106 ChannelMojo::WriteToMessageAttachmentSet(handle_buffer, &message); 108 ChannelMojo::WriteToMessageAttachmentSet(handle_buffer, &message);
107 if (write_result != MOJO_RESULT_OK) { 109 if (write_result != MOJO_RESULT_OK) {
108 CloseWithError(write_result); 110 CloseWithError(write_result);
109 return; 111 return;
110 } 112 }
111 113
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 236
235 void MessagePipeReader::DelayedDeleter::operator()( 237 void MessagePipeReader::DelayedDeleter::operator()(
236 MessagePipeReader* ptr) const { 238 MessagePipeReader* ptr) const {
237 ptr->Close(); 239 ptr->Close();
238 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 240 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
239 base::Bind(&DeleteNow, ptr)); 241 base::Bind(&DeleteNow, ptr));
240 } 242 }
241 243
242 } // namespace internal 244 } // namespace internal
243 } // namespace IPC 245 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_channel_mojo_unittest.cc ('k') | ipc/mojo/ipc_mojo_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698