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

Side by Side Diff: chrome/browser/android/dev_tools_server.cc

Issue 680943002: [DevTools] Migrate DevToolsHttpHandlerDelegate::CreateSocketForTethering to StreamSocket (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/dev_tools_server.h" 5 #include "chrome/browser/android/dev_tools_server.h"
6 6
7 #include <pwd.h> 7 #include <pwd.h>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Delegate implementation for the devtools http handler on android. A new 79 // Delegate implementation for the devtools http handler on android. A new
80 // instance of this gets created each time devtools is enabled. 80 // instance of this gets created each time devtools is enabled.
81 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { 81 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
82 public: 82 public:
83 explicit DevToolsServerDelegate( 83 explicit DevToolsServerDelegate(
84 const net::UnixDomainServerSocket::AuthCallback& auth_callback) 84 const net::UnixDomainServerSocket::AuthCallback& auth_callback)
85 : last_tethering_socket_(0), 85 : last_tethering_socket_(0),
86 auth_callback_(auth_callback) { 86 auth_callback_(auth_callback) {
87 } 87 }
88 88
89 virtual std::string GetDiscoveryPageHTML() override { 89 std::string GetDiscoveryPageHTML() override {
90 // TopSites updates itself after a delay. Ask TopSites to update itself 90 // TopSites updates itself after a delay. Ask TopSites to update itself
91 // when we're about to show the remote debugging landing page. 91 // when we're about to show the remote debugging landing page.
92 content::BrowserThread::PostTask( 92 content::BrowserThread::PostTask(
93 content::BrowserThread::UI, 93 content::BrowserThread::UI,
94 FROM_HERE, 94 FROM_HERE,
95 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails)); 95 base::Bind(&DevToolsServerDelegate::PopulatePageThumbnails));
96 return ResourceBundle::GetSharedInstance().GetRawDataResource( 96 return ResourceBundle::GetSharedInstance().GetRawDataResource(
97 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string(); 97 IDR_DEVTOOLS_DISCOVERY_PAGE_HTML).as_string();
98 } 98 }
99 99
100 virtual bool BundlesFrontendResources() override { 100 bool BundlesFrontendResources() override {
101 return false; 101 return false;
102 } 102 }
103 103
104 virtual base::FilePath GetDebugFrontendDir() override { 104 base::FilePath GetDebugFrontendDir() override {
105 return base::FilePath(); 105 return base::FilePath();
106 } 106 }
107 107
108 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( 108 scoped_ptr<net::ServerSocket>
109 net::StreamListenSocket::Delegate* delegate, 109 CreateSocketForTethering(std::string* name) override {
110 std::string* name) override {
111 *name = base::StringPrintf( 110 *name = base::StringPrintf(
112 kTetheringSocketName, getpid(), ++last_tethering_socket_); 111 kTetheringSocketName, getpid(), ++last_tethering_socket_);
113 return net::deprecated::UnixDomainListenSocket:: 112 scoped_ptr<net::UnixDomainServerSocket> socket(
114 CreateAndListenWithAbstractNamespace( 113 new net::UnixDomainServerSocket(auth_callback_, true));
115 *name, "", delegate, auth_callback_); 114 if (socket->ListenWithAddressAndPort(*name, 0, 10) != net::OK)
dgozman 2014/11/06 14:33:17 nit: make 10 a named constant.
vkuzkokov 2014/11/06 16:12:43 Done.
115 return scoped_ptr<net::ServerSocket>();
116
117 return socket.Pass();
116 } 118 }
117 119
118 private: 120 private:
119 static void PopulatePageThumbnails() { 121 static void PopulatePageThumbnails() {
120 Profile* profile = 122 Profile* profile =
121 ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); 123 ProfileManager::GetLastUsedProfile()->GetOriginalProfile();
122 history::TopSites* top_sites = profile->GetTopSites(); 124 history::TopSites* top_sites = profile->GetTopSites();
123 if (top_sites) 125 if (top_sites)
124 top_sites->SyncWithHistory(); 126 top_sites->SyncWithHistory();
125 } 127 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 jlong server, 250 jlong server,
249 jboolean enabled, 251 jboolean enabled,
250 jboolean allow_debug_permission) { 252 jboolean allow_debug_permission) {
251 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); 253 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server);
252 if (enabled) { 254 if (enabled) {
253 devtools_server->Start(allow_debug_permission); 255 devtools_server->Start(allow_debug_permission);
254 } else { 256 } else {
255 devtools_server->Stop(); 257 devtools_server->Stop();
256 } 258 }
257 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698