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

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: 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), 66 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"),
65 "MessagePipeReader::Send", 67 "MessagePipeReader::Send",
66 message->flags(), 68 message->flags(),
67 TRACE_EVENT_FLAG_FLOW_OUT); 69 TRACE_EVENT_FLAG_FLOW_OUT);
68 std::vector<MojoHandle> handles; 70 std::vector<MojoHandle> handles;
69 MojoResult result = MOJO_RESULT_OK; 71 MojoResult result = MOJO_RESULT_OK;
70 result = ChannelMojo::ReadFromMessageAttachmentSet(message.get(), &handles); 72 result = ChannelMojo::ReadFromMessageAttachmentSet(message.get(), &handles);
71 if (result == MOJO_RESULT_OK) { 73 if (result == MOJO_RESULT_OK) {
72 result = MojoWriteMessage(handle(), 74 result = MojoWriteMessage(handle(),
73 message->data(), 75 message->data(),
74 static_cast<uint32>(message->size()), 76 static_cast<uint32_t>(message->size()),
75 handles.empty() ? nullptr : &handles[0], 77 handles.empty() ? nullptr : &handles[0],
76 static_cast<uint32>(handles.size()), 78 static_cast<uint32_t>(handles.size()),
77 MOJO_WRITE_MESSAGE_FLAG_NONE); 79 MOJO_WRITE_MESSAGE_FLAG_NONE);
78 } 80 }
79 81
80 if (result != MOJO_RESULT_OK) { 82 if (result != MOJO_RESULT_OK) {
81 std::for_each(handles.begin(), handles.end(), &MojoClose); 83 std::for_each(handles.begin(), handles.end(), &MojoClose);
82 // We cannot call CloseWithError() here as Send() is protected by 84 // We cannot call CloseWithError() here as Send() is protected by
83 // ChannelMojo's lock and CloseWithError() could re-enter ChannelMojo. We 85 // ChannelMojo's lock and CloseWithError() could re-enter ChannelMojo. We
84 // cannot call CloseWithError() also because Send() can be called from 86 // cannot call CloseWithError() also because Send() can be called from
85 // non-UI thread while OnPipeError() expects to be called on IO thread. 87 // non-UI thread while OnPipeError() expects to be called on IO thread.
86 CloseWithErrorLater(result); 88 CloseWithErrorLater(result);
87 return false; 89 return false;
88 } 90 }
89 91
90 return true; 92 return true;
91 } 93 }
92 94
93 void MessagePipeReader::OnMessageReceived() { 95 void MessagePipeReader::OnMessageReceived() {
94 Message message(data_buffer().empty() ? "" : &data_buffer()[0], 96 Message message(data_buffer().empty() ? "" : &data_buffer()[0],
95 static_cast<uint32>(data_buffer().size())); 97 static_cast<uint32_t>(data_buffer().size()));
96 98
97 std::vector<MojoHandle> handle_buffer; 99 std::vector<MojoHandle> handle_buffer;
98 TakeHandleBuffer(&handle_buffer); 100 TakeHandleBuffer(&handle_buffer);
99 MojoResult write_result = 101 MojoResult write_result =
100 ChannelMojo::WriteToMessageAttachmentSet(handle_buffer, &message); 102 ChannelMojo::WriteToMessageAttachmentSet(handle_buffer, &message);
101 if (write_result != MOJO_RESULT_OK) { 103 if (write_result != MOJO_RESULT_OK) {
102 CloseWithError(write_result); 104 CloseWithError(write_result);
103 return; 105 return;
104 } 106 }
105 107
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 224
223 void MessagePipeReader::DelayedDeleter::operator()( 225 void MessagePipeReader::DelayedDeleter::operator()(
224 MessagePipeReader* ptr) const { 226 MessagePipeReader* ptr) const {
225 ptr->Close(); 227 ptr->Close();
226 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 228 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
227 base::Bind(&DeleteNow, ptr)); 229 base::Bind(&DeleteNow, ptr));
228 } 230 }
229 231
230 } // namespace internal 232 } // namespace internal
231 } // namespace IPC 233 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698