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

Unified Diff: bin/socket.cc

Issue 12255018: Add typed data interface to Dart API, this only changes the C++ API as dicussed in a previous email… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « bin/secure_socket.cc ('k') | include/dart_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/socket.cc
===================================================================
--- bin/socket.cc (revision 18843)
+++ bin/socket.cc (working copy)
@@ -185,20 +185,21 @@
intptr_t total_bytes_written = 0;
intptr_t bytes_written = 0;
- if (Dart_IsByteArrayExternal(buffer_obj)) {
- void* buffer = NULL;
- result = Dart_ExternalByteArrayGetData(buffer_obj, &buffer);
- if (Dart_IsError(result)) {
- Dart_PropagateError(result);
- }
- buffer = static_cast<void*>(static_cast<uint8_t*>(buffer) + offset);
+ Dart_TypedData_Type type;
+ uint8_t* buffer = NULL;
+ intptr_t len;
+ result = Dart_TypedDataAcquireData(buffer_obj, &type,
+ reinterpret_cast<void**>(&buffer), &len);
+ if (!Dart_IsError(result)) {
+ buffer += offset;
bytes_written = Socket::Write(socket, buffer, length);
if (bytes_written > 0) total_bytes_written = bytes_written;
+ Dart_TypedDataReleaseData(buffer_obj);
} else {
// Send data in chunks of maximum 16KB.
const intptr_t max_chunk_length =
dart::Utils::Minimum(length, static_cast<intptr_t>(16 * KB));
- uint8_t* buffer = new uint8_t[max_chunk_length];
+ buffer = new uint8_t[max_chunk_length];
do {
intptr_t chunk_length =
dart::Utils::Minimum(max_chunk_length, length - total_bytes_written);
« no previous file with comments | « bin/secure_socket.cc ('k') | include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698