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

Side by Side Diff: extensions/renderer/module_system_test.cc

Issue 1880473003: Make ModuleSystem have a const view of ResourceBundleSourceMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/module_system_test.h" 5 #include "extensions/renderer/module_system_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 }; 98 };
99 99
100 // Source map that operates on std::strings. 100 // Source map that operates on std::strings.
101 class ModuleSystemTestEnvironment::StringSourceMap 101 class ModuleSystemTestEnvironment::StringSourceMap
102 : public ModuleSystem::SourceMap { 102 : public ModuleSystem::SourceMap {
103 public: 103 public:
104 StringSourceMap() {} 104 StringSourceMap() {}
105 ~StringSourceMap() override {} 105 ~StringSourceMap() override {}
106 106
107 v8::Local<v8::Value> GetSource(v8::Isolate* isolate, 107 v8::Local<v8::Value> GetSource(v8::Isolate* isolate,
108 const std::string& name) override { 108 const std::string& name) const override {
109 if (source_map_.count(name) == 0) 109 if (source_map_.count(name) == 0)
Devlin 2016/04/12 17:01:25 Unrelated to this patch, but this is a double look
lazyboy 2016/04/12 17:29:28 Good catch, thank you. Done.
110 return v8::Undefined(isolate); 110 return v8::Undefined(isolate);
111 return v8::String::NewFromUtf8(isolate, source_map_[name].c_str()); 111 return v8::String::NewFromUtf8(isolate,
112 source_map_.find(name)->second.c_str());
112 } 113 }
113 114
114 bool Contains(const std::string& name) override { 115 bool Contains(const std::string& name) const override {
115 return source_map_.count(name); 116 return source_map_.count(name);
116 } 117 }
117 118
118 void RegisterModule(const std::string& name, const std::string& source) { 119 void RegisterModule(const std::string& name, const std::string& source) {
119 CHECK_EQ(0u, source_map_.count(name)) << "Module " << name << " not found"; 120 CHECK_EQ(0u, source_map_.count(name)) << "Module " << name << " not found";
120 source_map_[name] = source; 121 source_map_[name] = source;
121 } 122 }
122 123
123 private: 124 private:
124 std::map<std::string, std::string> source_map_; 125 std::map<std::string, std::string> source_map_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 251
251 void ModuleSystemTest::ExpectNoAssertionsMade() { 252 void ModuleSystemTest::ExpectNoAssertionsMade() {
252 should_assertions_be_made_ = false; 253 should_assertions_be_made_ = false;
253 } 254 }
254 255
255 void ModuleSystemTest::RunResolvedPromises() { 256 void ModuleSystemTest::RunResolvedPromises() {
256 v8::MicrotasksScope::PerformCheckpoint(isolate_); 257 v8::MicrotasksScope::PerformCheckpoint(isolate_);
257 } 258 }
258 259
259 } // namespace extensions 260 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698