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

Side by Side Diff: ppapi/proxy/file_ref_resource.cc

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove code duplication Created 7 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ppapi/proxy/file_ref_resource.h" 5 #include "ppapi/proxy/file_ref_resource.h"
6 6
7 #include "ppapi/c/pp_directory_entry.h" 7 #include "ppapi/c/pp_directory_entry.h"
8 #include "ppapi/c/pp_instance.h" 8 #include "ppapi/c/pp_instance.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
(...skipping 16 matching lines...) Expand all
27 create_info_(create_info), 27 create_info_(create_info),
28 file_system_resource_(create_info.file_system_plugin_resource) { 28 file_system_resource_(create_info.file_system_plugin_resource) {
29 if (create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL) { 29 if (create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL) {
30 // If path ends with a slash, then normalize it away unless path is 30 // If path ends with a slash, then normalize it away unless path is
31 // the root path. 31 // the root path.
32 int path_size = create_info_.internal_path.size(); 32 int path_size = create_info_.internal_path.size();
33 if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/') 33 if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/')
34 create_info_.internal_path.erase(path_size - 1, 1); 34 create_info_.internal_path.erase(path_size - 1, 1);
35 35
36 path_var_ = new StringVar(create_info_.internal_path); 36 path_var_ = new StringVar(create_info_.internal_path);
37
38 create_info_.display_name = GetNameForInternalFilePath( 37 create_info_.display_name = GetNameForInternalFilePath(
39 create_info_.internal_path); 38 create_info_.internal_path);
40 } 39 }
41 name_var_ = new StringVar(create_info_.display_name); 40 name_var_ = new StringVar(create_info_.display_name);
42 41
43 if (create_info_.pending_host_resource_id != 0) { 42 if (create_info_.pending_host_resource_id != 0) {
44 AttachToPendingHost(BROWSER, create_info_.pending_host_resource_id); 43 AttachToPendingHost(BROWSER, create_info_.pending_host_resource_id);
45 } else { 44 } else {
46 CHECK(create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL); 45 CHECK(create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL);
47 SendCreate(BROWSER, PpapiHostMsg_FileRef_CreateInternal( 46 SendCreate(BROWSER, PpapiHostMsg_FileRef_CreateInternal(
(...skipping 27 matching lines...) Expand all
75 create_info.file_system_type == PP_FILESYSTEMTYPE_LOCALTEMPORARY) { 74 create_info.file_system_type == PP_FILESYSTEMTYPE_LOCALTEMPORARY) {
76 if (!IsValidInternalPath(create_info.internal_path)) 75 if (!IsValidInternalPath(create_info.internal_path))
77 return 0; 76 return 0;
78 } 77 }
79 return (new FileRefResource(connection, 78 return (new FileRefResource(connection,
80 instance, 79 instance,
81 create_info))->GetReference(); 80 create_info))->GetReference();
82 } 81 }
83 82
84 thunk::PPB_FileRef_API* FileRefResource::AsPPB_FileRef_API() { 83 thunk::PPB_FileRef_API* FileRefResource::AsPPB_FileRef_API() {
85 // TODO: return "this" once we update PPB_FileRef_API. 84 return this;
86 NOTREACHED();
87 return NULL;
88 } 85 }
89 86
90 PP_FileSystemType FileRefResource::GetFileSystemType() const { 87 PP_FileSystemType FileRefResource::GetFileSystemType() const {
91 return create_info_.file_system_type; 88 return create_info_.file_system_type;
92 } 89 }
93 90
94 PP_Var FileRefResource::GetName() const { 91 PP_Var FileRefResource::GetName() const {
95 return name_var_->GetPPVar(); 92 return name_var_->GetPPVar();
96 } 93 }
97 94
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const PP_ArrayOutput& output, 174 const PP_ArrayOutput& output,
178 scoped_refptr<TrackedCallback> callback) { 175 scoped_refptr<TrackedCallback> callback) {
179 Call<PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply>( 176 Call<PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply>(
180 BROWSER, 177 BROWSER,
181 PpapiHostMsg_FileRef_ReadDirectoryEntries(), 178 PpapiHostMsg_FileRef_ReadDirectoryEntries(),
182 base::Bind(&FileRefResource::OnDirectoryEntriesReply, 179 base::Bind(&FileRefResource::OnDirectoryEntriesReply,
183 this, output, callback)); 180 this, output, callback));
184 return PP_OK_COMPLETIONPENDING; 181 return PP_OK_COMPLETIONPENDING;
185 } 182 }
186 183
187 /*
188 const FileRef_CreateInfo& FileRefResource::GetCreateInfo() const { 184 const FileRef_CreateInfo& FileRefResource::GetCreateInfo() const {
189 return create_info_; 185 return create_info_;
190 } 186 }
191 */
192 const PPB_FileRef_CreateInfo& FileRefResource::GetCreateInfo() const {
193 // FIXME
194 NOTREACHED();
195 PPB_FileRef_CreateInfo *info = new PPB_FileRef_CreateInfo();
196 return *info;
197 }
198
199 // TODO(teravest): Remove this when we are finished moving to the new proxy.
200 int32_t FileRefResource::QueryInHost(linked_ptr<PP_FileInfo> info,
201 scoped_refptr<TrackedCallback> callback) {
202 NOTREACHED();
203 return PP_ERROR_FAILED;
204 }
205
206 // TODO(teravest): Remove this when we are finished moving to the new proxy.
207 int32_t FileRefResource::ReadDirectoryEntriesInHost(
208 linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files,
209 linked_ptr<std::vector<PP_FileType> > file_types,
210 scoped_refptr<TrackedCallback> callback) {
211 NOTREACHED();
212 return PP_ERROR_FAILED;
213 }
214 187
215 PP_Var FileRefResource::GetAbsolutePath() { 188 PP_Var FileRefResource::GetAbsolutePath() {
216 if (!absolute_path_var_.get()) { 189 if (!absolute_path_var_.get()) {
217 std::string absolute_path; 190 std::string absolute_path;
218 int32_t result = SyncCall<PpapiPluginMsg_FileRef_GetAbsolutePathReply>( 191 int32_t result = SyncCall<PpapiPluginMsg_FileRef_GetAbsolutePathReply>(
219 BROWSER, PpapiHostMsg_FileRef_GetAbsolutePath(), &absolute_path); 192 BROWSER, PpapiHostMsg_FileRef_GetAbsolutePath(), &absolute_path);
220 if (result != PP_OK) 193 if (result != PP_OK)
221 return PP_MakeUndefined(); 194 return PP_MakeUndefined();
222 absolute_path_var_ = new StringVar(absolute_path); 195 absolute_path_var_ = new StringVar(absolute_path);
223 } 196 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 entries.push_back(entry); 243 entries.push_back(entry);
271 } 244 }
272 245
273 writer.StoreVector(entries); 246 writer.StoreVector(entries);
274 } 247 }
275 callback->Run(params.result()); 248 callback->Run(params.result());
276 } 249 }
277 250
278 } // namespace proxy 251 } // namespace proxy
279 } // namespace ppapi 252 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698