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

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

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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "native_client/src/include/nacl_macros.h" 11 #include "native_client/src/include/nacl_macros.h"
12 #include "native_client/src/include/nacl_string.h" 12 #include "native_client/src/include/nacl_string.h"
13 #include "native_client/src/shared/srpc/nacl_srpc.h" 13 #include "native_client/src/shared/srpc/nacl_srpc.h"
14 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 14 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
15 #include "native_client/src/trusted/plugin/delayed_callback.h" 15 #include "native_client/src/trusted/plugin/delayed_callback.h"
16 #include "native_client/src/trusted/plugin/plugin_error.h" 16 #include "native_client/src/trusted/plugin/plugin_error.h"
17 17
18 #include "ppapi/cpp/completion_callback.h" 18 #include "ppapi/cpp/completion_callback.h"
19 19
20 namespace plugin { 20 namespace plugin {
21 21
22 class Manifest;
22 class Plugin; 23 class Plugin;
23 class PnaclCoordinator; 24 class PnaclCoordinator;
24 25
25 26
26 // Loads a list of remote resources, providing a way to get file descriptors for 27 // Loads a list of remote resources, providing a way to get file descriptors for
27 // thse resources. All URLs in relative to resource_base_url_. 28 // thse resources. All URLs in relative to resource_base_url_.
28 class PnaclResources { 29 class PnaclResources {
29 public: 30 public:
30 PnaclResources(Plugin* plugin, 31 PnaclResources(Plugin* plugin,
31 PnaclCoordinator* coordinator, 32 PnaclCoordinator* coordinator,
32 const nacl::string& resource_base_url, 33 const Manifest* manifest,
33 const std::vector<nacl::string>& resource_urls, 34 const std::vector<nacl::string>& resource_urls,
34 const pp::CompletionCallback& all_loaded_callback) 35 const pp::CompletionCallback& all_loaded_callback)
35 : plugin_(plugin), 36 : plugin_(plugin),
36 coordinator_(coordinator), 37 coordinator_(coordinator),
37 resource_base_url_(resource_base_url), 38 manifest_(manifest),
38 resource_urls_(resource_urls), 39 resource_urls_(resource_urls),
39 all_loaded_callback_(all_loaded_callback) { 40 all_loaded_callback_(all_loaded_callback) {
40 callback_factory_.Initialize(this); 41 callback_factory_.Initialize(this);
41 } 42 }
42 43
43 virtual ~PnaclResources(); 44 virtual ~PnaclResources();
44 45
45 // Start fetching the URLs. After construction, this is the first step. 46 // Start fetching the URLs. After construction, this is the first step.
46 void StartDownloads(); 47 void StartDownloads();
47 // Get the wrapper for the downloaded resource. 48 // Get the wrapper for the downloaded resource.
48 // Only valid after all_loaded_callback_ has been run. 49 // Only valid after all_loaded_callback_ has been run.
49 nacl::DescWrapper* WrapperForUrl(const nacl::string& url) { 50 nacl::DescWrapper* WrapperForUrl(const nacl::string& url) {
50 return resource_wrappers_[url]; 51 return resource_wrappers_[url];
51 } 52 }
52 53
53 private: 54 private:
54 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources); 55 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclResources);
55 56
56 // Callback invoked each time one resource has been loaded. 57 // Callback invoked each time one resource has been loaded.
57 void ResourceReady(int32_t pp_error, 58 void ResourceReady(int32_t pp_error,
58 const nacl::string& url, 59 const nacl::string& url,
59 const nacl::string& full_url); 60 const nacl::string& full_url);
60 61
61 // The plugin requesting the resource loading. 62 // The plugin requesting the resource loading.
62 Plugin* plugin_; 63 Plugin* plugin_;
63 // The coordinator responsible for reporting errors, etc. 64 // The coordinator responsible for reporting errors, etc.
64 PnaclCoordinator* coordinator_; 65 PnaclCoordinator* coordinator_;
65 // The base url for looking up resources. 66 // The manifest url for looking up resources.
jvoung - send to chromium... 2011/12/19 21:37:08 Comment about "url" may be stale?
sehr (please use chromium) 2011/12/20 01:48:38 Thanks. Done.
66 nacl::string resource_base_url_; 67 const Manifest* manifest_;
67 // The list of resource URLs (relative to resource_base_url_) to load. 68 // The list of resource URLs (relative to resource_base_url_) to load.
68 std::vector<nacl::string> resource_urls_; 69 std::vector<nacl::string> resource_urls_;
69 // Callback to be invoked when all resources can be guaranteed available. 70 // Callback to be invoked when all resources can be guaranteed available.
70 pp::CompletionCallback all_loaded_callback_; 71 pp::CompletionCallback all_loaded_callback_;
71 // The descriptor wrappers for the downloaded URLs. Only valid 72 // The descriptor wrappers for the downloaded URLs. Only valid
72 // once all_loaded_callback_ has been invoked. 73 // once all_loaded_callback_ has been invoked.
73 std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_; 74 std::map<nacl::string, nacl::DescWrapper*> resource_wrappers_;
74 // Because we may be loading multiple resources, we need a callback that 75 // Because we may be loading multiple resources, we need a callback that
75 // is invoked each time a resource arrives, and finally invokes 76 // is invoked each time a resource arrives, and finally invokes
76 // all_loaded_callback_ when done. 77 // all_loaded_callback_ when done.
77 nacl::scoped_ptr<DelayedCallback> delayed_callback_; 78 nacl::scoped_ptr<DelayedCallback> delayed_callback_;
78 // Factory for ready callbacks, etc. 79 // Factory for ready callbacks, etc.
79 pp::CompletionCallbackFactory<PnaclResources> callback_factory_; 80 pp::CompletionCallbackFactory<PnaclResources> callback_factory_;
80 }; 81 };
81 82
82 } // namespace plugin; 83 } // namespace plugin;
83 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_ 84 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_RESOURCES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698