OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_ref_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/thunk/enter.h" | 11 #include "ppapi/thunk/enter.h" |
12 #include "ppapi/thunk/ppb_file_system_api.h" | 12 #include "ppapi/thunk/ppb_file_system_api.h" |
13 #include "webkit/plugins/ppapi/common.h" | 13 #include "webkit/plugins/ppapi/common.h" |
14 #include "webkit/plugins/ppapi/file_callbacks.h" | 14 #include "webkit/plugins/ppapi/file_callbacks.h" |
15 #include "webkit/plugins/ppapi/plugin_delegate.h" | 15 #include "webkit/plugins/ppapi/plugin_delegate.h" |
16 #include "webkit/plugins/ppapi/plugin_module.h" | 16 #include "webkit/plugins/ppapi/plugin_module.h" |
17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
18 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" | 18 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
19 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 19 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
| 20 #include "webkit/plugins/ppapi/time_conversion.h" |
20 #include "webkit/plugins/ppapi/var.h" | 21 #include "webkit/plugins/ppapi/var.h" |
21 | 22 |
22 using ppapi::thunk::EnterResourceNoLock; | 23 using ppapi::thunk::EnterResourceNoLock; |
23 using ppapi::thunk::PPB_FileRef_API; | 24 using ppapi::thunk::PPB_FileRef_API; |
24 using ppapi::thunk::PPB_FileSystem_API; | 25 using ppapi::thunk::PPB_FileSystem_API; |
25 | 26 |
26 namespace webkit { | 27 namespace webkit { |
27 namespace ppapi { | 28 namespace ppapi { |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return PP_OK_COMPLETIONPENDING; | 175 return PP_OK_COMPLETIONPENDING; |
175 } | 176 } |
176 | 177 |
177 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, | 178 int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time, |
178 PP_Time last_modified_time, | 179 PP_Time last_modified_time, |
179 PP_CompletionCallback callback) { | 180 PP_CompletionCallback callback) { |
180 if (!IsValidNonExternalFileSystem()) | 181 if (!IsValidNonExternalFileSystem()) |
181 return PP_ERROR_NOACCESS; | 182 return PP_ERROR_NOACCESS; |
182 if (!instance()->delegate()->Touch( | 183 if (!instance()->delegate()->Touch( |
183 GetFileSystemURL(), | 184 GetFileSystemURL(), |
184 base::Time::FromDoubleT(last_access_time), | 185 PPTimeToTime(last_access_time), |
185 base::Time::FromDoubleT(last_modified_time), | 186 PPTimeToTime(last_modified_time), |
186 new FileCallbacks(instance()->module()->AsWeakPtr(), | 187 new FileCallbacks(instance()->module()->AsWeakPtr(), |
187 GetReferenceNoAddRef(), callback, | 188 GetReferenceNoAddRef(), callback, |
188 NULL, NULL, NULL))) | 189 NULL, NULL, NULL))) |
189 return PP_ERROR_FAILED; | 190 return PP_ERROR_FAILED; |
190 return PP_OK_COMPLETIONPENDING; | 191 return PP_OK_COMPLETIONPENDING; |
191 } | 192 } |
192 | 193 |
193 int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) { | 194 int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) { |
194 if (!IsValidNonExternalFileSystem()) | 195 if (!IsValidNonExternalFileSystem()) |
195 return PP_ERROR_NOACCESS; | 196 return PP_ERROR_NOACCESS; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 return GURL(file_system_->root_url().spec() + virtual_path_.substr(1)); | 250 return GURL(file_system_->root_url().spec() + virtual_path_.substr(1)); |
250 } | 251 } |
251 | 252 |
252 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { | 253 bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const { |
253 return file_system_ && file_system_->opened() && | 254 return file_system_ && file_system_->opened() && |
254 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; | 255 file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL; |
255 } | 256 } |
256 | 257 |
257 } // namespace ppapi | 258 } // namespace ppapi |
258 } // namespace webkit | 259 } // namespace webkit |
OLD | NEW |