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

Side by Side Diff: native_client_sdk/src/libraries/nacl_mounts/mount_node_html5fs.cc

Issue 11887021: [NaCl SDK] Add HTTP mount. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 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 | Annotate | Revision Log
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_mounts/mount_node_html5fs.h" 6 #include "nacl_mounts/mount_node_html5fs.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <ppapi/c/pp_completion_callback.h> 10 #include <ppapi/c/pp_completion_callback.h>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 errno = EINVAL; 69 errno = EINVAL;
70 return -1; 70 return -1;
71 } 71 }
72 72
73 // If the buffer is too small, fail 73 // If the buffer is too small, fail
74 if (size < sizeof(struct dirent)) { 74 if (size < sizeof(struct dirent)) {
75 errno = EINVAL; 75 errno = EINVAL;
76 return -1; 76 return -1;
77 } 77 }
78 78
79 PP_Resource directory_reader_resource = 79 ScopedResource directory_reader(
80 mount_->ppapi()->GetDirectoryReaderInterface()->Create(fileref_resource_); 80 mount_->ppapi(),
81 if (!directory_reader_resource) { 81 mount_->ppapi()->GetDirectoryReaderInterface()->Create(
82 fileref_resource_));
83 if (!directory_reader.pp_resource()) {
82 errno = ENOSYS; 84 errno = ENOSYS;
83 return -1; 85 return -1;
84 } 86 }
85 87
86 ScopedResource scoped_directory_reader(
87 mount_->ppapi(),
88 directory_reader_resource,
89 ScopedResource::NoAddRef());
90
91 std::vector<struct dirent> dirents; 88 std::vector<struct dirent> dirents;
92 PP_DirectoryEntry_Dev directory_entry = {0}; 89 PP_DirectoryEntry_Dev directory_entry = {0};
93 while (1) { 90 while (1) {
94 int32_t result = 91 int32_t result =
95 mount_->ppapi()->GetDirectoryReaderInterface()->GetNextEntry( 92 mount_->ppapi()->GetDirectoryReaderInterface()->GetNextEntry(
96 directory_reader_resource, &directory_entry, 93 directory_reader.pp_resource(), &directory_entry,
97 PP_BlockUntilComplete()); 94 PP_BlockUntilComplete());
98 if (result != PP_OK) { 95 if (result != PP_OK) {
99 errno = PPErrorToErrno(result); 96 errno = PPErrorToErrno(result);
100 return -1; 97 return -1;
101 } 98 }
102 99
103 // file_ref == 0 is a sentry marking the end of the directory list. 100 // file_ref == 0 is a sentry marking the end of the directory list.
104 if (!directory_entry.file_ref) 101 if (!directory_entry.file_ref)
105 break; 102 break;
106 103
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (fileio_resource_) { 244 if (fileio_resource_) {
248 mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_); 245 mount_->ppapi()->GetFileIoInterface()->Close(fileio_resource_);
249 mount_->ppapi()->ReleaseResource(fileio_resource_); 246 mount_->ppapi()->ReleaseResource(fileio_resource_);
250 } 247 }
251 248
252 mount_->ppapi()->ReleaseResource(fileref_resource_); 249 mount_->ppapi()->ReleaseResource(fileref_resource_);
253 fileio_resource_ = 0; 250 fileio_resource_ = 0;
254 fileref_resource_ = 0; 251 fileref_resource_ = 0;
255 return 0; 252 return 0;
256 } 253 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_mounts/mount_node.h ('k') | native_client_sdk/src/libraries/nacl_mounts/nacl_mounts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698