Chromium Code Reviews| 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_html5fs.h" | 6 #include "nacl_io/mount_html5fs.h" |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <ppapi/c/pp_completion_callback.h> | 9 #include <ppapi/c/pp_completion_callback.h> |
| 10 #include <ppapi/c/pp_errors.h> | 10 #include <ppapi/c/pp_errors.h> |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 Error MountHtml5Fs::Open(const Path& path, int mode, MountNode** out_node) { | 27 Error MountHtml5Fs::Open(const Path& path, int mode, MountNode** out_node) { |
| 28 *out_node = NULL; | 28 *out_node = NULL; |
| 29 | 29 |
| 30 Error error = BlockUntilFilesystemOpen(); | 30 Error error = BlockUntilFilesystemOpen(); |
| 31 if (error) | 31 if (error) |
| 32 return error; | 32 return error; |
| 33 | 33 |
| 34 PP_Resource fileref = ppapi()->GetFileRefInterface() | 34 PP_Resource fileref = ppapi()->GetFileRefInterface() |
| 35 ->Create(filesystem_resource_, path.Join().c_str()); | 35 ->Create(filesystem_resource_, path.Join().c_str()); |
| 36 if (!fileref) | 36 if (!fileref) |
| 37 return ENOSYS; | 37 return ENOENT; |
| 38 | 38 |
| 39 MountNodeHtml5Fs* node = new MountNodeHtml5Fs(this, fileref); | 39 MountNodeHtml5Fs* node = new MountNodeHtml5Fs(this, fileref); |
| 40 error = node->Init(mode); | 40 error = node->Init(mode); |
| 41 if (error) { | 41 if (error) { |
| 42 node->Release(); | 42 node->Release(); |
| 43 return error; | 43 return error; |
| 44 } | 44 } |
| 45 | 45 |
| 46 *out_node = node; | 46 *out_node = node; |
| 47 return 0; | 47 return 0; |
| 48 } | 48 } |
| 49 | 49 |
| 50 Error MountHtml5Fs::Unlink(const Path& path) { return Remove(path); } | 50 Error MountHtml5Fs::Unlink(const Path& path) { return Remove(path); } |
| 51 | 51 |
| 52 Error MountHtml5Fs::Mkdir(const Path& path, int permissions) { | 52 Error MountHtml5Fs::Mkdir(const Path& path, int permissions) { |
| 53 Error error = BlockUntilFilesystemOpen(); | 53 Error error = BlockUntilFilesystemOpen(); |
| 54 if (error) | 54 if (error) |
| 55 return error; | 55 return error; |
| 56 | 56 |
| 57 ScopedResource fileref_resource( | 57 ScopedResource fileref_resource( |
| 58 ppapi(), | 58 ppapi(), |
| 59 ppapi()->GetFileRefInterface()->Create(filesystem_resource_, | 59 ppapi()->GetFileRefInterface()->Create(filesystem_resource_, |
| 60 path.Join().c_str())); | 60 path.Join().c_str())); |
| 61 if (!fileref_resource.pp_resource()) | 61 if (!fileref_resource.pp_resource()) |
| 62 return EIO; | 62 return EIO; |
|
binji
2013/06/20 15:56:12
change this one too? It's not immediately clear wh
Matt Giuca
2013/06/21 00:33:03
Yeah it's not quite clear to me what it should be
| |
| 63 | 63 |
| 64 int32_t result = ppapi()->GetFileRefInterface()->MakeDirectory( | 64 int32_t result = ppapi()->GetFileRefInterface()->MakeDirectory( |
| 65 fileref_resource.pp_resource(), PP_FALSE, PP_BlockUntilComplete()); | 65 fileref_resource.pp_resource(), PP_FALSE, PP_BlockUntilComplete()); |
| 66 if (result != PP_OK) | 66 if (result != PP_OK) |
| 67 return PPErrorToErrno(result); | 67 return PPErrorToErrno(result); |
| 68 | 68 |
| 69 return 0; | 69 return 0; |
| 70 } | 70 } |
| 71 | 71 |
| 72 Error MountHtml5Fs::Rmdir(const Path& path) { return Remove(path); } | 72 Error MountHtml5Fs::Rmdir(const Path& path) { return Remove(path); } |
| 73 | 73 |
| 74 Error MountHtml5Fs::Remove(const Path& path) { | 74 Error MountHtml5Fs::Remove(const Path& path) { |
| 75 Error error = BlockUntilFilesystemOpen(); | 75 Error error = BlockUntilFilesystemOpen(); |
| 76 if (error) | 76 if (error) |
| 77 return error; | 77 return error; |
| 78 | 78 |
| 79 ScopedResource fileref_resource( | 79 ScopedResource fileref_resource( |
| 80 ppapi(), | 80 ppapi(), |
| 81 ppapi()->GetFileRefInterface()->Create(filesystem_resource_, | 81 ppapi()->GetFileRefInterface()->Create(filesystem_resource_, |
| 82 path.Join().c_str())); | 82 path.Join().c_str())); |
| 83 if (!fileref_resource.pp_resource()) | 83 if (!fileref_resource.pp_resource()) |
| 84 return ENOSYS; | 84 return ENOENT; |
| 85 | 85 |
| 86 int32_t result = ppapi()->GetFileRefInterface() | 86 int32_t result = ppapi()->GetFileRefInterface() |
| 87 ->Delete(fileref_resource.pp_resource(), PP_BlockUntilComplete()); | 87 ->Delete(fileref_resource.pp_resource(), PP_BlockUntilComplete()); |
| 88 if (result != PP_OK) | 88 if (result != PP_OK) |
| 89 return PPErrorToErrno(result); | 89 return PPErrorToErrno(result); |
| 90 | 90 |
| 91 return 0; | 91 return 0; |
| 92 } | 92 } |
| 93 | 93 |
| 94 MountHtml5Fs::MountHtml5Fs() | 94 MountHtml5Fs::MountHtml5Fs() |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 MountHtml5Fs* self = static_cast<MountHtml5Fs*>(user_data); | 171 MountHtml5Fs* self = static_cast<MountHtml5Fs*>(user_data); |
| 172 self->FilesystemOpenCallback(result); | 172 self->FilesystemOpenCallback(result); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void MountHtml5Fs::FilesystemOpenCallback(int32_t result) { | 175 void MountHtml5Fs::FilesystemOpenCallback(int32_t result) { |
| 176 AutoLock lock(&lock_); | 176 AutoLock lock(&lock_); |
| 177 filesystem_open_has_result_ = true; | 177 filesystem_open_has_result_ = true; |
| 178 filesystem_open_error_ = PPErrorToErrno(result); | 178 filesystem_open_error_ = PPErrorToErrno(result); |
| 179 pthread_cond_signal(&filesystem_open_cond_); | 179 pthread_cond_signal(&filesystem_open_cond_); |
| 180 } | 180 } |
| OLD | NEW |