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

Side by Side Diff: mojo/common/data_pipe_utils.cc

Issue 1055703002: Gather trace data by waiting on handles with a fixed timeout (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: review feedback Created 5 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
« no previous file with comments | « no previous file | mojo/common/trace_controller_impl.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 "mojo/common/data_pipe_utils.h" 5 #include "mojo/common/data_pipe_utils.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 MojoResult result = 85 MojoResult result =
86 BeginWriteDataRaw(destination.get(), &buffer, &buffer_num_bytes, 86 BeginWriteDataRaw(destination.get(), &buffer, &buffer_num_bytes,
87 MOJO_WRITE_DATA_FLAG_NONE); 87 MOJO_WRITE_DATA_FLAG_NONE);
88 if (result == MOJO_RESULT_OK) { 88 if (result == MOJO_RESULT_OK) {
89 char* char_buffer = static_cast<char*>(buffer); 89 char* char_buffer = static_cast<char*>(buffer);
90 uint32_t byte_index = 0; 90 uint32_t byte_index = 0;
91 while (it != source.end() && byte_index < buffer_num_bytes) { 91 while (it != source.end() && byte_index < buffer_num_bytes) {
92 char_buffer[byte_index++] = *it++; 92 char_buffer[byte_index++] = *it++;
93 } 93 }
94 EndWriteDataRaw(destination.get(), byte_index); 94 EndWriteDataRaw(destination.get(), byte_index);
95 if (it == source.end())
96 return true;
95 } else if (result == MOJO_RESULT_SHOULD_WAIT) { 97 } else if (result == MOJO_RESULT_SHOULD_WAIT) {
96 result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE, 98 result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
97 MOJO_DEADLINE_INDEFINITE, nullptr); 99 MOJO_DEADLINE_INDEFINITE, nullptr);
98 if (result != MOJO_RESULT_OK) { 100 if (result != MOJO_RESULT_OK) {
99 // If the consumer handle was closed, then treat as EOF. 101 // If the consumer handle was closed, then treat as EOF.
100 return result == MOJO_RESULT_FAILED_PRECONDITION; 102 return result == MOJO_RESULT_FAILED_PRECONDITION;
101 } 103 }
102 } else { 104 } else {
103 // If the consumer handle was closed, then treat as EOF. 105 // If the consumer handle was closed, then treat as EOF.
104 return result == MOJO_RESULT_FAILED_PRECONDITION; 106 return result == MOJO_RESULT_FAILED_PRECONDITION;
105 } 107 }
106 } 108 }
107 } 109 }
108 110
109 } // namespace common 111 } // namespace common
110 } // namespace mojo 112 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/common/trace_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698