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

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: 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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 MojoResult result = 86 MojoResult result =
87 BeginWriteDataRaw(destination.get(), &buffer, &buffer_num_bytes, 87 BeginWriteDataRaw(destination.get(), &buffer, &buffer_num_bytes,
88 MOJO_WRITE_DATA_FLAG_NONE); 88 MOJO_WRITE_DATA_FLAG_NONE);
89 if (result == MOJO_RESULT_OK) { 89 if (result == MOJO_RESULT_OK) {
90 char* char_buffer = static_cast<char*>(buffer); 90 char* char_buffer = static_cast<char*>(buffer);
91 uint32_t byte_index = 0; 91 uint32_t byte_index = 0;
92 while (it != source.end() && byte_index < buffer_num_bytes) { 92 while (it != source.end() && byte_index < buffer_num_bytes) {
93 char_buffer[byte_index++] = *it++; 93 char_buffer[byte_index++] = *it++;
94 } 94 }
95 EndWriteDataRaw(destination.get(), byte_index); 95 EndWriteDataRaw(destination.get(), byte_index);
96 if (it == source.end())
viettrungluu 2015/04/02 19:54:12 If we want to keep this function around, we really
97 return true;
96 } else if (result == MOJO_RESULT_SHOULD_WAIT) { 98 } else if (result == MOJO_RESULT_SHOULD_WAIT) {
97 result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE, 99 result = Wait(destination.get(), MOJO_HANDLE_SIGNAL_WRITABLE,
98 MOJO_DEADLINE_INDEFINITE, nullptr); 100 MOJO_DEADLINE_INDEFINITE, nullptr);
99 if (result != MOJO_RESULT_OK) { 101 if (result != MOJO_RESULT_OK) {
100 // If the consumer handle was closed, then treat as EOF. 102 // If the consumer handle was closed, then treat as EOF.
101 return result == MOJO_RESULT_FAILED_PRECONDITION; 103 return result == MOJO_RESULT_FAILED_PRECONDITION;
102 } 104 }
103 } else { 105 } else {
104 // If the consumer handle was closed, then treat as EOF. 106 // If the consumer handle was closed, then treat as EOF.
105 return result == MOJO_RESULT_FAILED_PRECONDITION; 107 return result == MOJO_RESULT_FAILED_PRECONDITION;
106 } 108 }
107 } 109 }
108 } 110 }
109 111
110 } // namespace common 112 } // namespace common
111 } // namespace mojo 113 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/common/trace_controller_impl.cc » ('j') | mojo/public/cpp/bindings/lib/connector.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698