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

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

Issue 8974020: Change pnacl to read all resources from the extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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) 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 #include "native_client/src/trusted/plugin/pnacl_resources.h" 5 #include "native_client/src/trusted/plugin/pnacl_resources.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/portability_io.h" 10 #include "native_client/src/include/portability_io.h"
11 #include "native_client/src/shared/platform/nacl_check.h" 11 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 12 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
13 #include "native_client/src/trusted/plugin/browser_interface.h" 13 #include "native_client/src/trusted/plugin/browser_interface.h"
14 #include "native_client/src/trusted/plugin/manifest.h"
14 #include "native_client/src/trusted/plugin/plugin.h" 15 #include "native_client/src/trusted/plugin/plugin.h"
15 #include "native_client/src/trusted/plugin/plugin_error.h" 16 #include "native_client/src/trusted/plugin/plugin_error.h"
16 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" 17 #include "native_client/src/trusted/plugin/pnacl_coordinator.h"
17 #include "native_client/src/trusted/plugin/utility.h" 18 #include "native_client/src/trusted/plugin/utility.h"
18 19
19 #include "ppapi/c/pp_errors.h" 20 #include "ppapi/c/pp_errors.h"
20 21
21 namespace plugin { 22 namespace plugin {
22 23
23 class Plugin; 24 class Plugin;
(...skipping 12 matching lines...) Expand all
36 PLUGIN_PRINTF(("PnaclResources::StartDownloads\n")); 37 PLUGIN_PRINTF(("PnaclResources::StartDownloads\n"));
37 // Create a counter (barrier) callback to track when all of the resources 38 // Create a counter (barrier) callback to track when all of the resources
38 // are loaded. 39 // are loaded.
39 uint32_t resource_count = static_cast<uint32_t>(resource_urls_.size()); 40 uint32_t resource_count = static_cast<uint32_t>(resource_urls_.size());
40 delayed_callback_.reset( 41 delayed_callback_.reset(
41 new DelayedCallback(all_loaded_callback_, resource_count)); 42 new DelayedCallback(all_loaded_callback_, resource_count));
42 43
43 // Schedule the downloads. 44 // Schedule the downloads.
44 CHECK(resource_urls_.size() > 0); 45 CHECK(resource_urls_.size() > 0);
45 for (size_t i = 0; i < resource_urls_.size(); ++i) { 46 for (size_t i = 0; i < resource_urls_.size(); ++i) {
46 const nacl::string& full_url = resource_base_url_ + resource_urls_[i]; 47 nacl::string full_url;
48 ErrorInfo error_info;
49 if (!manifest_->ResolveURL(resource_urls_[i], &full_url, &error_info)) {
50 coordinator_->ReportNonPpapiError(
51 nacl::string("failed to download ") + resource_urls_[i] + "\n");
jvoung - send to chromium... 2011/12/19 21:37:08 maybe incorporate the error_info string as well.
elijahtaylor (use chromium) 2011/12/19 21:42:52 s/download/resolve/ ? Also, does this need a bre
sehr (please use chromium) 2011/12/20 01:48:38 Done.
sehr (please use chromium) 2011/12/20 01:48:38 Agreed on the "resolve". I tried to harmonize the
52 }
47 pp::CompletionCallback ready_callback = 53 pp::CompletionCallback ready_callback =
48 callback_factory_.NewCallback(&PnaclResources::ResourceReady, 54 callback_factory_.NewCallback(&PnaclResources::ResourceReady,
49 resource_urls_[i], 55 resource_urls_[i],
50 full_url); 56 full_url);
51 if (!plugin_->StreamAsFile(full_url, 57 if (!plugin_->StreamAsFile(full_url,
58 manifest_->PermitsExtensionUrls(),
52 ready_callback.pp_completion_callback())) { 59 ready_callback.pp_completion_callback())) {
53 coordinator_->ReportNonPpapiError( 60 coordinator_->ReportNonPpapiError(
54 nacl::string("failed to download ") + resource_urls_[i] + "\n"); 61 nacl::string("failed to download ") + resource_urls_[i] + "\n");
55 break; 62 break;
56 } 63 }
57 } 64 }
58 } 65 }
59 66
60 void PnaclResources::ResourceReady(int32_t pp_error, 67 void PnaclResources::ResourceReady(int32_t pp_error,
61 const nacl::string& url, 68 const nacl::string& url,
62 const nacl::string& full_url) { 69 const nacl::string& full_url) {
63 PLUGIN_PRINTF(("PnaclResources::ResourceReady (pp_error=%" 70 PLUGIN_PRINTF(("PnaclResources::ResourceReady (pp_error=%"
64 NACL_PRId32", url=%s)\n", pp_error, url.c_str())); 71 NACL_PRId32", url=%s)\n", pp_error, url.c_str()));
65 // pp_error is checked by GetLoadedFileDesc. 72 // pp_error is checked by GetLoadedFileDesc.
66 int32_t fd = coordinator_->GetLoadedFileDesc(pp_error, 73 int32_t fd = coordinator_->GetLoadedFileDesc(pp_error,
67 full_url, 74 full_url,
68 "resource " + url); 75 "resource " + url);
69 if (fd < 0) { 76 if (fd < 0) {
70 coordinator_->ReportPpapiError(pp_error, 77 coordinator_->ReportPpapiError(pp_error,
71 "PnaclResources::ResourceReady failed.\n"); 78 "PnaclResources::ResourceReady failed.\n");
72 } else { 79 } else {
73 resource_wrappers_[url] = 80 resource_wrappers_[url] =
74 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY); 81 plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY);
75 delayed_callback_->RunIfTime(); 82 delayed_callback_->RunIfTime();
76 } 83 }
77 } 84 }
78 85
79 } // namespace plugin 86 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698