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

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

Issue 376323002: Refactor unix domain socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests because of incomplete reversion Created 6 years, 5 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 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 22 matching lines...) Expand all
33 #include "content/public/browser/favicon_status.h" 33 #include "content/public/browser/favicon_status.h"
34 #include "content/public/browser/navigation_entry.h" 34 #include "content/public/browser/navigation_entry.h"
35 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
38 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "content/public/common/url_constants.h" 39 #include "content/public/common/url_constants.h"
40 #include "content/public/common/user_agent.h" 40 #include "content/public/common/user_agent.h"
41 #include "grit/browser_resources.h" 41 #include "grit/browser_resources.h"
42 #include "jni/DevToolsServer_jni.h" 42 #include "jni/DevToolsServer_jni.h"
43 #include "net/socket/unix_domain_socket_posix.h" 43 #include "net/socket/unix_domain_listen_socket_posix.h"
44 #include "net/url_request/url_request_context_getter.h" 44 #include "net/url_request/url_request_context_getter.h"
45 #include "ui/base/resource/resource_bundle.h" 45 #include "ui/base/resource/resource_bundle.h"
46 46
47 using content::DevToolsAgentHost; 47 using content::DevToolsAgentHost;
48 using content::RenderViewHost; 48 using content::RenderViewHost;
49 using content::WebContents; 49 using content::WebContents;
50 50
51 namespace { 51 namespace {
52 52
53 // TL;DR: Do not change this string. 53 // TL;DR: Do not change this string.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 } 359 }
360 360
361 callback.Run(targets); 361 callback.Run(targets);
362 } 362 }
363 363
364 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( 364 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
365 net::StreamListenSocket::Delegate* delegate, 365 net::StreamListenSocket::Delegate* delegate,
366 std::string* name) OVERRIDE { 366 std::string* name) OVERRIDE {
367 *name = base::StringPrintf( 367 *name = base::StringPrintf(
368 kTetheringSocketName, getpid(), ++last_tethering_socket_); 368 kTetheringSocketName, getpid(), ++last_tethering_socket_);
369 return net::UnixDomainSocket::CreateAndListenWithAbstractNamespace( 369 return net::UnixDomainListenSocket::CreateAndListenWithAbstractNamespace(
370 *name, 370 *name,
371 "", 371 "",
372 delegate, 372 delegate,
373 base::Bind(&content::CanUserConnectToDevTools)) 373 base::Bind(&content::CanUserConnectToDevTools))
374 .PassAs<net::StreamListenSocket>(); 374 .PassAs<net::StreamListenSocket>();
375 } 375 }
376 376
377 private: 377 private:
378 static void PopulatePageThumbnails() { 378 static void PopulatePageThumbnails() {
379 Profile* profile = 379 Profile* profile =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 DevToolsServer::~DevToolsServer() { 417 DevToolsServer::~DevToolsServer() {
418 Stop(); 418 Stop();
419 } 419 }
420 420
421 void DevToolsServer::Start() { 421 void DevToolsServer::Start() {
422 if (protocol_handler_) 422 if (protocol_handler_)
423 return; 423 return;
424 424
425 protocol_handler_ = content::DevToolsHttpHandler::Start( 425 protocol_handler_ = content::DevToolsHttpHandler::Start(
426 new net::UnixDomainSocketWithAbstractNamespaceFactory( 426 new net::UnixDomainListenSocketWithAbstractNamespaceFactory(
427 socket_name_, 427 socket_name_,
428 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()), 428 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()),
429 base::Bind(&content::CanUserConnectToDevTools)), 429 base::Bind(&content::CanUserConnectToDevTools)),
430 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), 430 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()),
431 new DevToolsServerDelegate(), 431 new DevToolsServerDelegate(),
432 base::FilePath()); 432 base::FilePath());
433 } 433 }
434 434
435 void DevToolsServer::Stop() { 435 void DevToolsServer::Stop() {
436 if (!protocol_handler_) 436 if (!protocol_handler_)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 jobject obj, 471 jobject obj,
472 jlong server, 472 jlong server,
473 jboolean enabled) { 473 jboolean enabled) {
474 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); 474 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server);
475 if (enabled) { 475 if (enabled) {
476 devtools_server->Start(); 476 devtools_server->Start();
477 } else { 477 } else {
478 devtools_server->Stop(); 478 devtools_server->Stop();
479 } 479 }
480 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698