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

Side by Side Diff: chrome/renderer/extensions/module_system.cc

Issue 16032015: Extensions: pass ChromeV8Context around instead of v8::Handle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 "chrome/renderer/extensions/module_system.h" 5 #include "chrome/renderer/extensions/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 else 62 else
63 stack_trace = "<could not convert stack trace to string>"; 63 stack_trace = "<could not convert stack trace to string>";
64 } 64 }
65 65
66 console::Fatal(v8::Context::GetCalling(), 66 console::Fatal(v8::Context::GetCalling(),
67 CreateExceptionString(try_catch) + "{" + stack_trace + "}"); 67 CreateExceptionString(try_catch) + "{" + stack_trace + "}");
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 ModuleSystem::ModuleSystem(v8::Handle<v8::Context> context, 72 ModuleSystem::ModuleSystem(ChromeV8Context* context,
73 SourceMap* source_map) 73 SourceMap* source_map)
74 : ObjectBackedNativeHandler(context), 74 : ObjectBackedNativeHandler(context),
75 source_map_(source_map), 75 source_map_(source_map),
76 natives_enabled_(0) { 76 natives_enabled_(0) {
77 RouteFunction("require", 77 RouteFunction("require",
78 base::Bind(&ModuleSystem::RequireForJs, base::Unretained(this))); 78 base::Bind(&ModuleSystem::RequireForJs, base::Unretained(this)));
79 RouteFunction("requireNative", 79 RouteFunction("requireNative",
80 base::Bind(&ModuleSystem::RequireNative, base::Unretained(this))); 80 base::Bind(&ModuleSystem::RequireNative, base::Unretained(this)));
81 81
82 v8::Handle<v8::Object> global(context->Global()); 82 v8::Handle<v8::Object> global(context->v8_context()->Global());
83 global->SetHiddenValue(v8::String::New(kModulesField), v8::Object::New()); 83 global->SetHiddenValue(v8::String::New(kModulesField), v8::Object::New());
84 global->SetHiddenValue(v8::String::New(kModuleSystem), 84 global->SetHiddenValue(v8::String::New(kModuleSystem),
85 v8::External::New(this)); 85 v8::External::New(this));
86 } 86 }
87 87
88 ModuleSystem::~ModuleSystem() { 88 ModuleSystem::~ModuleSystem() {
89 Invalidate(); 89 Invalidate();
90 } 90 }
91 91
92 void ModuleSystem::Invalidate() { 92 void ModuleSystem::Invalidate() {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 v8::Handle<v8::String> ModuleSystem::WrapSource(v8::Handle<v8::String> source) { 449 v8::Handle<v8::String> ModuleSystem::WrapSource(v8::Handle<v8::String> source) {
450 v8::HandleScope handle_scope; 450 v8::HandleScope handle_scope;
451 v8::Handle<v8::String> left = v8::String::New( 451 v8::Handle<v8::String> left = v8::String::New(
452 "(function(require, requireNative, exports) {'use strict';"); 452 "(function(require, requireNative, exports) {'use strict';");
453 v8::Handle<v8::String> right = v8::String::New("\n})"); 453 v8::Handle<v8::String> right = v8::String::New("\n})");
454 return handle_scope.Close( 454 return handle_scope.Close(
455 v8::String::Concat(left, v8::String::Concat(source, right))); 455 v8::String::Concat(left, v8::String::Concat(source, right)));
456 } 456 }
457 457
458 } // extensions 458 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698