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/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
18 #include "net/socket/tcp_server_socket.h" | 18 #include "net/socket/tcp_server_socket.h" |
19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const int kMinTetheringPort = 9333; | 24 const uint16 kMinTetheringPort = 9333; |
25 const int kMaxTetheringPort = 9444; | 25 const uint16 kMaxTetheringPort = 9444; |
26 | 26 |
27 const int kBackLog = 10; | 27 const int kBackLog = 10; |
28 | 28 |
29 base::LazyInstance<bool>::Leaky g_tethering_enabled = LAZY_INSTANCE_INITIALIZER; | 29 base::LazyInstance<bool>::Leaky g_tethering_enabled = LAZY_INSTANCE_INITIALIZER; |
30 | 30 |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 void BrowserListTabContentsProvider::EnableTethering() { | 34 void BrowserListTabContentsProvider::EnableTethering() { |
35 g_tethering_enabled.Get() = true; | 35 g_tethering_enabled.Get() = true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 scoped_ptr<net::ServerSocket> | 80 scoped_ptr<net::ServerSocket> |
81 BrowserListTabContentsProvider::CreateSocketForTethering( | 81 BrowserListTabContentsProvider::CreateSocketForTethering( |
82 std::string* name) { | 82 std::string* name) { |
83 if (!g_tethering_enabled.Get()) | 83 if (!g_tethering_enabled.Get()) |
84 return scoped_ptr<net::ServerSocket>(); | 84 return scoped_ptr<net::ServerSocket>(); |
85 | 85 |
86 if (last_tethering_port_ == kMaxTetheringPort) | 86 if (last_tethering_port_ == kMaxTetheringPort) |
87 last_tethering_port_ = kMinTetheringPort; | 87 last_tethering_port_ = kMinTetheringPort; |
88 int port = ++last_tethering_port_; | 88 uint16 port = ++last_tethering_port_; |
89 *name = base::IntToString(port); | 89 *name = base::IntToString(port); |
90 scoped_ptr<net::TCPServerSocket> socket( | 90 scoped_ptr<net::TCPServerSocket> socket( |
91 new net::TCPServerSocket(nullptr, net::NetLog::Source())); | 91 new net::TCPServerSocket(nullptr, net::NetLog::Source())); |
92 if (socket->ListenWithAddressAndPort("127.0.0.1", port, kBackLog) != net::OK) | 92 if (socket->ListenWithAddressAndPort("127.0.0.1", port, kBackLog) != net::OK) |
93 return scoped_ptr<net::ServerSocket>(); | 93 return scoped_ptr<net::ServerSocket>(); |
94 | 94 |
95 return socket.Pass(); | 95 return socket.Pass(); |
96 } | 96 } |
OLD | NEW |