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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 249183004: Implement open_resource in non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 "components/nacl/renderer/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 private: 149 private:
150 int num_remaining_calls_; 150 int num_remaining_calls_;
151 PP_CompletionCallback callback_; 151 PP_CompletionCallback callback_;
152 int32_t result_; 152 int32_t result_;
153 153
154 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback); 154 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback);
155 }; 155 };
156 156
157 // Thin adapter from PP_ManifestService to ManifestServiceChannel::Delegate. 157 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate.
158 // Note that user_data is managed by the caller of LaunchSelLdr. Please see 158 // Note that user_data is managed by the caller of LaunchSelLdr. Please see
159 // also PP_ManifestService's comment for more details about resource 159 // also PP_ManifestService's comment for more details about resource
160 // management. 160 // management.
161 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { 161 class ManifestServiceProxy : public ManifestServiceChannel::Delegate {
162 public: 162 public:
163 ManifestServiceProxy(const PP_ManifestService* manifest_service, 163 ManifestServiceProxy(const PPP_ManifestService* manifest_service,
164 void* user_data) 164 void* user_data)
165 : manifest_service_(*manifest_service), 165 : manifest_service_(*manifest_service),
166 user_data_(user_data) { 166 user_data_(user_data) {
167 } 167 }
168 168
169 virtual ~ManifestServiceProxy() { 169 virtual ~ManifestServiceProxy() {
170 Quit(); 170 Quit();
171 } 171 }
172 172
173 virtual void StartupInitializationComplete() OVERRIDE { 173 virtual void StartupInitializationComplete() OVERRIDE {
174 if (!user_data_) 174 if (!user_data_)
175 return; 175 return;
176 176
177 if (!PP_ToBool( 177 if (!PP_ToBool(
178 manifest_service_.StartupInitializationComplete(user_data_))) { 178 manifest_service_.StartupInitializationComplete(user_data_))) {
179 user_data_ = NULL; 179 user_data_ = NULL;
180 } 180 }
181 } 181 }
182 182
183 virtual void OpenResource(
184 const std::string& key,
185 const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE {
186 if (!user_data_)
187 return;
188
189 // The allocated callback will be freed in DidOpenResource, which is always
190 // called regardless whether it succeeds or fails.
Mark Seaborn 2014/04/30 21:20:58 'it' -> 'OpenResource()' to be clearer?
hidehiko 2014/05/01 05:20:31 Done.
191 if (!PP_ToBool(manifest_service_.OpenResource(
192 user_data_,
193 key.c_str(),
194 DidOpenResource,
195 new ManifestServiceChannel::OpenResourceCallback(callback)))) {
196 user_data_ = NULL;
197 }
198 }
199
183 private: 200 private:
201 static void DidOpenResource(void* user_data, PP_FileHandle file_handle) {
202 scoped_ptr<ManifestServiceChannel::OpenResourceCallback> callback(
203 static_cast<ManifestServiceChannel::OpenResourceCallback*>(user_data));
204 callback->Run(file_handle);
205 }
206
184 void Quit() { 207 void Quit() {
185 if (!user_data_) 208 if (!user_data_)
186 return; 209 return;
187 210
188 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); 211 bool result = PP_ToBool(manifest_service_.Quit(user_data_));
189 DCHECK(!result); 212 DCHECK(!result);
190 user_data_ = NULL; 213 user_data_ = NULL;
191 } 214 }
192 215
193 PP_ManifestService manifest_service_; 216 PPP_ManifestService manifest_service_;
194 void* user_data_; 217 void* user_data_;
195 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); 218 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy);
196 }; 219 };
197 220
198 // Launch NaCl's sel_ldr process. 221 // Launch NaCl's sel_ldr process.
199 void LaunchSelLdr(PP_Instance instance, 222 void LaunchSelLdr(PP_Instance instance,
200 const char* alleged_url, 223 const char* alleged_url,
201 PP_Bool uses_irt, 224 PP_Bool uses_irt,
202 PP_Bool uses_ppapi, 225 PP_Bool uses_ppapi,
203 PP_Bool uses_nonsfi_mode, 226 PP_Bool uses_nonsfi_mode,
204 PP_Bool enable_ppapi_dev, 227 PP_Bool enable_ppapi_dev,
205 PP_Bool enable_dyncode_syscalls, 228 PP_Bool enable_dyncode_syscalls,
206 PP_Bool enable_exception_handling, 229 PP_Bool enable_exception_handling,
207 PP_Bool enable_crash_throttling, 230 PP_Bool enable_crash_throttling,
208 const PP_ManifestService* manifest_service_interface, 231 const PPP_ManifestService* manifest_service_interface,
209 void* manifest_service_user_data, 232 void* manifest_service_user_data,
210 void* imc_handle, 233 void* imc_handle,
211 struct PP_Var* error_message, 234 struct PP_Var* error_message,
212 PP_CompletionCallback callback) { 235 PP_CompletionCallback callback) {
213 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> 236 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->
214 BelongsToCurrentThread()); 237 BelongsToCurrentThread());
215 238
216 // Create the manifest service proxy here, so on error case, it will be 239 // Create the manifest service proxy here, so on error case, it will be
217 // destructed (without passing it to ManifestServiceChannel), and QUIT 240 // destructed (without passing it to ManifestServiceChannel), and QUIT
218 // will be called in its destructor so that the caller of this function 241 // will be called in its destructor so that the caller of this function
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 &DevInterfacesEnabled 909 &DevInterfacesEnabled
887 }; 910 };
888 911
889 } // namespace 912 } // namespace
890 913
891 const PPB_NaCl_Private* GetNaClPrivateInterface() { 914 const PPB_NaCl_Private* GetNaClPrivateInterface() {
892 return &nacl_interface; 915 return &nacl_interface;
893 } 916 }
894 917
895 } // namespace nacl 918 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698