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

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

Issue 10689012: Add ability to load pnacl resources from DIR_PNACL_COMPONENT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PP_FileHandle Created 8 years, 4 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 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" 5 #include "native_client/src/trusted/plugin/pnacl_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 15 matching lines...) Expand all
26 namespace { 26 namespace {
27 const char kPnaclTempDir[] = "/.pnacl"; 27 const char kPnaclTempDir[] = "/.pnacl";
28 const uint32_t kCopyBufSize = 512 << 10; 28 const uint32_t kCopyBufSize = 512 << 10;
29 } 29 }
30 30
31 namespace plugin { 31 namespace plugin {
32 32
33 ////////////////////////////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////////////
34 // Pnacl-specific manifest support. 34 // Pnacl-specific manifest support.
35 ////////////////////////////////////////////////////////////////////// 35 //////////////////////////////////////////////////////////////////////
36 class ExtensionManifest : public Manifest { 36
37 class PnaclManifest : public Manifest {
37 public: 38 public:
38 explicit ExtensionManifest(const pp::URLUtil_Dev* url_util) 39 explicit PnaclManifest(const pp::URLUtil_Dev* url_util,
robertm 2012/08/08 21:51:11 now that the constructor has a second arg the "exp
jvoung - send to chromium... 2012/08/08 22:47:04 Done.
40 bool use_extension)
39 : url_util_(url_util), 41 : url_util_(url_util),
40 manifest_base_url_(PnaclUrls::GetExtensionUrl()) { } 42 manifest_base_url_(PnaclUrls::GetBaseUrl(use_extension)) {
41 virtual ~ExtensionManifest() { } 43 // TODO(jvoung): get rid of use_extension when we no longer rely
44 // on the chrome webstore extension. Most of this Manifest stuff
45 // can also be simplified then.
46 }
47 virtual ~PnaclManifest() { }
42 48
43 virtual bool GetProgramURL(nacl::string* full_url, 49 virtual bool GetProgramURL(nacl::string* full_url,
44 nacl::string* cache_identity, 50 nacl::string* cache_identity,
45 ErrorInfo* error_info, 51 ErrorInfo* error_info,
46 bool* pnacl_translate) const { 52 bool* pnacl_translate) const {
47 // Does not contain program urls. 53 // Does not contain program urls.
48 UNREFERENCED_PARAMETER(full_url); 54 UNREFERENCED_PARAMETER(full_url);
49 UNREFERENCED_PARAMETER(cache_identity); 55 UNREFERENCED_PARAMETER(cache_identity);
50 UNREFERENCED_PARAMETER(error_info); 56 UNREFERENCED_PARAMETER(error_info);
51 UNREFERENCED_PARAMETER(pnacl_translate); 57 UNREFERENCED_PARAMETER(pnacl_translate);
52 PLUGIN_PRINTF(("ExtensionManifest does not contain a program\n")); 58 PLUGIN_PRINTF(("PnaclManifest does not contain a program\n"));
53 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL, 59 error_info->SetReport(ERROR_MANIFEST_GET_NEXE_URL,
54 "pnacl manifest does not contain a program."); 60 "pnacl manifest does not contain a program.");
55 return false; 61 return false;
56 } 62 }
57 63
58 virtual bool ResolveURL(const nacl::string& relative_url, 64 virtual bool ResolveURL(const nacl::string& relative_url,
59 nacl::string* full_url, 65 nacl::string* full_url,
60 ErrorInfo* error_info) const { 66 ErrorInfo* error_info) const {
61 // Does not do general URL resolution, simply appends relative_url to 67 // Does not do general URL resolution, simply appends relative_url to
62 // the end of manifest_base_url_. 68 // the end of manifest_base_url_.
63 UNREFERENCED_PARAMETER(error_info); 69 UNREFERENCED_PARAMETER(error_info);
64 *full_url = manifest_base_url_ + relative_url; 70 *full_url = manifest_base_url_ + relative_url;
65 return true; 71 return true;
66 } 72 }
67 73
68 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { 74 virtual bool GetFileKeys(std::set<nacl::string>* keys) const {
69 // Does not support enumeration. 75 // Does not support enumeration.
70 PLUGIN_PRINTF(("ExtensionManifest does not support key enumeration\n")); 76 PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n"));
71 UNREFERENCED_PARAMETER(keys); 77 UNREFERENCED_PARAMETER(keys);
72 return false; 78 return false;
73 } 79 }
74 80
75 virtual bool ResolveKey(const nacl::string& key, 81 virtual bool ResolveKey(const nacl::string& key,
76 nacl::string* full_url, 82 nacl::string* full_url,
77 nacl::string* cache_identity, 83 nacl::string* cache_identity,
78 ErrorInfo* error_info, 84 ErrorInfo* error_info,
79 bool* pnacl_translate) const { 85 bool* pnacl_translate) const {
80 // All of the extension files are native (do not require pnacl translate). 86 // All of the extension files are native (do not require pnacl translate).
81 *pnacl_translate = false; 87 *pnacl_translate = false;
82 // Do not cache these entries. 88 // Do not cache these entries.
83 *cache_identity = ""; 89 *cache_identity = "";
84 // We can only resolve keys in the files/ namespace. 90 // We can only resolve keys in the files/ namespace.
85 const nacl::string kFilesPrefix = "files/"; 91 const nacl::string kFilesPrefix = "files/";
86 size_t files_prefix_pos = key.find(kFilesPrefix); 92 size_t files_prefix_pos = key.find(kFilesPrefix);
87 if (files_prefix_pos == nacl::string::npos) { 93 if (files_prefix_pos == nacl::string::npos) {
88 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL, 94 error_info->SetReport(ERROR_MANIFEST_RESOLVE_URL,
89 "key did not start with files/"); 95 "key did not start with files/");
90 return false; 96 return false;
91 } 97 }
92 // Append what follows files to the pnacl URL prefix. 98 // Append what follows files to the pnacl URL prefix.
93 nacl::string key_basename = key.substr(kFilesPrefix.length()); 99 nacl::string key_basename = key.substr(kFilesPrefix.length());
94 return ResolveURL(key_basename, full_url, error_info); 100 return ResolveURL(key_basename, full_url, error_info);
95 } 101 }
96 102
97 private: 103 private:
98 NACL_DISALLOW_COPY_AND_ASSIGN(ExtensionManifest); 104 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclManifest);
99 105
100 const pp::URLUtil_Dev* url_util_; 106 const pp::URLUtil_Dev* url_util_;
101 nacl::string manifest_base_url_; 107 nacl::string manifest_base_url_;
102 }; 108 };
103 109
104 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest 110 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest
105 // until metadata is complete in pexes. This manifest lookup allows looking 111 // until metadata is complete in pexes. This manifest lookup allows looking
106 // for whether a resource requested by ld is in the nexe manifest first, and 112 // for whether a resource requested by ld is in the nexe manifest first, and
107 // if not, then consults the extension manifest. 113 // if not, then consults the extension manifest.
108 // TODO(sehr,jvoung,pdox): remove this when metadata is correct. 114 // TODO(sehr,jvoung,pdox): remove this when metadata is correct.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 pp::CompletionCallback resources_cb = 204 pp::CompletionCallback resources_cb =
199 coordinator->callback_factory_.NewCallback( 205 coordinator->callback_factory_.NewCallback(
200 &PnaclCoordinator::ResourcesDidLoad); 206 &PnaclCoordinator::ResourcesDidLoad);
201 coordinator->resources_.reset( 207 coordinator->resources_.reset(
202 new PnaclResources(plugin, 208 new PnaclResources(plugin,
203 coordinator, 209 coordinator,
204 coordinator->manifest_.get(), 210 coordinator->manifest_.get(),
205 resource_urls, 211 resource_urls,
206 resources_cb)); 212 resources_cb));
207 CHECK(coordinator->resources_ != NULL); 213 CHECK(coordinator->resources_ != NULL);
208 coordinator->resources_->StartDownloads(); 214 coordinator->resources_->StartLoad();
209 // ResourcesDidLoad will be invoked when all resources have been received. 215 // ResourcesDidLoad will be invoked when all resources have been received.
210 return coordinator; 216 return coordinator;
211 } 217 }
212 218
213 int32_t PnaclCoordinator::GetLoadedFileDesc(int32_t pp_error, 219 int32_t PnaclCoordinator::GetLoadedFileDesc(int32_t pp_error,
214 const nacl::string& url, 220 const nacl::string& url,
215 const nacl::string& component) { 221 const nacl::string& component) {
216 PLUGIN_PRINTF(("PnaclCoordinator::GetLoadedFileDesc (pp_error=%" 222 PLUGIN_PRINTF(("PnaclCoordinator::GetLoadedFileDesc (pp_error=%"
217 NACL_PRId32", url=%s, component=%s)\n", pp_error, 223 NACL_PRId32", url=%s, component=%s)\n", pp_error,
218 url.c_str(), component.c_str())); 224 url.c_str(), component.c_str()));
(...skipping 12 matching lines...) Expand all
231 237
232 PnaclCoordinator::PnaclCoordinator( 238 PnaclCoordinator::PnaclCoordinator(
233 Plugin* plugin, 239 Plugin* plugin,
234 const nacl::string& pexe_url, 240 const nacl::string& pexe_url,
235 const nacl::string& cache_identity, 241 const nacl::string& cache_identity,
236 const pp::CompletionCallback& translate_notify_callback) 242 const pp::CompletionCallback& translate_notify_callback)
237 : translate_finish_error_(PP_OK), 243 : translate_finish_error_(PP_OK),
238 plugin_(plugin), 244 plugin_(plugin),
239 translate_notify_callback_(translate_notify_callback), 245 translate_notify_callback_(translate_notify_callback),
240 file_system_(new pp::FileSystem(plugin, PP_FILESYSTEMTYPE_LOCALTEMPORARY)), 246 file_system_(new pp::FileSystem(plugin, PP_FILESYSTEMTYPE_LOCALTEMPORARY)),
241 manifest_(new ExtensionManifest(plugin->url_util())), 247 manifest_(new PnaclManifest(
248 plugin->url_util(),
249 plugin::PnaclUrls::UsePnaclExtension(plugin))),
242 pexe_url_(pexe_url), 250 pexe_url_(pexe_url),
243 cache_identity_(cache_identity), 251 cache_identity_(cache_identity),
244 error_already_reported_(false), 252 error_already_reported_(false),
245 off_the_record_(false) { 253 off_the_record_(false) {
246 PLUGIN_PRINTF(("PnaclCoordinator::PnaclCoordinator (this=%p, plugin=%p)\n", 254 PLUGIN_PRINTF(("PnaclCoordinator::PnaclCoordinator (this=%p, plugin=%p)\n",
247 static_cast<void*>(this), static_cast<void*>(plugin))); 255 static_cast<void*>(this), static_cast<void*>(plugin)));
248 callback_factory_.Initialize(this); 256 callback_factory_.Initialize(this);
249 ld_manifest_.reset(new PnaclLDManifest(plugin_->manifest(), manifest_.get())); 257 ld_manifest_.reset(new PnaclLDManifest(plugin_->manifest(), manifest_.get()));
250 } 258 }
251 259
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 manifest_.get(), 627 manifest_.get(),
620 ld_manifest_.get(), 628 ld_manifest_.get(),
621 obj_file_.get(), 629 obj_file_.get(),
622 temp_nexe_file_.get(), 630 temp_nexe_file_.get(),
623 &error_info_, 631 &error_info_,
624 resources_.get(), 632 resources_.get(),
625 plugin_); 633 plugin_);
626 } 634 }
627 635
628 } // namespace plugin 636 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698