OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifdef _MSC_VER | 5 #ifdef _MSC_VER |
6 // Do not warn about use of std::copy with raw pointers. | 6 // Do not warn about use of std::copy with raw pointers. |
7 #pragma warning(disable : 4996) | 7 #pragma warning(disable : 4996) |
8 #endif | 8 #endif |
9 | 9 |
10 #include "native_client/src/trusted/plugin/plugin.h" | 10 #include "native_client/src/trusted/plugin/plugin.h" |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 enable_dev_interfaces_(false), | 993 enable_dev_interfaces_(false), |
994 replayDidChangeView(false), | 994 replayDidChangeView(false), |
995 replayHandleDocumentLoad(false), | 995 replayHandleDocumentLoad(false), |
996 init_time_(0), | 996 init_time_(0), |
997 ready_time_(0), | 997 ready_time_(0), |
998 nexe_size_(0), | 998 nexe_size_(0), |
999 time_of_last_progress_event_(0) { | 999 time_of_last_progress_event_(0) { |
1000 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" | 1000 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" |
1001 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); | 1001 NACL_PRId32")\n", static_cast<void*>(this), pp_instance)); |
1002 NaClSrpcModuleInit(); | 1002 NaClSrpcModuleInit(); |
| 1003 callback_factory_.Initialize(this); |
1003 nexe_downloader_.Initialize(this); | 1004 nexe_downloader_.Initialize(this); |
1004 pnacl_.Initialize(this); | |
1005 callback_factory_.Initialize(this); | |
1006 } | 1005 } |
1007 | 1006 |
1008 | 1007 |
1009 Plugin::~Plugin() { | 1008 Plugin::~Plugin() { |
1010 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); | 1009 int64_t shutdown_start = NaClGetTimeOfDayMicroseconds(); |
1011 | 1010 |
1012 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, scriptable_handle=%p)\n", | 1011 PLUGIN_PRINTF(("Plugin::~Plugin (this=%p, scriptable_handle=%p)\n", |
1013 static_cast<void*>(this), | 1012 static_cast<void*>(this), |
1014 static_cast<void*>(scriptable_handle()))); | 1013 static_cast<void*>(scriptable_handle()))); |
1015 | 1014 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n", | 1297 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate (pp_error=%"NACL_PRId32")\n", |
1299 pp_error)); | 1298 pp_error)); |
1300 if (pp_error != PP_OK) { | 1299 if (pp_error != PP_OK) { |
1301 // Error should have been reported by pnacl. Just return. | 1300 // Error should have been reported by pnacl. Just return. |
1302 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); | 1301 PLUGIN_PRINTF(("Plugin::BitcodeDidTranslate error in Pnacl\n")); |
1303 return; | 1302 return; |
1304 } | 1303 } |
1305 // Inform JavaScript that we successfully translated the bitcode to a nexe. | 1304 // Inform JavaScript that we successfully translated the bitcode to a nexe. |
1306 EnqueueProgressEvent(kProgressEventProgress); | 1305 EnqueueProgressEvent(kProgressEventProgress); |
1307 nacl::scoped_ptr<nacl::DescWrapper> | 1306 nacl::scoped_ptr<nacl::DescWrapper> |
1308 wrapper(pnacl_.ReleaseTranslatedFD()); | 1307 wrapper(pnacl_coordinator_.get()->ReleaseTranslatedFD()); |
1309 ErrorInfo error_info; | 1308 ErrorInfo error_info; |
1310 bool was_successful = LoadNaClModule( | 1309 bool was_successful = LoadNaClModule( |
1311 wrapper.get(), &error_info, | 1310 wrapper.get(), &error_info, |
1312 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation), | 1311 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation), |
1313 pp::BlockUntilComplete()); | 1312 pp::BlockUntilComplete()); |
1314 | 1313 |
1315 if (!was_successful) { | 1314 if (!was_successful) { |
1316 ReportLoadError(error_info); | 1315 ReportLoadError(error_info); |
1317 } | 1316 } |
1318 } | 1317 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 } | 1613 } |
1615 | 1614 |
1616 if (SelectProgramURLFromManifest(&program_url, &error_info, &is_portable)) { | 1615 if (SelectProgramURLFromManifest(&program_url, &error_info, &is_portable)) { |
1617 set_nacl_ready_state(LOADING); | 1616 set_nacl_ready_state(LOADING); |
1618 // Inform JavaScript that we found a nexe URL to load. | 1617 // Inform JavaScript that we found a nexe URL to load. |
1619 EnqueueProgressEvent(kProgressEventProgress); | 1618 EnqueueProgressEvent(kProgressEventProgress); |
1620 if (is_portable) { | 1619 if (is_portable) { |
1621 pp::CompletionCallback translate_callback = | 1620 pp::CompletionCallback translate_callback = |
1622 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); | 1621 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); |
1623 // Will always call the callback on success or failure. | 1622 // Will always call the callback on success or failure. |
1624 pnacl_.BitcodeToNative(program_url, translate_callback); | 1623 pnacl_coordinator_.reset( |
| 1624 PnaclCoordinator::BitcodeToNative(this, |
| 1625 program_url, |
| 1626 translate_callback)); |
1625 return; | 1627 return; |
1626 } else { | 1628 } else { |
1627 pp::CompletionCallback open_callback = | 1629 pp::CompletionCallback open_callback = |
1628 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); | 1630 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); |
1629 // Will always call the callback on success or failure. | 1631 // Will always call the callback on success or failure. |
1630 CHECK( | 1632 CHECK( |
1631 nexe_downloader_.Open(program_url, | 1633 nexe_downloader_.Open(program_url, |
1632 DOWNLOAD_TO_FILE, | 1634 DOWNLOAD_TO_FILE, |
1633 open_callback, | 1635 open_callback, |
1634 &UpdateDownloadProgress)); | 1636 &UpdateDownloadProgress)); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2030 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, | 2032 std::string scheme = canonicalized.AsString().substr(comps.scheme.begin, |
2031 comps.scheme.len); | 2033 comps.scheme.len); |
2032 if (scheme == kChromeExtensionUriScheme) | 2034 if (scheme == kChromeExtensionUriScheme) |
2033 return SCHEME_CHROME_EXTENSION; | 2035 return SCHEME_CHROME_EXTENSION; |
2034 if (scheme == kDataUriScheme) | 2036 if (scheme == kDataUriScheme) |
2035 return SCHEME_DATA; | 2037 return SCHEME_DATA; |
2036 return SCHEME_OTHER; | 2038 return SCHEME_OTHER; |
2037 } | 2039 } |
2038 | 2040 |
2039 } // namespace plugin | 2041 } // namespace plugin |
OLD | NEW |