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

Unified Diff: content/utility/utility_process_control_impl.cc

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: misc build fixes 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: content/utility/utility_process_control_impl.cc
diff --git a/content/utility/utility_process_control_impl.cc b/content/utility/utility_process_control_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c680182b095b712f661be2b1fed437a9023fdae2
--- /dev/null
+++ b/content/utility/utility_process_control_impl.cc
@@ -0,0 +1,57 @@
+// 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 "content/utility/utility_process_control_impl.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/stl_util.h"
+#include "content/public/utility/utility_thread.h"
+#include "mojo/application/public/cpp/application_delegate.h"
+#include "mojo/shell/static_application_loader.h"
+
+namespace content {
+
+namespace {
+
+// Called when a static application terminates.
+void QuitProcess() {
+ content::UtilityThread::Get()->ReleaseProcessIfNeeded();
jam 2015/05/29 01:48:54 nit: no "content::"
Ken Rockot(use gerrit already) 2015/05/29 03:20:40 Done.
+}
+
+} // namespace
+
+UtilityProcessControlImpl::UtilityProcessControlImpl() {
+}
+
+UtilityProcessControlImpl::~UtilityProcessControlImpl() {
+ STLDeleteValues(&url_to_loader_map_);
+}
+
+void UtilityProcessControlImpl::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(LOAD_APPLICATION_RESULT_NOT_FOUND);
+ return;
+ }
+
+ callback.Run(LOAD_APPLICATION_RESULT_OK);
+ it->second->Load(application_url, request.Pass());
+}
+
+void UtilityProcessControlImpl::RegisterStaticAppForURL(
+ const GURL& url,
+ const StaticAppFactory& factory) {
+ auto result = url_to_loader_map_.insert(
+ std::make_pair(url,
+ // Cleaned up in ~UtilityProcessControlImpl.
+ new mojo::shell::StaticApplicationLoader(
+ factory, base::Bind(&QuitProcess))));
+ DCHECK(result.second);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698