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 PP_NaClFileInfo MakeInvalidNaClFileInfo() { | |
hidehiko
2014/06/18 04:43:11
Just FYI:
How about using a constant here?
const
teravest
2014/06/18 20:13:43
Done.
| |
117 PP_NaClFileInfo info; | |
118 info.handle = PP_kInvalidFileHandle; | |
119 info.token_lo = 0; | |
120 info.token_hi = 0; | |
121 return info; | |
122 } | |
123 | |
116 int GetRoutingID(PP_Instance instance) { | 124 int GetRoutingID(PP_Instance instance) { |
117 // Check that we are on the main renderer thread. | 125 // Check that we are on the main renderer thread. |
118 DCHECK(content::RenderThread::Get()); | 126 DCHECK(content::RenderThread::Get()); |
119 content::RendererPpapiHost *host = | 127 content::RendererPpapiHost *host = |
120 content::RendererPpapiHost::GetForPPInstance(instance); | 128 content::RendererPpapiHost::GetForPPInstance(instance); |
121 if (!host) | 129 if (!host) |
122 return 0; | 130 return 0; |
123 return host->GetRoutingIDForWidget(instance); | 131 return host->GetRoutingIDForWidget(instance); |
124 } | 132 } |
125 | 133 |
(...skipping 12 matching lines...) Expand all Loading... | |
138 return true; | 146 return true; |
139 } | 147 } |
140 | 148 |
141 void PostPPCompletionCallback(PP_CompletionCallback callback, | 149 void PostPPCompletionCallback(PP_CompletionCallback callback, |
142 int32_t status) { | 150 int32_t status) { |
143 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 151 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
144 FROM_HERE, | 152 FROM_HERE, |
145 base::Bind(callback.func, callback.user_data, status)); | 153 base::Bind(callback.func, callback.user_data, status)); |
146 } | 154 } |
147 | 155 |
156 bool ManifestResolveKey(PP_Instance instance, | |
hidehiko
2014/06/18 04:43:11
I'm rarely see this kind of forward declaration. C
teravest
2014/06/18 20:13:43
I don't think so; I could try to reorganize the fi
| |
157 bool is_helper_process, | |
158 const std::string& key, | |
159 std::string* full_url, | |
160 PP_PNaClOptions* pnacl_options); | |
161 | |
162 void DownloadFile(PP_Instance instance, | |
163 const char* url, | |
164 base::Callback<void(int32_t, PP_NaClFileInfo)> callback); | |
hidehiko
2014/06/18 04:43:11
const PP_NaClFileInfo& ? Ditto for below.
teravest
2014/06/18 20:13:44
Done.
| |
165 | |
148 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. | 166 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. |
149 // Note that user_data is managed by the caller of LaunchSelLdr. Please see | 167 // Note that user_data is managed by the caller of LaunchSelLdr. Please see |
150 // also PP_ManifestService's comment for more details about resource | 168 // also PP_ManifestService's comment for more details about resource |
151 // management. | 169 // management. |
152 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { | 170 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
153 public: | 171 public: |
154 ManifestServiceProxy(const PPP_ManifestService* manifest_service, | 172 ManifestServiceProxy(PP_Instance pp_instance, |
173 const PPP_ManifestService* manifest_service, | |
155 void* user_data) | 174 void* user_data) |
156 : manifest_service_(*manifest_service), | 175 : pp_instance_(pp_instance), |
157 user_data_(user_data) { | 176 manifest_service_(*manifest_service), |
177 user_data_(user_data), | |
178 weak_factory_(this) { | |
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 { |
177 if (!user_data_) | 198 if (!user_data_) |
178 return; | 199 return; |
179 | 200 |
180 // The allocated callback will be freed in DidOpenResource, which is always | 201 std::string url; |
181 // called regardless whether OpenResource() succeeds or fails. | 202 PP_PNaClOptions pnacl_options = {PP_FALSE, PP_FALSE, 2}; |
dmichael (off chromium)
2014/06/17 21:52:28
nit: This would be more readable if you zero-initi
teravest
2014/06/18 20:13:44
Done.
| |
182 if (!PP_ToBool(manifest_service_.OpenResource( | 203 if (!ManifestResolveKey(pp_instance_, false, key, &url, &pnacl_options)) { |
183 user_data_, | 204 base::MessageLoop::current()->PostTask( |
184 key.c_str(), | 205 FROM_HERE, |
185 DidOpenResource, | 206 base::Bind(callback, PP_kInvalidFileHandle)); |
186 new ManifestServiceChannel::OpenResourceCallback(callback)))) { | 207 return; |
187 user_data_ = NULL; | |
188 } | 208 } |
209 | |
210 DownloadFile(pp_instance_, url.c_str(), | |
211 base::Bind(&ManifestServiceProxy::DidDownloadFile, | |
212 weak_factory_.GetWeakPtr(), | |
213 callback)); | |
189 } | 214 } |
190 | 215 |
191 private: | 216 private: |
192 static void DidOpenResource(void* user_data, PP_FileHandle file_handle) { | 217 void DidDownloadFile(ManifestServiceChannel::OpenResourceCallback callback, |
hidehiko
2014/06/18 04:43:11
Can be static? Or is it intentional change that th
teravest
2014/06/18 20:13:44
Changed this to be static. It's better without the
| |
193 scoped_ptr<ManifestServiceChannel::OpenResourceCallback> callback( | 218 int32_t pp_error, |
194 static_cast<ManifestServiceChannel::OpenResourceCallback*>(user_data)); | 219 PP_NaClFileInfo file_info) { |
195 callback->Run(file_handle); | 220 if (pp_error != PP_OK) { |
221 callback.Run(base::kInvalidPlatformFileValue); | |
222 return; | |
223 } | |
224 callback.Run(file_info.handle); | |
196 } | 225 } |
197 | 226 |
198 void Quit() { | 227 void Quit() { |
199 if (!user_data_) | 228 if (!user_data_) |
200 return; | 229 return; |
201 | 230 |
202 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); | 231 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); |
203 DCHECK(!result); | 232 DCHECK(!result); |
204 user_data_ = NULL; | 233 user_data_ = NULL; |
205 } | 234 } |
206 | 235 |
236 PP_Instance pp_instance_; | |
207 PPP_ManifestService manifest_service_; | 237 PPP_ManifestService manifest_service_; |
208 void* user_data_; | 238 void* user_data_; |
239 base::WeakPtrFactory<ManifestServiceProxy> weak_factory_; | |
240 | |
209 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); | 241 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); |
210 }; | 242 }; |
211 | 243 |
212 blink::WebURLLoader* CreateWebURLLoader(const blink::WebDocument& document, | 244 blink::WebURLLoader* CreateWebURLLoader(const blink::WebDocument& document, |
213 const GURL& gurl) { | 245 const GURL& gurl) { |
214 blink::WebURLLoaderOptions options; | 246 blink::WebURLLoaderOptions options; |
215 options.untrustedHTTP = true; | 247 options.untrustedHTTP = true; |
216 | 248 |
217 // Options settings here follow the original behavior in the trusted | 249 // Options settings here follow the original behavior in the trusted |
218 // plugin and PepperURLLoaderHost. | 250 // plugin and PepperURLLoaderHost. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 void* imc_handle, | 296 void* imc_handle, |
265 PP_CompletionCallback callback) { | 297 PP_CompletionCallback callback) { |
266 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 298 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
267 BelongsToCurrentThread()); | 299 BelongsToCurrentThread()); |
268 | 300 |
269 // Create the manifest service proxy here, so on error case, it will be | 301 // Create the manifest service proxy here, so on error case, it will be |
270 // destructed (without passing it to ManifestServiceChannel), and QUIT | 302 // destructed (without passing it to ManifestServiceChannel), and QUIT |
271 // will be called in its destructor so that the caller of this function | 303 // will be called in its destructor so that the caller of this function |
272 // can free manifest_service_user_data properly. | 304 // can free manifest_service_user_data properly. |
273 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( | 305 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( |
274 new ManifestServiceProxy(manifest_service_interface, | 306 new ManifestServiceProxy(instance, |
307 manifest_service_interface, | |
275 manifest_service_user_data)); | 308 manifest_service_user_data)); |
276 | 309 |
277 FileDescriptor result_socket; | 310 FileDescriptor result_socket; |
278 IPC::Sender* sender = content::RenderThread::Get(); | 311 IPC::Sender* sender = content::RenderThread::Get(); |
279 DCHECK(sender); | 312 DCHECK(sender); |
280 int routing_id = 0; | 313 int routing_id = 0; |
281 // If the nexe uses ppapi APIs, we need a routing ID. | 314 // If the nexe uses ppapi APIs, we need a routing ID. |
282 // To get the routing ID, we must be on the main thread. | 315 // 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, | 316 // Some nexes do not use ppapi and launch from the background thread, |
284 // so those nexes can skip finding a routing_id. | 317 // 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) | 1055 if (load_manager) |
1023 load_manager->ReportLoadError(error_info.error, error_info.string); | 1056 load_manager->ReportLoadError(error_info.error, error_info.string); |
1024 return PP_FALSE; | 1057 return PP_FALSE; |
1025 } | 1058 } |
1026 | 1059 |
1027 bool ManifestResolveKey(PP_Instance instance, | 1060 bool ManifestResolveKey(PP_Instance instance, |
1028 bool is_helper_process, | 1061 bool is_helper_process, |
1029 const std::string& key, | 1062 const std::string& key, |
1030 std::string* full_url, | 1063 std::string* full_url, |
1031 PP_PNaClOptions* pnacl_options) { | 1064 PP_PNaClOptions* pnacl_options) { |
1032 // For "helper" processes (llc and ld), we resolve keys manually as there is | 1065 // For "helper" processes (llc and ld), we resolve keys manually as there is |
hidehiko
2014/06/18 04:43:11
Update this comment, too?
teravest
2014/06/18 20:13:43
Not exactly sure what you want here, but I did upd
| |
1033 // no existing .nmf file to parse. | 1066 // no existing .nmf file to parse. |
1034 if (is_helper_process) { | 1067 if (is_helper_process) { |
1035 pnacl_options->translate = PP_FALSE; | 1068 pnacl_options->translate = PP_FALSE; |
1036 // We can only resolve keys in the files/ namespace. | 1069 // We can only resolve keys in the files/ namespace. |
1037 const std::string kFilesPrefix = "files/"; | 1070 const std::string kFilesPrefix = "files/"; |
1038 if (key.find(kFilesPrefix) == std::string::npos) { | 1071 if (key.find(kFilesPrefix) == std::string::npos) { |
1039 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1072 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1040 if (load_manager) | 1073 if (load_manager) |
1041 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, | 1074 load_manager->ReportLoadError(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, |
1042 "key did not start with files/"); | 1075 "key did not start with files/"); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1361 } | 1394 } |
1362 | 1395 |
1363 if (pp_error == PP_OK && target_file.IsValid()) | 1396 if (pp_error == PP_OK && target_file.IsValid()) |
1364 out_file_info->handle = target_file.TakePlatformFile(); | 1397 out_file_info->handle = target_file.TakePlatformFile(); |
1365 else | 1398 else |
1366 out_file_info->handle = PP_kInvalidFileHandle; | 1399 out_file_info->handle = PP_kInvalidFileHandle; |
1367 | 1400 |
1368 request.callback.func(request.callback.user_data, pp_error); | 1401 request.callback.func(request.callback.user_data, pp_error); |
1369 } | 1402 } |
1370 | 1403 |
1371 void DownloadFileCompletion(PP_NaClFileInfo* file_info, | 1404 void DownloadFileCompletion( |
1372 PP_CompletionCallback callback, | 1405 base::Callback<void(int32_t, PP_NaClFileInfo)> callback, |
1373 FileDownloader::Status status, | 1406 FileDownloader::Status status, |
1374 base::File file, | 1407 base::File file, |
1375 int http_status) { | 1408 int http_status) { |
1376 int32_t pp_error = FileDownloaderToPepperError(status); | 1409 int32_t pp_error = FileDownloaderToPepperError(status); |
1377 if (pp_error == PP_OK) { | 1410 PP_NaClFileInfo file_info = MakeInvalidNaClFileInfo(); |
1378 file_info->handle = file.TakePlatformFile(); | 1411 if (pp_error == PP_OK) |
1379 file_info->token_lo = 0; | 1412 file_info.handle = file.TakePlatformFile(); |
hidehiko
2014/06/18 04:43:11
Setting the platform file handle to invalid file i
teravest
2014/06/18 20:13:44
Done.
| |
1380 file_info->token_hi = 0; | 1413 callback.Run(pp_error, file_info); |
1381 } | |
1382 callback.func(callback.user_data, pp_error); | |
1383 } | 1414 } |
1384 | 1415 |
1385 void DownloadFile(PP_Instance instance, | 1416 void DownloadFile(PP_Instance instance, |
1386 const char* url, | 1417 const char* url, |
1387 struct PP_NaClFileInfo* file_info, | 1418 base::Callback<void(int32_t, PP_NaClFileInfo)> callback) { |
1388 struct PP_CompletionCallback callback) { | |
1389 CHECK(url); | 1419 CHECK(url); |
1390 CHECK(file_info); | |
1391 | 1420 |
1392 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1421 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1393 DCHECK(load_manager); | 1422 DCHECK(load_manager); |
1394 if (!load_manager) { | 1423 if (!load_manager) { |
1395 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1424 base::MessageLoop::current()->PostTask( |
dmichael (off chromium)
2014/06/17 21:52:28
Is this only a cosmetic change, or are you trying
teravest
2014/06/18 20:13:44
Done.
| |
1396 FROM_HERE, | 1425 FROM_HERE, |
1397 base::Bind(callback.func, callback.user_data, | 1426 base::Bind(callback, |
1398 static_cast<int32_t>(PP_ERROR_FAILED))); | 1427 static_cast<int32_t>(PP_ERROR_FAILED), |
1428 MakeInvalidNaClFileInfo())); | |
1399 return; | 1429 return; |
1400 } | 1430 } |
1401 | 1431 |
1402 // Handle special PNaCl support files which are installed on the user's | 1432 // Handle special PNaCl support files which are installed on the user's |
1403 // machine. | 1433 // machine. |
1404 std::string url_string(url); | 1434 std::string url_string(url); |
1405 if (url_string.find(kPNaClTranslatorBaseUrl, 0) == 0) { | 1435 if (url_string.find(kPNaClTranslatorBaseUrl, 0) == 0) { |
1406 PP_FileHandle handle = GetReadonlyPnaclFd(url); | 1436 PP_FileHandle handle = GetReadonlyPnaclFd(url); |
1407 if (handle == PP_kInvalidFileHandle) { | 1437 if (handle == PP_kInvalidFileHandle) { |
1408 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1438 base::MessageLoop::current()->PostTask( |
1409 FROM_HERE, | 1439 FROM_HERE, |
1410 base::Bind(callback.func, callback.user_data, | 1440 base::Bind(callback, |
1411 static_cast<int32_t>(PP_ERROR_FAILED))); | 1441 static_cast<int32_t>(PP_ERROR_FAILED), |
1442 MakeInvalidNaClFileInfo())); | |
1412 return; | 1443 return; |
1413 } | 1444 } |
1414 // TODO(ncbray): enable the fast loading and validation paths for this type | 1445 // TODO(ncbray): enable the fast loading and validation paths for this type |
1415 // of file. | 1446 // of file. |
1416 file_info->handle = handle; | 1447 PP_NaClFileInfo file_info; |
1417 file_info->token_lo = 0; | 1448 file_info.handle = handle; |
1418 file_info->token_hi = 0; | 1449 file_info.token_lo = 0; |
1419 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1450 file_info.token_hi = 0; |
1451 base::MessageLoop::current()->PostTask( | |
1420 FROM_HERE, | 1452 FROM_HERE, |
1421 base::Bind(callback.func, callback.user_data, | 1453 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); |
1422 static_cast<int32_t>(PP_OK))); | |
1423 return; | 1454 return; |
1424 } | 1455 } |
1425 | 1456 |
1426 // We have to ensure that this url resolves relative to the plugin base url | 1457 // We have to ensure that this url resolves relative to the plugin base url |
1427 // before downloading it. | 1458 // before downloading it. |
1428 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); | 1459 const GURL& test_gurl = load_manager->plugin_base_url().Resolve(url); |
1429 if (!test_gurl.is_valid()) { | 1460 if (!test_gurl.is_valid()) { |
1430 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1461 base::MessageLoop::current()->PostTask( |
1431 FROM_HERE, | 1462 FROM_HERE, |
1432 base::Bind(callback.func, callback.user_data, | 1463 base::Bind(callback, |
1433 static_cast<int32_t>(PP_ERROR_FAILED))); | 1464 static_cast<int32_t>(PP_ERROR_FAILED), |
1465 MakeInvalidNaClFileInfo())); | |
1434 return; | 1466 return; |
1435 } | 1467 } |
1436 | 1468 |
1437 // Try the fast path for retrieving the file first. | 1469 // Try the fast path for retrieving the file first. |
1438 uint64_t file_token_lo = 0; | 1470 uint64_t file_token_lo = 0; |
1439 uint64_t file_token_hi = 0; | 1471 uint64_t file_token_hi = 0; |
1440 PP_FileHandle file_handle = OpenNaClExecutable(instance, | 1472 PP_FileHandle file_handle = OpenNaClExecutable(instance, |
1441 url, | 1473 url, |
1442 &file_token_lo, | 1474 &file_token_lo, |
1443 &file_token_hi); | 1475 &file_token_hi); |
1444 if (file_handle != PP_kInvalidFileHandle) { | 1476 if (file_handle != PP_kInvalidFileHandle) { |
1445 file_info->handle = file_handle; | 1477 PP_NaClFileInfo file_info; |
1446 file_info->token_lo = file_token_lo; | 1478 file_info.handle = file_handle; |
1447 file_info->token_hi = file_token_hi; | 1479 file_info.token_lo = file_token_lo; |
1448 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1480 file_info.token_hi = file_token_hi; |
1481 base::MessageLoop::current()->PostTask( | |
1449 FROM_HERE, | 1482 FROM_HERE, |
1450 base::Bind(callback.func, callback.user_data, | 1483 base::Bind(callback, static_cast<int32_t>(PP_OK), file_info)); |
1451 static_cast<int32_t>(PP_OK))); | |
1452 return; | 1484 return; |
1453 } | 1485 } |
1454 | 1486 |
1455 // The fast path didn't work, we'll fetch the file using URLLoader and write | 1487 // The fast path didn't work, we'll fetch the file using URLLoader and write |
1456 // it to local storage. | 1488 // it to local storage. |
1457 base::File target_file(CreateTemporaryFile(instance)); | 1489 base::File target_file(CreateTemporaryFile(instance)); |
1458 GURL gurl(url); | 1490 GURL gurl(url); |
1459 | 1491 |
1460 content::PepperPluginInstance* plugin_instance = | 1492 content::PepperPluginInstance* plugin_instance = |
1461 content::PepperPluginInstance::Get(instance); | 1493 content::PepperPluginInstance::Get(instance); |
1462 if (!plugin_instance) { | 1494 if (!plugin_instance) { |
1463 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 1495 base::MessageLoop::current()->PostTask( |
1464 FROM_HERE, | 1496 FROM_HERE, |
1465 base::Bind(callback.func, callback.user_data, | 1497 base::Bind(callback, |
1466 static_cast<int32_t>(PP_ERROR_FAILED))); | 1498 static_cast<int32_t>(PP_ERROR_FAILED), |
1499 MakeInvalidNaClFileInfo())); | |
1467 } | 1500 } |
1468 const blink::WebDocument& document = | 1501 const blink::WebDocument& document = |
1469 plugin_instance->GetContainer()->element().document(); | 1502 plugin_instance->GetContainer()->element().document(); |
1470 scoped_ptr<blink::WebURLLoader> url_loader( | 1503 scoped_ptr<blink::WebURLLoader> url_loader( |
1471 CreateWebURLLoader(document, gurl)); | 1504 CreateWebURLLoader(document, gurl)); |
1472 blink::WebURLRequest url_request = CreateWebURLRequest(document, gurl); | 1505 blink::WebURLRequest url_request = CreateWebURLRequest(document, gurl); |
1473 | 1506 |
1474 ProgressEventRateLimiter* tracker = new ProgressEventRateLimiter(instance); | 1507 ProgressEventRateLimiter* tracker = new ProgressEventRateLimiter(instance); |
1475 | 1508 |
1476 // FileDownloader deletes itself after invoking DownloadNexeCompletion. | 1509 // FileDownloader deletes itself after invoking DownloadNexeCompletion. |
1477 FileDownloader* file_downloader = new FileDownloader( | 1510 FileDownloader* file_downloader = new FileDownloader( |
1478 url_loader.Pass(), | 1511 url_loader.Pass(), |
1479 target_file.Pass(), | 1512 target_file.Pass(), |
1480 base::Bind(&DownloadFileCompletion, file_info, callback), | 1513 base::Bind(&DownloadFileCompletion, callback), |
1481 base::Bind(&ProgressEventRateLimiter::ReportProgress, | 1514 base::Bind(&ProgressEventRateLimiter::ReportProgress, |
1482 base::Owned(tracker), url)); | 1515 base::Owned(tracker), url)); |
1483 file_downloader->Load(url_request); | 1516 file_downloader->Load(url_request); |
1484 } | 1517 } |
1485 | 1518 |
1519 void ExternalDownloadFileCompletion(struct PP_NaClFileInfo* out_file_info, | |
1520 struct PP_CompletionCallback callback, | |
1521 int32_t pp_error, | |
1522 PP_NaClFileInfo file_info) { | |
1523 DCHECK(callback.func); | |
dmichael (off chromium)
2014/06/17 21:52:28
nit: This DCHECK seems either unnecessary or like
teravest
2014/06/18 20:13:43
Done.
| |
1524 if (pp_error == PP_OK) { | |
1525 out_file_info->handle = file_info.handle; | |
hidehiko
2014/06/18 04:43:11
Maybe:
*out_file_info = file_info;
teravest
2014/06/18 20:13:43
Done.
| |
1526 out_file_info->token_lo = file_info.token_lo; | |
1527 out_file_info->token_hi = file_info.token_hi; | |
1528 } | |
1529 callback.func(callback.user_data, pp_error); | |
1530 } | |
1531 | |
1532 void ExternalDownloadFile(PP_Instance instance, | |
1533 const char* url, | |
1534 struct PP_NaClFileInfo* file_info, | |
1535 struct PP_CompletionCallback callback) { | |
1536 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | |
1537 BelongsToCurrentThread()); | |
1538 DownloadFile(instance, url, | |
1539 base::Bind(&ExternalDownloadFileCompletion, | |
1540 file_info, | |
1541 callback)); | |
1542 } | |
1543 | |
1486 void ReportSelLdrStatus(PP_Instance instance, | 1544 void ReportSelLdrStatus(PP_Instance instance, |
1487 int32_t load_status, | 1545 int32_t load_status, |
1488 int32_t max_status) { | 1546 int32_t max_status) { |
1489 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); | 1547 HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status); |
1490 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 1548 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
1491 DCHECK(load_manager); | 1549 DCHECK(load_manager); |
1492 if (!load_manager) | 1550 if (!load_manager) |
1493 return; | 1551 return; |
1494 | 1552 |
1495 // Gather data to see if being installed changes load outcomes. | 1553 // 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, | 1597 &RequestNaClManifest, |
1540 &GetManifestBaseURL, | 1598 &GetManifestBaseURL, |
1541 &ProcessNaClManifest, | 1599 &ProcessNaClManifest, |
1542 &DevInterfacesEnabled, | 1600 &DevInterfacesEnabled, |
1543 &ManifestGetProgramURL, | 1601 &ManifestGetProgramURL, |
1544 &ExternalManifestResolveKey, | 1602 &ExternalManifestResolveKey, |
1545 &GetPNaClResourceInfo, | 1603 &GetPNaClResourceInfo, |
1546 &GetCpuFeatureAttrs, | 1604 &GetCpuFeatureAttrs, |
1547 &PostMessageToJavaScript, | 1605 &PostMessageToJavaScript, |
1548 &DownloadNexe, | 1606 &DownloadNexe, |
1549 &DownloadFile, | 1607 &ExternalDownloadFile, |
1550 &ReportSelLdrStatus, | 1608 &ReportSelLdrStatus, |
1551 &LogTranslateTime | 1609 &LogTranslateTime |
1552 }; | 1610 }; |
1553 | 1611 |
1554 } // namespace | 1612 } // namespace |
1555 | 1613 |
1556 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1614 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1557 return &nacl_interface; | 1615 return &nacl_interface; |
1558 } | 1616 } |
1559 | 1617 |
1560 } // namespace nacl | 1618 } // namespace nacl |
OLD | NEW |