diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 22:13:50 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-08 22:13:50 +0000 |
commit | dcb253d128f653364bf1ee450b2b055fafb25273 (patch) | |
tree | 07d70cc8bd8ad35a852493af41c5f0917ac61a4c /ppapi | |
parent | 5aab5e2abeb4c9bec597c789c80299730564de26 (diff) | |
download | chromium_src-dcb253d128f653364bf1ee450b2b055fafb25273.zip chromium_src-dcb253d128f653364bf1ee450b2b055fafb25273.tar.gz chromium_src-dcb253d128f653364bf1ee450b2b055fafb25273.tar.bz2 |
Implement proxying GetModuleLocalDirContents in the Flash proxy.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/5650002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/proxy/ppb_flash_proxy.cc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index fb72eb3b..248ebe9 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -41,6 +41,7 @@ IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( } return result; */ + NOTIMPLEMENTED(); *error = PP_ERROR_NOACCESS; return INVALID_HANDLE_VALUE; #elif defined(OS_POSIX) @@ -153,14 +154,32 @@ int32_t GetModuleLocalDirContents(PP_Module module, new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents( INTERFACE_ID_PPB_FLASH, module, path, &entries, &result)); - // TODO(brettw) implement this. + if (result != PP_OK) + return result; + + // Copy the serialized dir entries to the output struct. + *contents = new PP_DirContents_Dev; + (*contents)->count = static_cast<int32_t>(entries.size()); + (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; + for (size_t i = 0; i < entries.size(); i++) { + const SerializedDirEntry& source = entries[i]; + PP_DirEntry_Dev* dest = &(*contents)->entries[i]; + + char* name_copy = new char[source.name.size() + 1]; + memcpy(name_copy, source.name.c_str(), source.name.size() + 1); + dest->name = name_copy; + dest->is_dir = source.is_dir; + } return result; } void FreeModuleLocalDirContents(PP_Module module, PP_DirContents_Dev* contents) { - // TODO(brettw) implement this. + for (int32_t i = 0; i < contents->count; ++i) + delete[] contents->entries[i].name; + delete[] contents->entries; + delete contents; } bool NavigateToURL(PP_Instance pp_instance, @@ -313,7 +332,19 @@ void PPB_Flash_Proxy::OnMsgGetModuleLocalDirContents( const std::string& path, std::vector<pp::proxy::SerializedDirEntry>* entries, int32_t* result) { - // TODO(brettw) implement this. + PP_DirContents_Dev* contents = NULL; + *result = ppb_flash_target()->GetModuleLocalDirContents(module, path.c_str(), + &contents); + if (*result != PP_OK) + return; + + // Convert the list of entries to the serialized version. + entries->resize(contents->count); + for (int32_t i = 0; i < contents->count; i++) { + (*entries)[i].name.assign(contents->entries[i].name); + (*entries)[i].is_dir = contents->entries[i].is_dir; + } + ppb_flash_target()->FreeModuleLocalDirContents(module, contents); } void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance, |