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

Unified Diff: third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp

Issue 2046203003: [Fetch API] Introduce BytesConsumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 5 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: third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp b/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..89eb71958c9c00425f658ea58c3b47c73524fa2f
--- /dev/null
+++ b/third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp
@@ -0,0 +1,25 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/fetch/BytesConsumer.h"
+
+#include <algorithm>
+#include <string.h>
+
+namespace blink {
+
+BytesConsumer::Result BytesConsumer::read(char* buffer, size_t size, size_t* readSize)
+{
+ *readSize = 0;
+ const char* src = nullptr;
+ size_t available;
+ Result r = beginRead(&src, &available);
+ if (r != Result::Ok)
+ return r;
+ *readSize = std::min(available, size);
+ memcpy(buffer, src, *readSize);
+ return endRead(*readSize);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698