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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_http.cc

Issue 13831005: [NaCl SDK] nacl_io: HTTP mount bugfix, w/ packaged app and content cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 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 */ 4 */
5 5
6 #include "nacl_io/mount_http.h" 6 #include "nacl_io/mount_http.h"
7 #include <assert.h> 7 #include <assert.h>
8 #include <ctype.h> 8 #include <ctype.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (real_size < 0) 411 if (real_size < 0)
412 return -1; 412 return -1;
413 413
414 SetCachedSize(real_size); 414 SetCachedSize(real_size);
415 cached_data_.resize(real_size); 415 cached_data_.resize(real_size);
416 return real_size; 416 return real_size;
417 } 417 }
418 418
419 // We don't know how big the file is. Read in chunks. 419 // We don't know how big the file is. Read in chunks.
420 cached_data_.resize(MAX_READ_BUFFER_SIZE); 420 cached_data_.resize(MAX_READ_BUFFER_SIZE);
421 char* buf = cached_data_.data();
422 size_t total_bytes_read = 0; 421 size_t total_bytes_read = 0;
423 size_t bytes_to_read = MAX_READ_BUFFER_SIZE; 422 size_t bytes_to_read = MAX_READ_BUFFER_SIZE;
424 while (true) { 423 while (true) {
424 char* buf = cached_data_.data() + total_bytes_read;
425 int bytes_read = DownloadToBuffer(loader, buf, bytes_to_read); 425 int bytes_read = DownloadToBuffer(loader, buf, bytes_to_read);
426 if (bytes_read < 0) 426 if (bytes_read < 0)
427 return -1; 427 return -1;
428 428
429 total_bytes_read += bytes_read; 429 total_bytes_read += bytes_read;
430 430
431 if (bytes_read < bytes_to_read) { 431 if (bytes_read < bytes_to_read) {
432 SetCachedSize(total_bytes_read); 432 SetCachedSize(total_bytes_read);
433 cached_data_.resize(total_bytes_read); 433 cached_data_.resize(total_bytes_read);
434 return total_bytes_read; 434 return total_bytes_read;
435 } 435 }
436 436
437 buf += bytes_read;
438 cached_data_.resize(total_bytes_read + bytes_to_read); 437 cached_data_.resize(total_bytes_read + bytes_to_read);
439 } 438 }
440 } 439 }
441 440
442 int MountNodeHttp::ReadPartialFromCache(size_t offs, void* buf, size_t count) { 441 int MountNodeHttp::ReadPartialFromCache(size_t offs, void* buf, size_t count) {
443 if (offs > cached_data_.size()) { 442 if (offs > cached_data_.size()) {
444 errno = EINVAL; 443 errno = EINVAL;
445 return -1; 444 return -1;
446 } 445 }
447 446
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 off_t len = manifest_node->Read(0, text, manifest_node->GetSize()); 793 off_t len = manifest_node->Read(0, text, manifest_node->GetSize());
795 manifest_node->Release(); 794 manifest_node->Release();
796 795
797 text[len] = 0; 796 text[len] = 0;
798 return text; 797 return text;
799 } 798 }
800 799
801 fprintf(stderr, "Could not open manifest: %s\n", manifest_name.c_str()); 800 fprintf(stderr, "Could not open manifest: %s\n", manifest_name.c_str());
802 return NULL; 801 return NULL;
803 } 802 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698