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 #include "webkit/plugins/ppapi/file_callbacks.h" | 5 #include "webkit/plugins/ppapi/file_callbacks.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_file_info.h" | 8 #include "ppapi/c/pp_file_info.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/ppb_file_system.h" | 10 #include "ppapi/c/ppb_file_system.h" |
11 #include "ppapi/shared_impl/file_type_conversion.h" | 11 #include "ppapi/shared_impl/file_type_conversion.h" |
12 #include "ppapi/shared_impl/time_conversion.h" | 12 #include "ppapi/shared_impl/time_conversion.h" |
13 #include "ppapi/shared_impl/tracked_callback.h" | 13 #include "ppapi/shared_impl/tracked_callback.h" |
14 #include "webkit/fileapi/file_system_types.h" | 14 #include "webkit/fileapi/file_system_types.h" |
15 #include "webkit/plugins/ppapi/plugin_module.h" | 15 #include "webkit/plugins/ppapi/plugin_module.h" |
16 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" | |
17 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 16 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
18 | 17 |
19 using ppapi::Resource; | 18 using ppapi::Resource; |
20 using ppapi::TimeToPPTime; | 19 using ppapi::TimeToPPTime; |
21 using ppapi::TrackedCallback; | 20 using ppapi::TrackedCallback; |
22 | 21 |
23 namespace webkit { | 22 namespace webkit { |
24 namespace ppapi { | 23 namespace ppapi { |
25 | 24 |
26 FileCallbacks::FileCallbacks( | 25 FileCallbacks::FileCallbacks( |
27 Resource* resource, | 26 Resource* resource, |
28 scoped_refptr<TrackedCallback> callback, | 27 scoped_refptr<TrackedCallback> callback, |
29 PP_FileInfo* info, | 28 PP_FileInfo* info, |
30 scoped_refptr<PPB_FileSystem_Impl> file_system, | 29 scoped_refptr<PPB_FileSystem_Impl> file_system) |
31 scoped_refptr<PPB_DirectoryReader_Impl> directory_reader) | |
32 : callback_(callback), | 30 : callback_(callback), |
33 info_(info), | 31 info_(info), |
34 file_system_(file_system), | 32 file_system_(file_system) { |
35 directory_reader_(directory_reader) { | |
36 } | 33 } |
37 | 34 |
38 FileCallbacks::~FileCallbacks() {} | 35 FileCallbacks::~FileCallbacks() {} |
39 | 36 |
40 void FileCallbacks::DidSucceed() { | 37 void FileCallbacks::DidSucceed() { |
41 if (callback_->completed()) | 38 if (callback_->completed()) |
42 return; | 39 return; |
43 | 40 |
44 callback_->Run(PP_OK); | 41 callback_->Run(PP_OK); |
45 } | 42 } |
(...skipping 14 matching lines...) Expand all Loading... |
60 if (file_info.is_directory) | 57 if (file_info.is_directory) |
61 info_->type = PP_FILETYPE_DIRECTORY; | 58 info_->type = PP_FILETYPE_DIRECTORY; |
62 else | 59 else |
63 info_->type = PP_FILETYPE_REGULAR; | 60 info_->type = PP_FILETYPE_REGULAR; |
64 | 61 |
65 callback_->Run(PP_OK); | 62 callback_->Run(PP_OK); |
66 } | 63 } |
67 | 64 |
68 void FileCallbacks::DidReadDirectory( | 65 void FileCallbacks::DidReadDirectory( |
69 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { | 66 const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) { |
70 if (callback_->completed()) | 67 NOTREACHED(); |
71 return; | |
72 | |
73 DCHECK(directory_reader_); | |
74 directory_reader_->AddNewEntries(entries, has_more); | |
75 | |
76 callback_->Run(PP_OK); | |
77 } | 68 } |
78 | 69 |
79 void FileCallbacks::DidOpenFileSystem(const std::string&, | 70 void FileCallbacks::DidOpenFileSystem(const std::string&, |
80 const GURL& root_url) { | 71 const GURL& root_url) { |
81 if (callback_->completed()) | 72 if (callback_->completed()) |
82 return; | 73 return; |
83 | 74 |
84 DCHECK(file_system_); | 75 DCHECK(file_system_); |
85 file_system_->set_root_url(root_url); | 76 file_system_->set_root_url(root_url); |
86 file_system_->set_opened(true); | 77 file_system_->set_opened(true); |
(...skipping 11 matching lines...) Expand all Loading... |
98 | 89 |
99 void FileCallbacks::RunCallback(base::PlatformFileError error_code) { | 90 void FileCallbacks::RunCallback(base::PlatformFileError error_code) { |
100 if (callback_->completed()) | 91 if (callback_->completed()) |
101 return; | 92 return; |
102 | 93 |
103 callback_->Run(::ppapi::PlatformFileErrorToPepperError(error_code)); | 94 callback_->Run(::ppapi::PlatformFileErrorToPepperError(error_code)); |
104 } | 95 } |
105 | 96 |
106 } // namespace ppapi | 97 } // namespace ppapi |
107 } // namespace webkit | 98 } // namespace webkit |
OLD | NEW |