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

Side by Side Diff: net/base/nss_memio.c

Issue 11366155: SSLClientSocket::IsConnected should care for internal buffers (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 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
« no previous file with comments | « net/base/nss_memio.h ('k') | net/data/websocket/README » ('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 /* memio is a simple NSPR I/O layer that lets you decouple NSS from 6 /* memio is a simple NSPR I/O layer that lets you decouple NSS from
7 * the real network. It's rather like openssl's memory bio, 7 * the real network. It's rather like openssl's memory bio,
8 * and is useful when your app absolutely, positively doesn't 8 * and is useful when your app absolutely, positively doesn't
9 * want to let NSS do its own networking. 9 * want to let NSS do its own networking.
10 */ 10 */
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 int memio_GetReadParams(memio_Private *secret, char **buf) 396 int memio_GetReadParams(memio_Private *secret, char **buf)
397 { 397 {
398 struct memio_buffer* mb = &((PRFilePrivate *)secret)->readbuf; 398 struct memio_buffer* mb = &((PRFilePrivate *)secret)->readbuf;
399 PR_ASSERT(mb->bufsize); 399 PR_ASSERT(mb->bufsize);
400 400
401 *buf = &mb->buf[mb->tail]; 401 *buf = &mb->buf[mb->tail];
402 return memio_buffer_unused_contiguous(mb); 402 return memio_buffer_unused_contiguous(mb);
403 } 403 }
404 404
405 int memio_GetReadableBufferSize(memio_Private *secret)
406 {
407 struct memio_buffer* mb = &((PRFilePrivate *)secret)->readbuf;
408 PR_ASSERT(mb->bufsize);
409
410 return memio_buffer_used_contiguous(mb);
411 }
412
405 void memio_PutReadResult(memio_Private *secret, int bytes_read) 413 void memio_PutReadResult(memio_Private *secret, int bytes_read)
406 { 414 {
407 struct memio_buffer* mb = &((PRFilePrivate *)secret)->readbuf; 415 struct memio_buffer* mb = &((PRFilePrivate *)secret)->readbuf;
408 PR_ASSERT(mb->bufsize); 416 PR_ASSERT(mb->bufsize);
409 417
410 if (bytes_read > 0) { 418 if (bytes_read > 0) {
411 mb->tail += bytes_read; 419 mb->tail += bytes_read;
412 if (mb->tail == mb->bufsize) 420 if (mb->tail == mb->bufsize)
413 mb->tail = 0; 421 mb->tail = 0;
414 } else if (bytes_read == 0) { 422 } else if (bytes_read == 0) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 CHECKEQ(memio_buffer_unused_contiguous(&mb), 0); 510 CHECKEQ(memio_buffer_unused_contiguous(&mb), 0);
503 CHECKEQ(memio_buffer_used_contiguous(&mb), 1); 511 CHECKEQ(memio_buffer_used_contiguous(&mb), 1);
504 512
505 /* TODO: add more cases */ 513 /* TODO: add more cases */
506 514
507 printf("Test passed\n"); 515 printf("Test passed\n");
508 exit(0); 516 exit(0);
509 } 517 }
510 518
511 #endif 519 #endif
OLDNEW
« no previous file with comments | « net/base/nss_memio.h ('k') | net/data/websocket/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698