Index: chrome/renderer/module_system.h |
diff --git a/chrome/renderer/module_system.h b/chrome/renderer/module_system.h |
index b29d8d644b4d4758b77e3d4d3f3fce49257f8a1c..9809f8db9798ae51fc8045e6206ee3982d7751bf 100644 |
--- a/chrome/renderer/module_system.h |
+++ b/chrome/renderer/module_system.h |
@@ -9,7 +9,9 @@ |
#include "base/compiler_specific.h" |
#include "base/memory/linked_ptr.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/string_piece.h" |
#include "chrome/renderer/native_handler.h" |
+#include "chrome/renderer/static_v8_external_string_resource.h" |
#include "v8/include/v8.h" |
#include <map> |
@@ -30,7 +32,8 @@ |
class ModuleSystem : public NativeHandler { |
public: |
// |source_map| is a weak pointer. |
- explicit ModuleSystem(const std::map<std::string, std::string>* source_map); |
+ explicit ModuleSystem( |
+ const std::map<std::string, base::StringPiece>* source_map); |
virtual ~ModuleSystem(); |
// Require the specified module. This is the equivalent of calling |
@@ -41,9 +44,10 @@ class ModuleSystem : public NativeHandler { |
// calls to requireNative(|name|) from JS will return a new object created by |
// |native_handler|. |
void RegisterNativeHandler(const std::string& name, |
- scoped_ptr<NativeHandler> native_handler); |
+ scoped_ptr<NativeHandler> native_handler); |
private: |
+ typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; |
// Ensure that require_ has been evaluated from require.js. |
void EnsureRequireLoaded(); |
@@ -63,12 +67,19 @@ class ModuleSystem : public NativeHandler { |
// |args[0]| - the name of a native handler object. |
v8::Handle<v8::Value> GetNative(const v8::Arguments& args); |
+ // Converts |string| into a v8::String. This creates a wrapper object that is |
+ // owned by the ModuleSystem. |
+ v8::Handle<v8::String> ConvertString(const base::StringPiece& string); |
+ |
+ v8::Handle<v8::String> GetResource(int resource_id); |
+ |
// A map from module names to the JS source for that module. GetSource() |
// performs a lookup on this map. |
- const std::map<std::string, std::string>* source_map_; |
- typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; |
+ const std::map<std::string, base::StringPiece>* source_map_; |
NativeHandlerMap native_handler_map_; |
v8::Handle<v8::Function> require_; |
+ std::vector<linked_ptr<StaticV8ExternalAsciiStringResource> > |
+ external_strings_; |
}; |
#endif // CHROME_RENDERER_MODULE_SYSTEM_H_ |