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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/data_pipe_utils/data_pipe_utils.cc
diff --git a/mojo/data_pipe_utils/data_pipe_utils.cc b/mojo/data_pipe_utils/data_pipe_utils.cc
index af9f2062bd7c045a7d5d2c23faf7424aa0e4abc1..b05df9270dce28d6efb0c043bc81ec6884141db4 100644
--- a/mojo/data_pipe_utils/data_pipe_utils.cc
+++ b/mojo/data_pipe_utils/data_pipe_utils.cc
@@ -111,5 +111,19 @@ bool BlockingCopyFromString(const std::string& source,
}
}
+ScopedDataPipeConsumerHandle WriteStringToConsumerHandle(
+ const std::string& source) {
+ TRACE_EVENT0("data_pipe_utils", "WriteStringToConsumerHandle");
+ static const size_t max_buffer_size = 2 * 1024 * 1024; // 2MB
+ 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.
+ MojoCreateDataPipeOptions options = {
+ sizeof(MojoCreateDataPipeOptions),
+ MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE, 1,
+ 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.
+ DataPipe pipe(options);
+ BlockingCopyFromString(source, pipe.producer_handle.Pass());
+ return pipe.consumer_handle.Pass();
+}
+
} // namespace common
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698