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

Unified Diff: gin/modules/file_module_provider.cc

Issue 401723002: Mojo: Log an error when we fail to find a JS module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/modules/file_module_provider.h ('k') | gin/modules/module_runner_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/modules/file_module_provider.cc
diff --git a/gin/modules/file_module_provider.cc b/gin/modules/file_module_provider.cc
index 660d9b1b9ac2e2a1e60f56cc78827abc0975fce3..dfadf8e6a5a54c01eaeabb531fa1fa5d93de62c3 100644
--- a/gin/modules/file_module_provider.cc
+++ b/gin/modules/file_module_provider.cc
@@ -14,11 +14,14 @@ namespace gin {
namespace {
-void AttempToLoadModule(const base::WeakPtr<Runner>& runner,
- const std::vector<base::FilePath>& search_paths,
- const std::string& id) {
- if (!runner)
+void AttemptToLoadModule(const base::WeakPtr<Runner>& runner,
+ const std::vector<base::FilePath>& search_paths,
+ const std::string& id,
+ base::Callback<void(bool)> callback) {
+ if (!runner) {
+ callback.Run(false);
return;
+ }
std::vector<std::string> components;
base::SplitString(id, '/', &components);
@@ -38,21 +41,23 @@ void AttempToLoadModule(const base::WeakPtr<Runner>& runner,
Runner::Scope scope(runner.get());
runner->Run(source, id);
+ callback.Run(true);
return;
}
+ callback.Run(false);
abarth-chromium 2014/07/22 22:16:15 Maybe we should just log something at this point a
Matt Perry 2014/07/22 22:24:40 Huh.. I thought I tried that and it resulted in fa
}
} // namespace
FileModuleProvider::FileModuleProvider(
const std::vector<base::FilePath>& search_paths)
- : search_paths_(search_paths) {
+ : weak_factory_(this), search_paths_(search_paths) {
}
FileModuleProvider::~FileModuleProvider() {
}
-void FileModuleProvider::AttempToLoadModules(
+void FileModuleProvider::AttemptToLoadModules(
Runner* runner, const std::set<std::string>& ids) {
std::set<std::string> modules = ids;
for (std::set<std::string>::const_iterator it = modules.begin();
@@ -62,7 +67,22 @@ void FileModuleProvider::AttempToLoadModules(
continue;
attempted_ids_.insert(id);
base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
- AttempToLoadModule, runner->GetWeakPtr(), search_paths_, id));
+ AttemptToLoadModule, runner->GetWeakPtr(), search_paths_, id,
+ base::Bind(&FileModuleProvider::OnReadCompleted,
+ weak_factory_.GetWeakPtr(), id)));
+ }
+}
+
+void FileModuleProvider::OnReadCompleted(const std::string& id, bool success) {
+ if (success) {
+ successful_ids_.insert(id);
+ } else {
+ failed_ids_.insert(id);
+ }
+
+ if (failed_ids_.size() + successful_ids_.size() == attempted_ids_.size()) {
+ if (!completion_callback_.is_null())
+ completion_callback_.Run(successful_ids_);
}
}
« no previous file with comments | « gin/modules/file_module_provider.h ('k') | gin/modules/module_runner_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698