| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "ppapi/c/dev/ppb_file_system_dev.h" | 8 #include "ppapi/c/dev/ppb_file_system_dev.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 int32_t Open(PP_Resource file_system_id, | 51 int32_t Open(PP_Resource file_system_id, |
| 52 int64 expected_size, | 52 int64 expected_size, |
| 53 PP_CompletionCallback callback) { | 53 PP_CompletionCallback callback) { |
| 54 scoped_refptr<PPB_FileSystem_Impl> file_system( | 54 scoped_refptr<PPB_FileSystem_Impl> file_system( |
| 55 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id)); | 55 Resource::GetAs<PPB_FileSystem_Impl>(file_system_id)); |
| 56 if (!file_system) | 56 if (!file_system) |
| 57 return PP_ERROR_BADRESOURCE; | 57 return PP_ERROR_BADRESOURCE; |
| 58 | 58 |
| 59 if (file_system->opened()) | 59 // Should not allow multiple opens. |
| 60 return PP_OK; | 60 if (file_system->called_open()) |
| 61 return PP_ERROR_FAILED; |
| 62 file_system->set_called_open(); |
| 61 | 63 |
| 62 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && | 64 if ((file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT) && |
| 63 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) | 65 (file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)) |
| 64 return PP_ERROR_FAILED; | 66 return PP_ERROR_FAILED; |
| 65 | 67 |
| 66 PluginInstance* instance = file_system->instance(); | 68 PluginInstance* instance = file_system->instance(); |
| 67 fileapi::FileSystemType file_system_type = | 69 fileapi::FileSystemType file_system_type = |
| 68 (file_system->type() == PP_FILESYSTEMTYPE_LOCALTEMPORARY ? | 70 (file_system->type() == PP_FILESYSTEMTYPE_LOCALTEMPORARY ? |
| 69 fileapi::kFileSystemTypeTemporary : | 71 fileapi::kFileSystemTypeTemporary : |
| 70 fileapi::kFileSystemTypePersistent); | 72 fileapi::kFileSystemTypePersistent); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 93 &GetType | 95 &GetType |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace | 98 } // namespace |
| 97 | 99 |
| 98 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, | 100 PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance, |
| 99 PP_FileSystemType_Dev type) | 101 PP_FileSystemType_Dev type) |
| 100 : Resource(instance), | 102 : Resource(instance), |
| 101 instance_(instance), | 103 instance_(instance), |
| 102 type_(type), | 104 type_(type), |
| 103 opened_(false) { | 105 opened_(false), |
| 106 called_open_(false) { |
| 104 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); | 107 DCHECK(type_ != PP_FILESYSTEMTYPE_INVALID); |
| 105 } | 108 } |
| 106 | 109 |
| 107 PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() { | 110 PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() { |
| 108 return this; | 111 return this; |
| 109 } | 112 } |
| 110 | 113 |
| 111 const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() { | 114 const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() { |
| 112 return &ppb_filesystem; | 115 return &ppb_filesystem; |
| 113 } | 116 } |
| 114 | 117 |
| 115 } // namespace ppapi | 118 } // namespace ppapi |
| 116 } // namespace webkit | 119 } // namespace webkit |
| 117 | 120 |
| OLD | NEW |