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

Side by Side Diff: chrome/test/base/module_system_test.cc

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 10 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/test/base/module_system_test.h" 5 #include "chrome/test/base/module_system_test.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "chrome/renderer/extensions/native_handler.h" 10 #include "chrome/renderer/extensions/object_backed_native_handler.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 12
13 #include <map> 13 #include <map>
14 #include <string> 14 #include <string>
15 15
16 using extensions::ModuleSystem; 16 using extensions::ModuleSystem;
17 using extensions::NativeHandler; 17 using extensions::NativeHandler;
18 using extensions::ObjectBackedNativeHandler;
18 19
19 // Native JS functions for doing asserts. 20 // Native JS functions for doing asserts.
20 class AssertNatives : public NativeHandler { 21 class AssertNatives : public ObjectBackedNativeHandler {
21 public: 22 public:
22 explicit AssertNatives(v8::Isolate* isolate) 23 explicit AssertNatives(v8::Isolate* isolate)
23 : NativeHandler(isolate), 24 : ObjectBackedNativeHandler(isolate),
24 assertion_made_(false), 25 assertion_made_(false),
25 failed_(false) { 26 failed_(false) {
26 RouteFunction("AssertTrue", base::Bind(&AssertNatives::AssertTrue, 27 RouteFunction("AssertTrue", base::Bind(&AssertNatives::AssertTrue,
27 base::Unretained(this))); 28 base::Unretained(this)));
28 RouteFunction("AssertFalse", base::Bind(&AssertNatives::AssertFalse, 29 RouteFunction("AssertFalse", base::Bind(&AssertNatives::AssertFalse,
29 base::Unretained(this))); 30 base::Unretained(this)));
30 } 31 }
31 32
32 bool assertion_made() { return assertion_made_; } 33 bool assertion_made() { return assertion_made_; }
33 bool failed() { return failed_; } 34 bool failed() { return failed_; }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 should_assertions_be_made_ = false; 132 should_assertions_be_made_ = false;
132 } 133 }
133 134
134 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { 135 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) {
135 v8::HandleScope handle_scope; 136 v8::HandleScope handle_scope;
136 v8::Handle<v8::Object> object = v8::Object::New(); 137 v8::Handle<v8::Object> object = v8::Object::New();
137 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), 138 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()),
138 object); 139 object);
139 return handle_scope.Close(object); 140 return handle_scope.Close(object);
140 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698