OLD | NEW |
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 <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 LAZY_INSTANCE_INITIALIZER; | 106 LAZY_INSTANCE_INITIALIZER; |
107 | 107 |
108 nacl::NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { | 108 nacl::NexeLoadManager* GetNexeLoadManager(PP_Instance instance) { |
109 NexeLoadManagerMap& map = g_load_manager_map.Get(); | 109 NexeLoadManagerMap& map = g_load_manager_map.Get(); |
110 NexeLoadManagerMap::iterator iter = map.find(instance); | 110 NexeLoadManagerMap::iterator iter = map.find(instance); |
111 if (iter != map.end()) | 111 if (iter != map.end()) |
112 return iter->second; | 112 return iter->second; |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 | 115 |
| 116 static const PP_NaClFileInfo kInvalidNaClFileInfo = { |
| 117 PP_kInvalidFileHandle, |
| 118 0, // token_lo |
| 119 0, // token_hi |
| 120 }; |
| 121 |
116 int GetRoutingID(PP_Instance instance) { | 122 int GetRoutingID(PP_Instance instance) { |
117 // Check that we are on the main renderer thread. | 123 // Check that we are on the main renderer thread. |
118 DCHECK(content::RenderThread::Get()); | 124 DCHECK(content::RenderThread::Get()); |
119 content::RendererPpapiHost *host = | 125 content::RendererPpapiHost *host = |
120 content::RendererPpapiHost::GetForPPInstance(instance); | 126 content::RendererPpapiHost::GetForPPInstance(instance); |
121 if (!host) | 127 if (!host) |
122 return 0; | 128 return 0; |
123 return host->GetRoutingIDForWidget(instance); | 129 return host->GetRoutingIDForWidget(instance); |
124 } | 130 } |
125 | 131 |
(...skipping 12 matching lines...) Expand all Loading... |
138 return true; | 144 return true; |
139 } | 145 } |
140 | 146 |
141 void PostPPCompletionCallback(PP_CompletionCallback callback, | 147 void PostPPCompletionCallback(PP_CompletionCallback callback, |
142 int32_t status) { | 148 int32_t status) { |
143 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 149 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
144 FROM_HERE, | 150 FROM_HERE, |
145 base::Bind(callback.func, callback.user_data, status)); | 151 base::Bind(callback.func, callback.user_data, status)); |
146 } | 152 } |
147 | 153 |
| 154 bool ManifestResolveKey(PP_Instance instance, |
| 155 bool is_helper_process, |
| 156 const std::string& key, |
| 157 std::string* full_url, |
| 158 PP_PNaClOptions* pnacl_options); |
| 159 |
| 160 typedef base::Callback<void(int32_t, const PP_NaClFileInfo&)> |
| 161 DownloadFileCallback; |
| 162 |
| 163 void DownloadFile(PP_Instance instance, |
| 164 const char* url, |
| 165 const DownloadFileCallback& callback); |
| 166 |
148 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. | 167 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. |
149 // Note that user_data is managed by the caller of LaunchSelLdr. Please see | 168 // Note that user_data is managed by the caller of LaunchSelLdr. Please see |
150 // also PP_ManifestService's comment for more details about resource | 169 // also PP_ManifestService's comment for more details about resource |
151 // management. | 170 // management. |
152 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { | 171 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
153 public: | 172 public: |
154 ManifestServiceProxy(const PPP_ManifestService* manifest_service, | 173 ManifestServiceProxy(PP_Instance pp_instance, |
| 174 const PPP_ManifestService* manifest_service, |
155 void* user_data) | 175 void* user_data) |
156 : manifest_service_(*manifest_service), | 176 : pp_instance_(pp_instance), |
| 177 manifest_service_(*manifest_service), |
157 user_data_(user_data) { | 178 user_data_(user_data) { |
158 } | 179 } |
159 | 180 |
160 virtual ~ManifestServiceProxy() { | 181 virtual ~ManifestServiceProxy() { |
161 Quit(); | 182 Quit(); |
162 } | 183 } |
163 | 184 |
164 virtual void StartupInitializationComplete() OVERRIDE { | 185 virtual void StartupInitializationComplete() OVERRIDE { |
165 if (!user_data_) | 186 if (!user_data_) |
166 return; | 187 return; |
167 | 188 |
168 if (!PP_ToBool( | 189 if (!PP_ToBool( |
169 manifest_service_.StartupInitializationComplete(user_data_))) { | 190 manifest_service_.StartupInitializationComplete(user_data_))) { |
170 user_data_ = NULL; | 191 user_data_ = NULL; |
171 } | 192 } |
172 } | 193 } |
173 | 194 |
174 virtual void OpenResource( | 195 virtual void OpenResource( |
175 const std::string& key, | 196 const std::string& key, |
176 const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE { | 197 const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE { |
| 198 DCHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
| 199 BelongsToCurrentThread()); |
| 200 |
177 if (!user_data_) | 201 if (!user_data_) |
178 return; | 202 return; |
179 | 203 |
180 // The allocated callback will be freed in DidOpenResource, which is always | 204 std::string url; |
181 // called regardless whether OpenResource() succeeds or fails. | 205 // TODO(teravest): Clean up pnacl_options logic in JsonManifest so we don't |
182 if (!PP_ToBool(manifest_service_.OpenResource( | 206 // have to initialize it like this here. |
183 user_data_, | 207 PP_PNaClOptions pnacl_options; |
184 key.c_str(), | 208 pnacl_options.translate = PP_FALSE; |
185 DidOpenResource, | 209 pnacl_options.is_debug = PP_FALSE; |
186 new ManifestServiceChannel::OpenResourceCallback(callback)))) { | 210 pnacl_options.opt_level = 2; |
187 user_data_ = NULL; | 211 if (!ManifestResolveKey(pp_instance_, false, key, &url, &pnacl_options)) { |
| 212 base::MessageLoop::current()->PostTask( |
| 213 FROM_HERE, |
| 214 base::Bind(callback, PP_kInvalidFileHandle)); |
| 215 return; |
188 } | 216 } |
| 217 |
| 218 // We have to call DidDownloadFile, even if this object is destroyed, so |
| 219 // that the handle inside PP_NaClFileInfo isn't leaked. This means that the |
| 220 // callback passed to this function shouldn't have a weak pointer to an |
| 221 // object either. |
| 222 // |
| 223 // TODO(teravest): Make a type like PP_NaClFileInfo to use for DownloadFile |
| 224 // that would close the file handle on destruction. |
| 225 DownloadFile(pp_instance_, url.c_str(), |
| 226 base::Bind(&ManifestServiceProxy::DidDownloadFile, callback)); |
189 } | 227 } |
190 | 228 |
191 private: | 229 private: |
192 static void DidOpenResource(void* user_data, PP_FileHandle file_handle) { | 230 static void DidDownloadFile( |
193 scoped_ptr<ManifestServiceChannel::OpenResourceCallback> callback( | 231 ManifestServiceChannel::OpenResourceCallback callback, |
194 static_cast<ManifestServiceChannel::OpenResourceCallback*>(user_data)); | 232 int32_t pp_error, |
195 callback->Run(file_handle); | 233 const PP_NaClFileInfo& file_info) { |
| 234 if (pp_error != PP_OK) { |
| 235 callback.Run(base::kInvalidPlatformFileValue); |
| 236 return; |
| 237 } |
| 238 callback.Run(file_info.handle); |
196 } | 239 } |
197 | 240 |
198 void Quit() { | 241 void Quit() { |
199 if (!user_data_) | 242 if (!user_data_) |
200 return; | 243 return; |
201 | 244 |
202 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); | 245 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); |
203 DCHECK(!result); | 246 DCHECK(!result); |
204 user_data_ = NULL; | 247 user_data_ = NULL; |
205 } | 248 } |
206 | 249 |
| 250 PP_Instance pp_instance_; |
207 PPP_ManifestService manifest_service_; | 251 PPP_ManifestService manifest_service_; |
208 void* user_data_; | 252 void* user_data_; |
209 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); | 253 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); |
210 }; | 254 }; |
211 | 255 |
212 blink::WebURLLoader* CreateWebURLLoader(const blink::WebDocument& document, | 256 blink::WebURLLoader* CreateWebURLLoader(const blink::WebDocument& document, |
213 const GURL& gurl) { | 257 const GURL& gurl) { |
214 blink::WebURLLoaderOptions options; | 258 blink::WebURLLoaderOptions options; |
215 options.untrustedHTTP = true; | 259 options.untrustedHTTP = true; |
216 | 260 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 void* imc_handle, | 308 void* imc_handle, |
265 PP_CompletionCallback callback) { | 309 PP_CompletionCallback callback) { |
266 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 310 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
267 BelongsToCurrentThread()); | 311 BelongsToCurrentThread()); |
268 | 312 |
269 // Create the manifest service proxy here, so on error case, it will be | 313 // Create the manifest service proxy here, so on error case, it will be |
270 // destructed (without passing it to ManifestServiceChannel), and QUIT | 314 // destructed (without passing it to ManifestServiceChannel), and QUIT |
271 // will be called in its destructor so that the caller of this function | 315 // will be called in its destructor so that the caller of this function |
272 // can free manifest_service_user_data properly. | 316 // can free manifest_service_user_data properly. |
273 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( | 317 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( |
274 new ManifestServiceProxy(manifest_service_interface, | 318 new ManifestServiceProxy(instance, |
| 319 manifest_service_interface, |
275 manifest_service_user_data)); | 320 manifest_service_user_data)); |
276 | 321 |
277 FileDescriptor result_socket; | 322 FileDescriptor result_socket; |
278 IPC::Sender* sender = content::RenderThread::Get(); | 323 IPC::Sender* sender = content::RenderThread::Get(); |
279 DCHECK(sender); | 324 DCHECK(sender); |
280 int routing_id = 0; | 325 int routing_id = 0; |
281 // If the nexe uses ppapi APIs, we need a routing ID. | 326 // If the nexe uses ppapi APIs, we need a routing ID. |
282 // To get the routing ID, we must be on the main thread. | 327 // To get the routing ID, we must be on the main thread. |
283 // Some nexes do not use ppapi and launch from the background thread, | 328 // Some nexes do not use ppapi and launch from the background thread, |
284 // so those nexes can skip finding a routing_id. | 329 // so those nexes can skip finding a routing_id. |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 if (load_manager) | 1067 if (load_manager) |
1023 load_manager->ReportLoadError(error_info.error, error_info.string); | 1068 load_manager->ReportLoadError(error_info.error, error_info.string); |
1024 return PP_FALSE; | 1069 return PP_FALSE; |
1025 } | 1070 } |
1026 | 1071 |
1027 bool ManifestResolveKey(PP_Instance instance, | 1072 bool ManifestResolveKey(PP_Instance instance, |
1028 bool is_helper_process, | 1073 bool is_helper_process, |
1029 const std::string& key, | 1074 const std::string& key, |
1030 std::string* full_url, | 1075 std::string* full_url, |
1031 PP_PNaClOptions* pnacl_options) { | 1076 PP_PNaClOptions* pnacl_options) { |
1032 // For "helper" processes (llc and ld), we resolve keys manually as there is | 1077 // For "helper" processes (llc and ld, for PNaCl translation), we resolve |
1033 // no existing .nmf file to parse. | 1078 // keys manually as there is no existing .nmf file to parse. |
1034 if (is_helper_process) { | 1079 if (is_helper_process) { |
1035 pnacl_options->translate = PP_FALSE; | 1080 pnacl_options->translate = PP_FALSE; |
1036 // We can only resolve keys in the files/ namespace. | 1081 // We can only resolve keys in the files/ namespace. |
1037 const std::string kFilesPrefix = "files/"; | 1082 const std::string kFilesPrefix = "files/"; |
1038 if (key.find(kFilesPrefix) == std::string::npos) { | 1083 if (key.find(kFilesPrefix) == std::string::npos) { |
1039 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1084 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1040 if (load_manager) | 1085 if (load_manager) |
1041 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 1086 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
1042 "key did not start with files/"); | 1087 "key did not start with files/"); |
1043 return false; | 1088 return false; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 } | 1406 } |
1362 | 1407 |
1363 if (pp_error == PP_OK && target_file.IsValid()) | 1408 if (pp_error == PP_OK && target_file.IsValid()) |
1364 out_file_info->handle = target_file.TakePlatformFile(); | 1409 out_file_info->handle = target_file.TakePlatformFile(); |
1365 else | 1410 else |
1366 out_file_info->handle = PP_kInvalidFileHandle; | 1411 out_file_info->handle = PP_kInvalidFileHandle; |
1367 | 1412 |
1368 request.callback.func(request.callback.user_data, pp_error); | 1413 request.callback.func(request.callback.user_data, pp_error); |
1369 } | 1414 } |
1370 | 1415 |
1371 void DownloadFileCompletion(PP_NaClFileInfo* file_info, | 1416 void DownloadFileCompletion( |
1372 PP_CompletionCallback callback, | 1417 const DownloadFileCallback& callback, |
1373 FileDownloader::Status status, | 1418 FileDownloader::Status status, |
1374 base::File file, | 1419 base::File file, |
1375 int http_status) { | 1420 int http_status) { |
1376 int32_t pp_error = FileDownloaderToPepperError(status); | 1421 int32_t pp_error = FileDownloaderToPepperError(status); |
| 1422 PP_NaClFileInfo file_info; |
1377 if (pp_error == PP_OK) { | 1423 if (pp_error == PP_OK) { |
1378 file_info->handle = file.TakePlatformFile(); | 1424 file_info.handle = file.TakePlatformFile(); |
1379 file_info->token_lo = 0; | 1425 file_info.token_lo = 0; |
1380 file_info->token_hi = 0; | 1426 file_info.token_hi = 0; |
| 1427 } else { |
| 1428 file_info = kInvalidNaClFileInfo; |
1381 } | 1429 } |
1382 callback.func(callback.user_data, pp_error); | 1430 |
| 1431 callback.Run(pp_error, file_info); |
1383 } | 1432 } |
1384 | 1433 |
1385 void DownloadFile(PP_Instance instance, | 1434 void DownloadFile(PP_Instance instance, |
1386 const char* url, | 1435 const char* url, |
1387 struct PP_NaClFileInfo* file_info, | 1436 const DownloadFileCallback& callback) { |
1388 struct PP_CompletionCallback callback) { | 1437 DCHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
| 1438 BelongsToCurrentThread()); |
1389 CHECK(url); | 1439 CHECK(url); |
1390 CHECK(file_info); | |
1391 | 1440 |
1392 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1441 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1393 DCHECK(load_manager); | 1442 DCHECK(load_manager); |
1394 if (!load_manager) { | 1443 if (!load_manager) { |
1395 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1444 base::MessageLoop::current()->PostTask( |
1396 FROM_HERE, | 1445 FROM_HERE, |
1397 base::Bind(callback.func, callback.user_data, | 1446 base::Bind(callback, |
1398 static_cast<int32_t>(PP_ERROR_FAILED))); | 1447 static_cast<int32_t>(PP_ERROR_FAILED), |
| 1448 kInvalidNaClFileInfo)); |
1399 return; | 1449 return; |
1400 } | 1450 } |
1401 | 1451 |
1402 // Handle special PNaCl support files which are installed on the user's | 1452 // Handle special PNaCl support files which are installed on the user's |
1403 // machine. | 1453 // machine. |
1404 std::string url_string(url); | 1454 std::string url_string(url); |
1405 if (url_string.find(kPNaClTranslatorBaseUrl, 0) == 0) { | 1455 if (url_string.find(kPNaClTranslatorBaseUrl, 0) == 0) { |
1406 PP_FileHandle handle = GetReadonlyPnaclFd(url); | 1456 PP_FileHandle handle = GetReadonlyPnaclFd(url); |
1407 if (handle == PP_kInvalidFileHandle) { | 1457 if (handle == PP_kInvalidFileHandle) { |
1408 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1458 base::MessageLoop::current()->PostTask( |
1409 FROM_HERE, | 1459 FROM_HERE, |
1410 base::Bind(callback.func, callback.user_data, | 1460 base::Bind(callback, |
1411 static_cast<int32_t>(PP_ERROR_FAILED))); | 1461 static_cast<int32_t>(PP_ERROR_FAILED), |
| 1462 kInvalidNaClFileInfo)); |
1412 return; | 1463 return; |
1413 } | 1464 } |
1414 // TODO(ncbray): enable the fast loading and validation paths for this type | 1465 // TODO(ncbray): enable the fast loading and validation paths for this type |
1415 // of file. | 1466 // of file. |
1416 file_info->handle = handle; | 1467 PP_NaClFileInfo file_info; |
1417 file_info->token_lo = 0; | 1468 file_info.handle = handle; |
1418 file_info->token_hi = 0; | 1469 file_info.token_lo = 0; |
1419 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1470 file_info.token_hi = 0; |
| 1471 base::MessageLoop::current()->PostTask( |
1420 FROM_HERE, | 1472 FROM_HERE, |
1421 base::Bind(callback.func, callback.user_data, | 1473 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); |
1422 static_cast<int32_t>(PP_OK))); | |
1423 return; | 1474 return; |
1424 } | 1475 } |
1425 | 1476 |
1426 // We have to ensure that this url resolves relative to the plugin base url | 1477 // We have to ensure that this url resolves relative to the plugin base url |
1427 // before downloading it. | 1478 // before downloading it. |
1428 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); | 1479 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); |
1429 if (!test_gurl.is_valid()) { | 1480 if (!test_gurl.is_valid()) { |
1430 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1481 base::MessageLoop::current()->PostTask( |
1431 FROM_HERE, | 1482 FROM_HERE, |
1432 base::Bind(callback.func, callback.user_data, | 1483 base::Bind(callback, |
1433 static_cast<int32_t>(PP_ERROR_FAILED))); | 1484 static_cast<int32_t>(PP_ERROR_FAILED), |
| 1485 kInvalidNaClFileInfo)); |
1434 return; | 1486 return; |
1435 } | 1487 } |
1436 | 1488 |
1437 // Try the fast path for retrieving the file first. | 1489 // Try the fast path for retrieving the file first. |
1438 uint64_t file_token_lo = 0; | 1490 uint64_t file_token_lo = 0; |
1439 uint64_t file_token_hi = 0; | 1491 uint64_t file_token_hi = 0; |
1440 PP_FileHandle file_handle = OpenNaClExecutable(instance, | 1492 PP_FileHandle file_handle = OpenNaClExecutable(instance, |
1441 url, | 1493 url, |
1442 &file_token_lo, | 1494 &file_token_lo, |
1443 &file_token_hi); | 1495 &file_token_hi); |
1444 if (file_handle != PP_kInvalidFileHandle) { | 1496 if (file_handle != PP_kInvalidFileHandle) { |
1445 file_info->handle = file_handle; | 1497 PP_NaClFileInfo file_info; |
1446 file_info->token_lo = file_token_lo; | 1498 file_info.handle = file_handle; |
1447 file_info->token_hi = file_token_hi; | 1499 file_info.token_lo = file_token_lo; |
1448 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1500 file_info.token_hi = file_token_hi; |
| 1501 base::MessageLoop::current()->PostTask( |
1449 FROM_HERE, | 1502 FROM_HERE, |
1450 base::Bind(callback.func, callback.user_data, | 1503 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); |
1451 static_cast<int32_t>(PP_OK))); | |
1452 return; | 1504 return; |
1453 } | 1505 } |
1454 | 1506 |
1455 // The fast path didn't work, we'll fetch the file using URLLoader and write | 1507 // The fast path didn't work, we'll fetch the file using URLLoader and write |
1456 // it to local storage. | 1508 // it to local storage. |
1457 base::File target_file(CreateTemporaryFile(instance)); | 1509 base::File target_file(CreateTemporaryFile(instance)); |
1458 GURL gurl(url); | 1510 GURL gurl(url); |
1459 | 1511 |
1460 content::PepperPluginInstance* plugin_instance = | 1512 content::PepperPluginInstance* plugin_instance = |
1461 content::PepperPluginInstance::Get(instance); | 1513 content::PepperPluginInstance::Get(instance); |
1462 if (!plugin_instance) { | 1514 if (!plugin_instance) { |
1463 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1515 base::MessageLoop::current()->PostTask( |
1464 FROM_HERE, | 1516 FROM_HERE, |
1465 base::Bind(callback.func, callback.user_data, | 1517 base::Bind(callback, |
1466 static_cast<int32_t>(PP_ERROR_FAILED))); | 1518 static_cast<int32_t>(PP_ERROR_FAILED), |
| 1519 kInvalidNaClFileInfo)); |
1467 } | 1520 } |
1468 const blink::WebDocument& document = | 1521 const blink::WebDocument& document = |
1469 plugin_instance->GetContainer()->element().document(); | 1522 plugin_instance->GetContainer()->element().document(); |
1470 scoped_ptr<blink::WebURLLoader> url_loader( | 1523 scoped_ptr<blink::WebURLLoader> url_loader( |
1471 CreateWebURLLoader(document, gurl)); | 1524 CreateWebURLLoader(document, gurl)); |
1472 blink::WebURLRequest url_request = CreateWebURLRequest(document, gurl); | 1525 blink::WebURLRequest url_request = CreateWebURLRequest(document, gurl); |
1473 | 1526 |
1474 ProgressEventRateLimiter* tracker = new ProgressEventRateLimiter(instance); | 1527 ProgressEventRateLimiter* tracker = new ProgressEventRateLimiter(instance); |
1475 | 1528 |
1476 // FileDownloader deletes itself after invoking DownloadNexeCompletion. | 1529 // FileDownloader deletes itself after invoking DownloadNexeCompletion. |
1477 FileDownloader* file_downloader = new FileDownloader( | 1530 FileDownloader* file_downloader = new FileDownloader( |
1478 url_loader.Pass(), | 1531 url_loader.Pass(), |
1479 target_file.Pass(), | 1532 target_file.Pass(), |
1480 base::Bind(&DownloadFileCompletion, file_info, callback), | 1533 base::Bind(&DownloadFileCompletion, callback), |
1481 base::Bind(&ProgressEventRateLimiter::ReportProgress, | 1534 base::Bind(&ProgressEventRateLimiter::ReportProgress, |
1482 base::Owned(tracker), url)); | 1535 base::Owned(tracker), url)); |
1483 file_downloader->Load(url_request); | 1536 file_downloader->Load(url_request); |
1484 } | 1537 } |
1485 | 1538 |
| 1539 void ExternalDownloadFileCompletion(struct PP_NaClFileInfo* out_file_info, |
| 1540 struct PP_CompletionCallback callback, |
| 1541 int32_t pp_error, |
| 1542 const PP_NaClFileInfo& file_info) { |
| 1543 if (pp_error == PP_OK) |
| 1544 *out_file_info = file_info; |
| 1545 callback.func(callback.user_data, pp_error); |
| 1546 } |
| 1547 |
| 1548 void ExternalDownloadFile(PP_Instance instance, |
| 1549 const char* url, |
| 1550 struct PP_NaClFileInfo* file_info, |
| 1551 struct PP_CompletionCallback callback) { |
| 1552 DCHECK(callback.func); |
| 1553 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
| 1554 BelongsToCurrentThread()); |
| 1555 DownloadFile(instance, url, |
| 1556 base::Bind(&ExternalDownloadFileCompletion, |
| 1557 file_info, |
| 1558 callback)); |
| 1559 } |
| 1560 |
1486 void ReportSelLdrStatus(PP_Instance instance, | 1561 void ReportSelLdrStatus(PP_Instance instance, |
1487 int32_t load_status, | 1562 int32_t load_status, |
1488 int32_t max_status) { | 1563 int32_t max_status) { |
1489 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); | 1564 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); |
1490 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1565 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1491 DCHECK(load_manager); | 1566 DCHECK(load_manager); |
1492 if (!load_manager) | 1567 if (!load_manager) |
1493 return; | 1568 return; |
1494 | 1569 |
1495 // Gather data to see if being installed changes load outcomes. | 1570 // Gather data to see if being installed changes load outcomes. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 &RequestNaClManifest, | 1614 &RequestNaClManifest, |
1540 &GetManifestBaseURL, | 1615 &GetManifestBaseURL, |
1541 &ProcessNaClManifest, | 1616 &ProcessNaClManifest, |
1542 &DevInterfacesEnabled, | 1617 &DevInterfacesEnabled, |
1543 &ManifestGetProgramURL, | 1618 &ManifestGetProgramURL, |
1544 &ExternalManifestResolveKey, | 1619 &ExternalManifestResolveKey, |
1545 &GetPNaClResourceInfo, | 1620 &GetPNaClResourceInfo, |
1546 &GetCpuFeatureAttrs, | 1621 &GetCpuFeatureAttrs, |
1547 &PostMessageToJavaScript, | 1622 &PostMessageToJavaScript, |
1548 &DownloadNexe, | 1623 &DownloadNexe, |
1549 &DownloadFile, | 1624 &ExternalDownloadFile, |
1550 &ReportSelLdrStatus, | 1625 &ReportSelLdrStatus, |
1551 &LogTranslateTime | 1626 &LogTranslateTime |
1552 }; | 1627 }; |
1553 | 1628 |
1554 } // namespace | 1629 } // namespace |
1555 | 1630 |
1556 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1631 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1557 return &nacl_interface; | 1632 return &nacl_interface; |
1558 } | 1633 } |
1559 | 1634 |
1560 } // namespace nacl | 1635 } // namespace nacl |
OLD | NEW |