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

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

Issue 691863002: [DevTools] Remove DevToolsHttpHandler::Stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@httpHandler
Patch Set: Removed comment 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 const net::UnixDomainServerSocket::AuthCallback auth_callback_; 175 const net::UnixDomainServerSocket::AuthCallback auth_callback_;
176 176
177 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); 177 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory);
178 }; 178 };
179 179
180 } // namespace 180 } // namespace
181 181
182 DevToolsServer::DevToolsServer(const std::string& socket_name_prefix) 182 DevToolsServer::DevToolsServer(const std::string& socket_name_prefix)
183 : socket_name_(base::StringPrintf(kDevToolsChannelNameFormat, 183 : socket_name_(base::StringPrintf(kDevToolsChannelNameFormat,
184 socket_name_prefix.c_str())), 184 socket_name_prefix.c_str())) {
185 protocol_handler_(NULL) {
186 // Override the socket name if one is specified on the command line. 185 // Override the socket name if one is specified on the command line.
187 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 186 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
188 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { 187 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) {
189 socket_name_ = command_line.GetSwitchValueASCII( 188 socket_name_ = command_line.GetSwitchValueASCII(
190 switches::kRemoteDebuggingSocketName); 189 switches::kRemoteDebuggingSocketName);
191 } 190 }
192 } 191 }
193 192
194 DevToolsServer::~DevToolsServer() { 193 DevToolsServer::~DevToolsServer() {
195 Stop(); 194 Stop();
196 } 195 }
197 196
198 void DevToolsServer::Start(bool allow_debug_permission) { 197 void DevToolsServer::Start(bool allow_debug_permission) {
199 if (protocol_handler_) 198 if (protocol_handler_)
200 return; 199 return;
201 200
202 net::UnixDomainServerSocket::AuthCallback auth_callback = 201 net::UnixDomainServerSocket::AuthCallback auth_callback =
203 allow_debug_permission ? 202 allow_debug_permission ?
204 base::Bind(&AuthorizeSocketAccessWithDebugPermission) : 203 base::Bind(&AuthorizeSocketAccessWithDebugPermission) :
205 base::Bind(&content::CanUserConnectToDevTools); 204 base::Bind(&content::CanUserConnectToDevTools);
206 scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> factory( 205 scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> factory(
207 new UnixDomainServerSocketFactory(socket_name_, auth_callback)); 206 new UnixDomainServerSocketFactory(socket_name_, auth_callback));
208 protocol_handler_ = content::DevToolsHttpHandler::Start( 207 protocol_handler_.reset(content::DevToolsHttpHandler::Start(
209 factory.Pass(), 208 factory.Pass(),
210 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), 209 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()),
211 new DevToolsServerDelegate(auth_callback), 210 new DevToolsServerDelegate(auth_callback),
212 base::FilePath()); 211 base::FilePath()));
213 } 212 }
214 213
215 void DevToolsServer::Stop() { 214 void DevToolsServer::Stop() {
216 if (!protocol_handler_) 215 protocol_handler_.reset();
217 return;
218 // Note that the call to Stop() below takes care of |protocol_handler_|
219 // deletion.
220 protocol_handler_->Stop();
221 protocol_handler_ = NULL;
222 } 216 }
223 217
224 bool DevToolsServer::IsStarted() const { 218 bool DevToolsServer::IsStarted() const {
225 return protocol_handler_; 219 return protocol_handler_;
226 } 220 }
227 221
228 bool RegisterDevToolsServer(JNIEnv* env) { 222 bool RegisterDevToolsServer(JNIEnv* env) {
229 return RegisterNativesImpl(env); 223 return RegisterNativesImpl(env);
230 } 224 }
231 225
(...skipping 20 matching lines...) Expand all
252 jlong server, 246 jlong server,
253 jboolean enabled, 247 jboolean enabled,
254 jboolean allow_debug_permission) { 248 jboolean allow_debug_permission) {
255 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); 249 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server);
256 if (enabled) { 250 if (enabled) {
257 devtools_server->Start(allow_debug_permission); 251 devtools_server->Start(allow_debug_permission);
258 } else { 252 } else {
259 devtools_server->Stop(); 253 devtools_server->Stop();
260 } 254 }
261 } 255 }
OLDNEW
« no previous file with comments | « chrome/browser/android/dev_tools_server.h ('k') | chrome/browser/devtools/remote_debugging_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698