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

Unified Diff: content/shell/browser/shell_devtools_manager_delegate.cc

Issue 2320003002: DevTools: reuse ephemeral port from http handler in the shell front-end. (Closed)
Patch Set: includes removed Created 4 years, 3 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 | « content/shell/browser/shell_devtools_manager_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/shell_devtools_manager_delegate.cc
diff --git a/content/shell/browser/shell_devtools_manager_delegate.cc b/content/shell/browser/shell_devtools_manager_delegate.cc
index 526ad376b145bc421c032cbfbc8cd14f94bf7f72..47c5b2dbe53f1027e799633ea5aef177c31b9bc1 100644
--- a/content/shell/browser/shell_devtools_manager_delegate.cc
+++ b/content/shell/browser/shell_devtools_manager_delegate.cc
@@ -8,6 +8,7 @@
#include <vector>
+#include "base/atomicops.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -51,6 +52,8 @@ const char kFrontEndURL[] =
const int kBackLog = 10;
+base::subtle::Atomic32 g_last_used_port;
+
#if defined(OS_ANDROID)
class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory {
public:
@@ -92,6 +95,10 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK)
return std::unique_ptr<net::ServerSocket>();
+ net::IPEndPoint endpoint;
+ if (socket->GetLocalAddress(&endpoint) == net::OK)
+ base::subtle::NoBarrier_Store(&g_last_used_port, endpoint.port());
+
return socket;
}
@@ -143,6 +150,11 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
// ShellDevToolsManagerDelegate ----------------------------------------------
// static
+int ShellDevToolsManagerDelegate::GetHttpHandlerPort() {
+ return base::subtle::NoBarrier_Load(&g_last_used_port);
+}
+
+// static
void ShellDevToolsManagerDelegate::StartHttpHandler(
BrowserContext* browser_context) {
std::string frontend_url;
« no previous file with comments | « content/shell/browser/shell_devtools_manager_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698