Index: mojo/services/catalog/catalog.cc |
diff --git a/mojo/services/catalog/catalog.cc b/mojo/services/catalog/catalog.cc |
index 66a651dd70b0b82289cfdfd8bcbe516201a28c4a..a2b2df0769165a2cd16cd5eae560784487ae7fda 100644 |
--- a/mojo/services/catalog/catalog.cc |
+++ b/mojo/services/catalog/catalog.cc |
@@ -7,6 +7,7 @@ |
#include "base/bind.h" |
#include "base/strings/string_split.h" |
#include "base/task_runner_util.h" |
+#include "base/thread_task_runner_handle.h" |
#include "mojo/common/url_type_converters.h" |
#include "mojo/services/catalog/entry.h" |
#include "mojo/services/catalog/store.h" |
@@ -20,8 +21,11 @@ namespace catalog { |
//////////////////////////////////////////////////////////////////////////////// |
// Catalog, public: |
-Catalog::Catalog(base::TaskRunner* blocking_pool, scoped_ptr<Store> store) |
- : store_(std::move(store)), |
+Catalog::Catalog(base::TaskRunner* blocking_pool, |
+ scoped_ptr<Store> store, |
+ Delegate* delegate) |
+ : delegate_(delegate), |
+ store_(std::move(store)), |
weak_factory_(this) { |
PathService::Get(base::DIR_MODULE, &package_path_); |
reader_.reset(new Reader(package_path_, blocking_pool)); |
@@ -85,9 +89,22 @@ void Catalog::ResolveMojoName(const mojo::String& mojo_name, |
if (IsNameInCatalog(resolved_name)) { |
CompleteResolveMojoName(resolved_name, qualifier, callback); |
} else { |
- reader_->Read(resolved_name, |
- base::Bind(&Catalog::OnReadEntry, weak_factory_.GetWeakPtr(), |
- resolved_name, callback)); |
+ std::string manifest_contents; |
+ if (delegate_ && |
+ delegate_->GetApplicationManifest(resolved_name, &manifest_contents)) { |
+ // We don't invoke the callback synchronously in this case to avoid |
+ // surprising the caller with possible re-entry. |
+ scoped_ptr<Entry> entry = reader_->Parse(manifest_contents); |
+ base::ThreadTaskRunnerHandle::Get()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&Catalog::OnReadEntry, weak_factory_.GetWeakPtr(), |
+ resolved_name, callback, base::Passed(&entry))); |
+ } else { |
+ reader_->Read( |
+ resolved_name, |
+ base::Bind(&Catalog::OnReadEntry, weak_factory_.GetWeakPtr(), |
+ resolved_name, callback)); |
+ } |
} |
} |