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

Unified Diff: content/browser/mojo/mojo_shell_client_host.cc

Issue 1461243002: [OLD ATTEMPT, DO NOT REVIEW] mustash: Enable connections to mus from the Chrome renderer Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ben's comments Created 5 years, 1 month 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 | « content/browser/mojo/mojo_shell_client_host.h ('k') | content/browser/mus_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/mojo/mojo_shell_client_host.cc
diff --git a/content/browser/mojo/mojo_shell_client_host.cc b/content/browser/mojo/mojo_shell_client_host.cc
index 1bc85b51f168de0d8bc05c6909e59fe1d5f3771c..5ca93e03b34030307d93860f41aa847ffed816d5 100644
--- a/content/browser/mojo/mojo_shell_client_host.cc
+++ b/content/browser/mojo/mojo_shell_client_host.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/thread_task_runner_handle.h"
#include "content/browser/mojo/mojo_shell_client_host.h"
@@ -9,6 +10,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/common/mojo_shell_connection.h"
#include "ipc/ipc_sender.h"
+#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/converters/network/network_type_converters.h"
#include "mojo/shell/application_manager.mojom.h"
@@ -103,4 +105,17 @@ std::string GetMojoApplicationInstanceURL(
return instance_url ? instance_url->get() : std::string();
}
+int GetRenderProcessIDFromConnection(mojo::ApplicationConnection* connection) {
+ // Just use the host name for finding the string to avoid checking for
+ // slashes.
+ const char kChromeRenderer[] = "chrome_renderer";
+ const std::string& url = connection->GetRemoteApplicationURL();
+ size_t pos = url.find_last_of(kChromeRenderer);
+ std::string val(url.substr(pos + 1, url.size() - pos - 2));
+ int render_process_id = 0;
+ if (!base::StringToInt(val, &render_process_id))
+ return 0;
+ return render_process_id;
+}
+
} // namespace content
« no previous file with comments | « content/browser/mojo/mojo_shell_client_host.h ('k') | content/browser/mus_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698