Chromium Code Reviews| Index: components/nacl/renderer/ppb_nacl_private_impl.cc |
| diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc |
| index 8cfca54c63e7840a701489f85e6444099d965672..35f7888300c5c8d3b1cd09bdac335ccee7890d0c 100644 |
| --- a/components/nacl/renderer/ppb_nacl_private_impl.cc |
| +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc |
| @@ -154,13 +154,13 @@ class ChannelConnectedCallback { |
| DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback); |
| }; |
| -// Thin adapter from PP_ManifestService to ManifestServiceChannel::Delegate. |
| +// Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. |
| // Note that user_data is managed by the caller of LaunchSelLdr. Please see |
| // also PP_ManifestService's comment for more details about resource |
| // management. |
| class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
| public: |
| - ManifestServiceProxy(const PP_ManifestService* manifest_service, |
| + ManifestServiceProxy(const PPP_ManifestService* manifest_service, |
| void* user_data) |
| : manifest_service_(*manifest_service), |
| user_data_(user_data) { |
| @@ -180,7 +180,45 @@ class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
| } |
| } |
| + virtual void OpenResource( |
| + const std::string& key, |
| + const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE { |
| + if (!user_data_) |
| + return; |
| + |
| + OpenResourceCallbackData* data = new OpenResourceCallbackData(callback); |
| + if (!PP_ToBool(manifest_service_.OpenResource( |
| + user_data_, |
| + key.c_str(), |
| + &data->platform_file, |
|
dmichael (off chromium)
2014/04/25 21:06:58
nit: I think parens around data->platform_file wou
hidehiko
2014/04/28 08:44:27
Acknowledged.
|
| + PP_MakeCompletionCallback(DidOpenResource, data)))) { |
| + // When failed, callback won't be invoked, so it is necessary to free |
| + // the data. |
| + delete data; |
| + user_data_ = NULL; |
| + } |
| + |
| + // When succeeded, the callback will be called, and the data will be freed |
|
teravest
2014/04/25 20:44:02
Would it be simpler to always invoke the callback?
hidehiko
2014/04/28 08:44:27
Done.
|
| + // in the callback. |
| + } |
| + |
| private: |
| + struct OpenResourceCallbackData { |
| + explicit OpenResourceCallbackData( |
| + const ManifestServiceChannel::OpenResourceCallback& callback) |
| + : platform_file(base::kInvalidPlatformFileValue), callback(callback) { |
| + } |
| + |
| + base::PlatformFile platform_file; |
| + ManifestServiceChannel::OpenResourceCallback callback; |
| + }; |
| + |
| + static void DidOpenResource(void* user_data, int32_t pp_error) { |
| + scoped_ptr<OpenResourceCallbackData> data( |
| + static_cast<OpenResourceCallbackData*>(user_data)); |
| + data->callback.Run(pp_error, data->platform_file); |
| + } |
| + |
| void Quit() { |
| if (!user_data_) |
| return; |
| @@ -190,7 +228,7 @@ class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
| user_data_ = NULL; |
| } |
| - PP_ManifestService manifest_service_; |
| + PPP_ManifestService manifest_service_; |
| void* user_data_; |
| DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); |
| }; |
| @@ -205,7 +243,7 @@ void LaunchSelLdr(PP_Instance instance, |
| PP_Bool enable_dyncode_syscalls, |
| PP_Bool enable_exception_handling, |
| PP_Bool enable_crash_throttling, |
| - const PP_ManifestService* manifest_service_interface, |
| + const PPP_ManifestService* manifest_service_interface, |
| void* manifest_service_user_data, |
| void* imc_handle, |
| struct PP_Var* error_message, |