| 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 "ppapi/cpp/dev/file_chooser_dev.h" | 5 #include "ppapi/cpp/dev/file_chooser_dev.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "ppapi/c/dev/ppb_file_chooser_dev.h" | 9 #include "ppapi/c/dev/ppb_file_chooser_dev.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const PPB_FileChooser_Dev_0_5* chooser = | 75 const PPB_FileChooser_Dev_0_5* chooser = |
| 76 get_interface<PPB_FileChooser_Dev_0_5>(); | 76 get_interface<PPB_FileChooser_Dev_0_5>(); |
| 77 while (PP_Resource cur = chooser->GetNextChosenFile(data->file_chooser)) | 77 while (PP_Resource cur = chooser->GetNextChosenFile(data->file_chooser)) |
| 78 selected_files.push_back(cur); | 78 selected_files.push_back(cur); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Need to issue the "GetDataBuffer" even for error cases & when the | 81 // Need to issue the "GetDataBuffer" even for error cases & when the |
| 82 // number of items is 0. | 82 // number of items is 0. |
| 83 void* output_buf = data->output.GetDataBuffer( | 83 void* output_buf = data->output.GetDataBuffer( |
| 84 data->output.user_data, | 84 data->output.user_data, |
| 85 selected_files.size(), sizeof(PP_Resource)); | 85 static_cast<uint32_t>(selected_files.size()), sizeof(PP_Resource)); |
| 86 if (output_buf) { | 86 if (output_buf) { |
| 87 if (!selected_files.empty()) { | 87 if (!selected_files.empty()) { |
| 88 memcpy(output_buf, &selected_files[0], | 88 memcpy(output_buf, &selected_files[0], |
| 89 sizeof(PP_Resource) * selected_files.size()); | 89 sizeof(PP_Resource) * selected_files.size()); |
| 90 } | 90 } |
| 91 } else { | 91 } else { |
| 92 // Error allocating, need to free the resource IDs. | 92 // Error allocating, need to free the resource IDs. |
| 93 for (size_t i = 0; i < selected_files.size(); i++) | 93 for (size_t i = 0; i < selected_files.size(); i++) |
| 94 Module::Get()->core()->ReleaseResource(selected_files[i]); | 94 Module::Get()->core()->ReleaseResource(selected_files[i]); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Now execute the original callback. | 97 // Now execute the original callback. |
| 98 PP_RunCompletionCallback(&data->original_callback, result); | 98 PP_RunCompletionCallback(&data->original_callback, result); |
| 99 delete data; | 99 delete data; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace pp | 102 } // namespace pp |
| OLD | NEW |