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

Side by Side Diff: chrome/renderer/module_system.h

Issue 9812025: Implement lazy JS module initialisation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | chrome/renderer/module_system.cc » ('j') | chrome/renderer/module_system.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_RENDERER_MODULE_SYSTEM_H_ 5 #ifndef CHROME_RENDERER_MODULE_SYSTEM_H_
6 #define CHROME_RENDERER_MODULE_SYSTEM_H_ 6 #define CHROME_RENDERER_MODULE_SYSTEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // Executes |code| in the current context with |name| as the filename. 59 // Executes |code| in the current context with |name| as the filename.
60 void RunString(const std::string& code, const std::string& name); 60 void RunString(const std::string& code, const std::string& name);
61 61
62 // When false |natives_enabled_| causes calls to GetNative() (the basis of 62 // When false |natives_enabled_| causes calls to GetNative() (the basis of
63 // requireNative() in JS) to throw an exception. 63 // requireNative() in JS) to throw an exception.
64 void set_natives_enabled(bool natives_enabled) { 64 void set_natives_enabled(bool natives_enabled) {
65 natives_enabled_ = natives_enabled; 65 natives_enabled_ = natives_enabled;
66 } 66 }
67 67
68 // Create an object which delegates all property accesses to the object that 68 static v8::Handle<v8::Value> GetterRouter(v8::Local<v8::String> property,
not at google - send to devlin 2012/03/22 00:35:53 Documentation. Though does this need to be public
koz (OOO until 15th September) 2012/03/22 01:13:01 I've made it private, but it does need to be a mem
69 // |source| evaluates to. The source is evaluated lazily on access to any of 69 const v8::AccessorInfo& info);
70 // the object's properties. 70
71 static v8::Handle<v8::Object> CreateLazyObject(const std::string& source_name, 71 // Make |object|.|field| lazily evaluate to the result of
72 v8::Handle<v8::String> source); 72 // require(|module_name|)[|module_field|].
73 void SetLazyField(v8::Handle<v8::Object> object,
74 const std::string& field,
75 const std::string& module_name,
76 const std::string& module_field);
73 77
74 private: 78 private:
75 typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap; 79 typedef std::map<std::string, linked_ptr<NativeHandler> > NativeHandlerMap;
76 80
77 // Ensure that require_ has been evaluated from require.js. 81 // Ensure that require_ has been evaluated from require.js.
78 void EnsureRequireLoaded(); 82 void EnsureRequireLoaded();
79 83
80 // Run |code| in the current context with the name |name| used for stack 84 // Run |code| in the current context with the name |name| used for stack
81 // traces. 85 // traces.
82 v8::Handle<v8::Value> RunString(v8::Handle<v8::String> code, 86 v8::Handle<v8::Value> RunString(v8::Handle<v8::String> code,
(...skipping 15 matching lines...) Expand all
98 v8::Handle<v8::Value> ThrowException(const std::string& message); 102 v8::Handle<v8::Value> ThrowException(const std::string& message);
99 103
100 // A map from module names to the JS source for that module. GetSource() 104 // A map from module names to the JS source for that module. GetSource()
101 // performs a lookup on this map. 105 // performs a lookup on this map.
102 SourceMap* source_map_; 106 SourceMap* source_map_;
103 NativeHandlerMap native_handler_map_; 107 NativeHandlerMap native_handler_map_;
104 bool natives_enabled_; 108 bool natives_enabled_;
105 }; 109 };
106 110
107 #endif // CHROME_RENDERER_MODULE_SYSTEM_H_ 111 #endif // CHROME_RENDERER_MODULE_SYSTEM_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/module_system.cc » ('j') | chrome/renderer/module_system.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698