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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 9355051: Plumb through cache_identity from manifest for first sketch of pnacl cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix type-check thing found by windows compiler. Created 8 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // No need to close |file_desc|, that is handled by |nexe_downloader_|. 1464 // No need to close |file_desc|, that is handled by |nexe_downloader_|.
1465 json_buffer[total_bytes_read] = '\0'; // Force null termination. 1465 json_buffer[total_bytes_read] = '\0'; // Force null termination.
1466 1466
1467 ProcessNaClManifest(json_buffer.get()); 1467 ProcessNaClManifest(json_buffer.get());
1468 } 1468 }
1469 1469
1470 void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { 1470 void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) {
1471 HistogramSizeKB("NaCl.Perf.Size.Manifest", 1471 HistogramSizeKB("NaCl.Perf.Size.Manifest",
1472 static_cast<int32_t>(manifest_json.length() / 1024)); 1472 static_cast<int32_t>(manifest_json.length() / 1024));
1473 nacl::string program_url; 1473 nacl::string program_url;
1474 nacl::string cache_identity;
1474 bool is_portable; 1475 bool is_portable;
1475 ErrorInfo error_info; 1476 ErrorInfo error_info;
1476 if (!SetManifestObject(manifest_json, &error_info)) { 1477 if (!SetManifestObject(manifest_json, &error_info)) {
1477 ReportLoadError(error_info); 1478 ReportLoadError(error_info);
1478 return; 1479 return;
1479 } 1480 }
1480 1481
1481 if (SelectProgramURLFromManifest(&program_url, &error_info, &is_portable)) { 1482 if (manifest_->GetProgramURL(&program_url, &cache_identity,
1483 &error_info, &is_portable)) {
1482 set_nacl_ready_state(LOADING); 1484 set_nacl_ready_state(LOADING);
1483 // Inform JavaScript that we found a nexe URL to load. 1485 // Inform JavaScript that we found a nexe URL to load.
1484 EnqueueProgressEvent(kProgressEventProgress); 1486 EnqueueProgressEvent(kProgressEventProgress);
1485 if (is_portable) { 1487 if (is_portable) {
1486 pp::CompletionCallback translate_callback = 1488 pp::CompletionCallback translate_callback =
1487 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); 1489 callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate);
1488 // Will always call the callback on success or failure. 1490 // Will always call the callback on success or failure.
1489 pnacl_coordinator_.reset( 1491 pnacl_coordinator_.reset(
1490 PnaclCoordinator::BitcodeToNative(this, 1492 PnaclCoordinator::BitcodeToNative(this,
1491 program_url, 1493 program_url,
1494 cache_identity,
1492 translate_callback)); 1495 translate_callback));
1493 return; 1496 return;
1494 } else { 1497 } else {
1495 pp::CompletionCallback open_callback = 1498 pp::CompletionCallback open_callback =
1496 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); 1499 callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen);
1497 // Will always call the callback on success or failure. 1500 // Will always call the callback on success or failure.
1498 CHECK( 1501 CHECK(
1499 nexe_downloader_.Open(program_url, 1502 nexe_downloader_.Open(program_url,
1500 DOWNLOAD_TO_FILE, 1503 DOWNLOAD_TO_FILE,
1501 open_callback, 1504 open_callback,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 manifest_base_url(), 1571 manifest_base_url(),
1569 GetSandboxISA(), 1572 GetSandboxISA(),
1570 should_prefer_portable)); 1573 should_prefer_portable));
1571 if (!json_manifest->Init(manifest_json, error_info)) { 1574 if (!json_manifest->Init(manifest_json, error_info)) {
1572 return false; 1575 return false;
1573 } 1576 }
1574 manifest_.reset(json_manifest.release()); 1577 manifest_.reset(json_manifest.release());
1575 return true; 1578 return true;
1576 } 1579 }
1577 1580
1578 bool Plugin::SelectProgramURLFromManifest(nacl::string* result,
1579 ErrorInfo* error_info,
1580 bool* is_portable) {
1581 const nacl::string sandbox_isa(GetSandboxISA());
1582 PLUGIN_PRINTF(("Plugin::SelectProgramURLFromManifest(): sandbox='%s'.\n",
1583 sandbox_isa.c_str()));
1584 if (result == NULL || error_info == NULL || manifest_ == NULL)
1585 return false;
1586 return manifest_->GetProgramURL(result, error_info, is_portable);
1587 }
1588
1589 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error, 1581 void Plugin::UrlDidOpenForStreamAsFile(int32_t pp_error,
1590 FileDownloader*& url_downloader, 1582 FileDownloader*& url_downloader,
1591 PP_CompletionCallback callback) { 1583 PP_CompletionCallback callback) {
1592 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32 1584 PLUGIN_PRINTF(("Plugin::UrlDidOpen (pp_error=%"NACL_PRId32
1593 ", url_downloader=%p)\n", pp_error, 1585 ", url_downloader=%p)\n", pp_error,
1594 static_cast<void*>(url_downloader))); 1586 static_cast<void*>(url_downloader)));
1595 url_downloaders_.erase(url_downloader); 1587 url_downloaders_.erase(url_downloader);
1596 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader); 1588 nacl::scoped_ptr<FileDownloader> scoped_url_downloader(url_downloader);
1597 int32_t file_desc = scoped_url_downloader->GetPOSIXFileDescriptor(); 1589 int32_t file_desc = scoped_url_downloader->GetPOSIXFileDescriptor();
1598 1590
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 static_cast<uint32_t>(text.size())); 1917 static_cast<uint32_t>(text.size()));
1926 const PPB_Console_Dev* console_interface = 1918 const PPB_Console_Dev* console_interface =
1927 static_cast<const PPB_Console_Dev*>( 1919 static_cast<const PPB_Console_Dev*>(
1928 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); 1920 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE));
1929 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str); 1921 console_interface->LogWithSource(pp_instance(), PP_LOGLEVEL_LOG, prefix, str);
1930 var_interface->Release(prefix); 1922 var_interface->Release(prefix);
1931 var_interface->Release(str); 1923 var_interface->Release(str);
1932 } 1924 }
1933 1925
1934 } // namespace plugin 1926 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.h ('k') | ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698