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

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

Issue 649003003: Add a mojoPrivate API that exposes mojo to component apps/extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serial-service
Patch Set: Created 5 years, 11 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.h" 5 #include "extensions/renderer/module_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 HandleException(try_catch); 650 HandleException(try_catch);
651 return v8::Undefined(GetIsolate()); 651 return v8::Undefined(GetIsolate());
652 } 652 }
653 } 653 }
654 return handle_scope.Escape(exports); 654 return handle_scope.Escape(exports);
655 } 655 }
656 656
657 void ModuleSystem::OnDidAddPendingModule( 657 void ModuleSystem::OnDidAddPendingModule(
658 const std::string& id, 658 const std::string& id,
659 const std::vector<std::string>& dependencies) { 659 const std::vector<std::string>& dependencies) {
660 if (!source_map_->Contains(id)) 660 bool module_system_managed = source_map_->Contains(id);
661 return;
662 661
663 gin::ModuleRegistry* registry = 662 gin::ModuleRegistry* registry =
664 gin::ModuleRegistry::From(context_->v8_context()); 663 gin::ModuleRegistry::From(context_->v8_context());
665 DCHECK(registry); 664 DCHECK(registry);
666 for (std::vector<std::string>::const_iterator it = dependencies.begin(); 665 for (const auto& dependency : dependencies) {
667 it != dependencies.end(); 666 // If a dependency is not available, and either the module or this
668 ++it) { 667 // dependency is managed by ModuleSystem, attempt to load it. Other
669 if (registry->available_modules().count(*it) == 0) 668 // gin::ModuleRegistry users (WebUI and users of the mojoPrivate API) are
670 LoadModule(*it); 669 // responsible for loading their module dependencies when required.
670 if (registry->available_modules().count(dependency) == 0 &&
671 (module_system_managed || source_map_->Contains(dependency))) {
672 LoadModule(dependency);
673 }
671 } 674 }
672 registry->AttemptToLoadMoreModules(GetIsolate()); 675 registry->AttemptToLoadMoreModules(GetIsolate());
673 } 676 }
674 677
675 void ModuleSystem::OnModuleLoaded( 678 void ModuleSystem::OnModuleLoaded(
676 scoped_ptr<v8::UniquePersistent<v8::Promise::Resolver> > resolver, 679 scoped_ptr<v8::UniquePersistent<v8::Promise::Resolver> > resolver,
677 v8::Handle<v8::Value> value) { 680 v8::Handle<v8::Value> value) {
678 if (!is_valid()) 681 if (!is_valid())
679 return; 682 return;
680 v8::HandleScope handle_scope(GetIsolate()); 683 v8::HandleScope handle_scope(GetIsolate());
681 v8::Handle<v8::Promise::Resolver> resolver_local( 684 v8::Handle<v8::Promise::Resolver> resolver_local(
682 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver)); 685 v8::Local<v8::Promise::Resolver>::New(GetIsolate(), *resolver));
683 resolver_local->Resolve(value); 686 resolver_local->Resolve(value);
684 } 687 }
685 688
686 } // namespace extensions 689 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698