OLD | NEW |
---|---|
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/devtools/browser_list_tabcontents_provider.h" | 5 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/history/top_sites.h" | 9 #include "chrome/browser/history/top_sites.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_iterator.h" | 12 #include "chrome/browser/ui/browser_iterator.h" |
13 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
16 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
17 #include "net/socket/tcp_listen_socket.h" | 17 #include "net/base/net_errors.h" |
18 #include "net/socket/tcp_server_socket.h" | |
18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 const int kMinTetheringPort = 9333; | 24 const int kMinTetheringPort = 9333; |
24 const int kMaxTetheringPort = 9444; | 25 const int kMaxTetheringPort = 9444; |
25 | 26 |
26 base::LazyInstance<bool>::Leaky g_tethering_enabled = LAZY_INSTANCE_INITIALIZER; | 27 base::LazyInstance<bool>::Leaky g_tethering_enabled = LAZY_INSTANCE_INITIALIZER; |
27 | 28 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 base::FilePath BrowserListTabContentsProvider::GetDebugFrontendDir() { | 68 base::FilePath BrowserListTabContentsProvider::GetDebugFrontendDir() { |
68 #if defined(DEBUG_DEVTOOLS) | 69 #if defined(DEBUG_DEVTOOLS) |
69 base::FilePath inspector_dir; | 70 base::FilePath inspector_dir; |
70 PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir); | 71 PathService::Get(chrome::DIR_INSPECTOR, &inspector_dir); |
71 return inspector_dir; | 72 return inspector_dir; |
72 #else | 73 #else |
73 return base::FilePath(); | 74 return base::FilePath(); |
74 #endif | 75 #endif |
75 } | 76 } |
76 | 77 |
77 scoped_ptr<net::StreamListenSocket> | 78 scoped_ptr<net::ServerSocket> |
78 BrowserListTabContentsProvider::CreateSocketForTethering( | 79 BrowserListTabContentsProvider::CreateSocketForTethering( |
79 net::StreamListenSocket::Delegate* delegate, | |
80 std::string* name) { | 80 std::string* name) { |
81 if (!g_tethering_enabled.Get()) | 81 if (!g_tethering_enabled.Get()) |
82 return scoped_ptr<net::StreamListenSocket>(); | 82 return scoped_ptr<net::ServerSocket>(); |
83 | 83 |
84 if (last_tethering_port_ == kMaxTetheringPort) | 84 if (last_tethering_port_ == kMaxTetheringPort) |
85 last_tethering_port_ = kMinTetheringPort; | 85 last_tethering_port_ = kMinTetheringPort; |
86 int port = ++last_tethering_port_; | 86 int port = ++last_tethering_port_; |
87 *name = base::IntToString(port); | 87 *name = base::IntToString(port); |
88 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate); | 88 scoped_ptr<net::TCPServerSocket> socket( |
89 new net::TCPServerSocket(nullptr, net::NetLog::Source())); | |
90 if (socket->ListenWithAddressAndPort("127.0.0.1", port, 10) != net::OK) | |
dgozman
2014/11/06 14:33:17
nit: make 10 a named constant.
vkuzkokov
2014/11/06 16:12:43
Done.
| |
91 return scoped_ptr<net::ServerSocket>(); | |
92 | |
93 return socket.Pass(); | |
89 } | 94 } |
OLD | NEW |