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

Unified Diff: chrome/utility/chrome_content_utility_process_impl.cc

Issue 1128453004: Embed a simple Mojo shell in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
Index: chrome/utility/chrome_content_utility_process_impl.cc
diff --git a/chrome/utility/chrome_content_utility_process_impl.cc b/chrome/utility/chrome_content_utility_process_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5feac78fba1bc3e76f8cf63222e56b9acc3a5200
--- /dev/null
+++ b/chrome/utility/chrome_content_utility_process_impl.cc
@@ -0,0 +1,75 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/utility/chrome_content_utility_process_impl.h"
+
+#include <list>
+#include <string>
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/stl_util.h"
+#include "base/thread_task_runner_handle.h"
+#include "base/threading/thread.h"
+#include "chrome/common/application_urls.h"
+#include "components/proxy_resolver/proxy_resolver_app.h"
+#include "content/public/common/static_mojo_application_loader.h"
+#include "mojo/common/message_pump_mojo.h"
+#include "mojo/shell/application_loader.h"
+#include "third_party/mojo/src/mojo/public/cpp/application/application_delegate.h"
+#include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
+#include "third_party/mojo/src/mojo/public/interfaces/application/application.mojom.h"
+
+namespace {
+
+template <typename DelegateType>
+scoped_ptr<mojo::ApplicationDelegate> CreateDelegate() {
+ return scoped_ptr<mojo::ApplicationDelegate>(new DelegateType);
+}
+
+template <typename DelegateType>
+content::StaticMojoApplicationLoader::ApplicationFactory MakeStaticFactory() {
+ return base::Bind(&CreateDelegate<DelegateType>);
+}
+
+} // namespace
+
+ChromeContentUtilityProcessImpl::ChromeContentUtilityProcessImpl() {
+ RegisterApplication(
+ GURL(application_urls::kProxyResolver),
+ new content::StaticMojoApplicationLoader(
+ application_urls::kProxyResolver,
+ MakeStaticFactory<proxy_resolver::ProxyResolverApp>()));
+}
+
+ChromeContentUtilityProcessImpl::~ChromeContentUtilityProcessImpl() {
+ STLDeleteValues(&url_to_loader_map_);
+}
+
+void ChromeContentUtilityProcessImpl::LoadApplication(
+ const mojo::String& url,
+ mojo::InterfaceRequest<mojo::Application> request,
+ const LoadApplicationCallback& callback) {
+ GURL application_url = GURL(url.To<std::string>());
+ auto it = url_to_loader_map_.find(application_url);
+ if (it == url_to_loader_map_.end()) {
+ callback.Run(content::LAUNCH_RESULT_NOT_FOUND);
+ return;
+ }
+ it->second->Load(application_url, request.Pass());
+ callback.Run(content::LAUNCH_RESULT_OK);
+}
+
+void ChromeContentUtilityProcessImpl::RegisterApplication(
+ const GURL& url,
+ mojo::shell::ApplicationLoader* loader) {
+ auto result = url_to_loader_map_.insert(std::make_pair(url, loader));
+ DCHECK(result.second);
+}

Powered by Google App Engine
This is Rietveld 408576698