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

Unified Diff: android_webview/native/aw_dev_tools_server.cc

Issue 703333005: DevTools: Tethering in Android Webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_dev_tools_server.cc
diff --git a/android_webview/native/aw_dev_tools_server.cc b/android_webview/native/aw_dev_tools_server.cc
index 4d5808b60774bd254a8f90038956c8e8156da255..b5ce81e870db95fe6308354d0b2dba7922acd178 100644
--- a/android_webview/native/aw_dev_tools_server.cc
+++ b/android_webview/native/aw_dev_tools_server.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/user_agent.h"
#include "jni/AwDevToolsServer_jni.h"
+#include "net/base/net_errors.h"
#include "net/socket/unix_domain_server_socket_posix.h"
using content::DevToolsAgentHost;
@@ -30,12 +31,17 @@ namespace {
const char kFrontEndURL[] =
"http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html";
const char kSocketNameFormat[] = "webview_devtools_remote_%d";
+const char kTetheringSocketName[] = "webview_devtools_tethering_%d_%d";
+
+const int kBackLog = 10;
// Delegate implementation for the devtools http handler for WebView. A new
// instance of this gets created each time web debugging is enabled.
class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
public:
- AwDevToolsServerDelegate() {}
+ AwDevToolsServerDelegate() : last_tethering_socket_(0) {
+ }
+
virtual ~AwDevToolsServerDelegate() {}
// DevToolsHttpProtocolHandler::Delegate overrides.
@@ -51,10 +57,20 @@ class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
scoped_ptr<net::ServerSocket>
CreateSocketForTethering(std::string* name) override {
- return scoped_ptr<net::ServerSocket>();
+ *name = base::StringPrintf(
+ kTetheringSocketName, getpid(), ++last_tethering_socket_);
+ scoped_ptr<net::UnixDomainServerSocket> socket(
+ new net::UnixDomainServerSocket(
+ base::Bind(&content::CanUserConnectToDevTools), true));
+ if (socket->ListenWithAddressAndPort(*name, 0, kBackLog) != net::OK)
+ return scoped_ptr<net::ServerSocket>();
+
+ return socket.Pass();
}
private:
+ int last_tethering_socket_;
+
DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698