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

Side by Side Diff: dart/runtime/bin/net/nss_memio.cc

Issue 574443002: Update NSS to 3.16.4. Updated to Chromium's copy of NSS at revision 291806 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « dart/runtime/bin/net/nss_memio.h ('k') | dart/runtime/bin/net/sqlite.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 // Written in NSPR style to also be suitable for adding to the NSS demo suite 4 // Written in NSPR style to also be suitable for adding to the NSS demo suite
5 5
6 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 6 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
7 // for details. All rights reserved. Use of this source code is governed by a 7 // for details. All rights reserved. Use of this source code is governed by a
8 // BSD-style license that can be found in the LICENSE file. 8 // BSD-style license that can be found in the LICENSE file.
9 9
10 // This file is a modified copy of Chromium's src/net/base/nss_memio.c. 10 // This file is a modified copy of Chromium's src/net/base/nss_memio.c.
11 // char* has been changed to uint8_t* everywhere, and C++ casts are used. 11 // char* has been changed to uint8_t* everywhere, and C++ casts are used.
12 // Revision 257452 (this should agree with "nss_rev" in DEPS). 12 // Revision 291806 (this should agree with "nss_rev" in DEPS).
13 13
14 14
15 /* memio is a simple NSPR I/O layer that lets you decouple NSS from 15 /* memio is a simple NSPR I/O layer that lets you decouple NSS from
16 * the real network. It's rather like openssl's memory bio, 16 * the real network. It's rather like openssl's memory bio,
17 * and is useful when your app absolutely, positively doesn't 17 * and is useful when your app absolutely, positively doesn't
18 * want to let NSS do its own networking. 18 * want to let NSS do its own networking.
19 */ 19 */
20 #include "bin/net/nss_memio.h" 20 #include "bin/net/nss_memio.h"
21 21
22 #include <stdio.h> 22 #include <stdio.h>
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (mb->tail == mb->bufsize) 435 if (mb->tail == mb->bufsize)
436 mb->tail = 0; 436 mb->tail = 0;
437 } else if (bytes_read == 0) { 437 } else if (bytes_read == 0) {
438 /* Record EOF condition and report to caller when buffer runs dry */ 438 /* Record EOF condition and report to caller when buffer runs dry */
439 reinterpret_cast<PRFilePrivate*>(secret)->eof = PR_TRUE; 439 reinterpret_cast<PRFilePrivate*>(secret)->eof = PR_TRUE;
440 } else /* if (bytes_read < 0) */ { 440 } else /* if (bytes_read < 0) */ {
441 mb->last_err = bytes_read; 441 mb->last_err = bytes_read;
442 } 442 }
443 } 443 }
444 444
445 void memio_GetWriteParams(memio_Private *secret, 445 int memio_GetWriteParams(memio_Private *secret,
446 const uint8_t** buf1, unsigned int *len1, 446 const uint8_t** buf1, unsigned int *len1,
447 const uint8_t** buf2, unsigned int *len2) { 447 const uint8_t** buf2, unsigned int *len2) {
448 struct memio_buffer* mb = 448 struct memio_buffer* mb =
449 &(reinterpret_cast<PRFilePrivate*>(secret)->writebuf); 449 &(reinterpret_cast<PRFilePrivate*>(secret)->writebuf);
450 PR_ASSERT(mb->bufsize); 450 PR_ASSERT(mb->bufsize);
451 451
452 if (mb->last_err)
453 return mb->last_err;
454
452 *buf1 = &mb->buf[mb->head]; 455 *buf1 = &mb->buf[mb->head];
453 *len1 = memio_buffer_used_contiguous(mb); 456 *len1 = memio_buffer_used_contiguous(mb);
454 *buf2 = mb->buf; 457 *buf2 = mb->buf;
455 *len2 = memio_buffer_wrapped_bytes(mb); 458 *len2 = memio_buffer_wrapped_bytes(mb);
459 return 0;
456 } 460 }
457 461
458 void memio_PutWriteResult(memio_Private *secret, int bytes_written) { 462 void memio_PutWriteResult(memio_Private *secret, int bytes_written) {
459 struct memio_buffer* mb = 463 struct memio_buffer* mb =
460 &(reinterpret_cast<PRFilePrivate*>(secret)->writebuf); 464 &(reinterpret_cast<PRFilePrivate*>(secret)->writebuf);
461 PR_ASSERT(mb->bufsize); 465 PR_ASSERT(mb->bufsize);
462 466
463 if (bytes_written > 0) { 467 if (bytes_written > 0) {
464 mb->head += bytes_written; 468 mb->head += bytes_written;
465 if (mb->head >= mb->bufsize) 469 if (mb->head >= mb->bufsize)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 CHECKEQ(memio_buffer_unused_contiguous(&mb), 0); 529 CHECKEQ(memio_buffer_unused_contiguous(&mb), 0);
526 CHECKEQ(memio_buffer_used_contiguous(&mb), 1); 530 CHECKEQ(memio_buffer_used_contiguous(&mb), 1);
527 531
528 /* TODO: add more cases */ 532 /* TODO: add more cases */
529 533
530 printf("Test passed\n"); 534 printf("Test passed\n");
531 exit(0); 535 exit(0);
532 } 536 }
533 537
534 #endif 538 #endif
OLDNEW
« no previous file with comments | « dart/runtime/bin/net/nss_memio.h ('k') | dart/runtime/bin/net/sqlite.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698