| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // errno is already set by OpenUrl. | 226 // errno is already set by OpenUrl. |
| 227 return -1; | 227 return -1; |
| 228 } | 228 } |
| 229 | 229 |
| 230 ScopedResource scoped_loader(mount_->ppapi(), loader); | 230 ScopedResource scoped_loader(mount_->ppapi(), loader); |
| 231 ScopedResource scoped_request(mount_->ppapi(), request); | 231 ScopedResource scoped_request(mount_->ppapi(), request); |
| 232 ScopedResource scoped_response(mount_->ppapi(), response); | 232 ScopedResource scoped_response(mount_->ppapi(), response); |
| 233 | 233 |
| 234 | 234 |
| 235 size_t entity_length; | 235 size_t entity_length; |
| 236 if (ParseContentLength(response_headers, &entity_length)) | 236 if (ParseContentLength(response_headers, &entity_length)) { |
| 237 SetCachedSize(static_cast<off_t>(entity_length)); | 237 SetCachedSize(static_cast<off_t>(entity_length)); |
| 238 else | 238 } else if (cache_content_ && !has_cached_size_) { |
| 239 DownloadToCache(); |
| 240 } else { |
| 239 // Don't use SetCachedSize here -- it is actually unknown. | 241 // Don't use SetCachedSize here -- it is actually unknown. |
| 240 stat_.st_size = 0; | 242 stat_.st_size = 0; |
| 243 } |
| 241 | 244 |
| 242 stat_.st_atime = 0; // TODO(binji): Use "Last-Modified". | 245 stat_.st_atime = 0; // TODO(binji): Use "Last-Modified". |
| 243 stat_.st_mtime = 0; | 246 stat_.st_mtime = 0; |
| 244 stat_.st_ctime = 0; | 247 stat_.st_ctime = 0; |
| 245 } | 248 } |
| 246 | 249 |
| 247 // Fill the stat structure if provided | 250 // Fill the stat structure if provided |
| 248 if (stat) { | 251 if (stat) { |
| 249 memcpy(stat, &stat_, sizeof(stat_)); | 252 memcpy(stat, &stat_, sizeof(stat_)); |
| 250 } | 253 } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 off_t len = manifest_node->Read(0, text, manifest_node->GetSize()); | 794 off_t len = manifest_node->Read(0, text, manifest_node->GetSize()); |
| 792 manifest_node->Release(); | 795 manifest_node->Release(); |
| 793 | 796 |
| 794 text[len] = 0; | 797 text[len] = 0; |
| 795 return text; | 798 return text; |
| 796 } | 799 } |
| 797 | 800 |
| 798 fprintf(stderr, "Could not open manifest: %s\n", manifest_name.c_str()); | 801 fprintf(stderr, "Could not open manifest: %s\n", manifest_name.c_str()); |
| 799 return NULL; | 802 return NULL; |
| 800 } | 803 } |
| OLD | NEW |