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

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

Issue 1466733002: Google OAuth Device Flow support for FNL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Addressed review comments Created 4 years, 11 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/data_pipe_utils/data_pipe_utils.h" 5 #include "mojo/data_pipe_utils/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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // If the consumer handle was closed, then treat as EOF. 104 // If the consumer handle was closed, then treat as EOF.
105 return result == MOJO_RESULT_FAILED_PRECONDITION; 105 return result == MOJO_RESULT_FAILED_PRECONDITION;
106 } 106 }
107 } else { 107 } else {
108 // If the consumer handle was closed, then treat as EOF. 108 // If the consumer handle was closed, then treat as EOF.
109 return result == MOJO_RESULT_FAILED_PRECONDITION; 109 return result == MOJO_RESULT_FAILED_PRECONDITION;
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 ScopedDataPipeConsumerHandle WriteStringToConsumerHandle(
115 const std::string& source) {
116 TRACE_EVENT0("data_pipe_utils", "WriteStringToConsumerHandle");
117 static const size_t max_buffer_size = 2 * 1024 * 1024; // 2MB
118 DCHECK_LE(static_cast<uint32_t>(source.size()), max_buffer_size);
viettrungluu 2016/01/11 21:23:44 Maybe make this a CHECK_LE instead of a DCHECK_LE
ukode 2016/02/09 00:20:17 Done.
119 MojoCreateDataPipeOptions options = {
120 sizeof(MojoCreateDataPipeOptions),
121 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 1,
122 static_cast<uint32_t>(std::min(source.size(), max_buffer_size))};
qsr 2016/01/13 12:01:00 once you change to a check, just use source.size()
ukode 2016/02/09 00:20:17 Acknowledged.
123 DataPipe pipe(options);
124 BlockingCopyFromString(source, pipe.producer_handle.Pass());
125 return pipe.consumer_handle.Pass();
126 }
127
114 } // namespace common 128 } // namespace common
115 } // namespace mojo 129 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698