| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ui_devtools/devtools_server.h" | 5 #include "components/ui_devtools/devtools_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace { | 27 namespace { |
| 28 const char kChromeDeveloperToolsPrefix[] = | 28 const char kChromeDeveloperToolsPrefix[] = |
| 29 "chrome-devtools://devtools/bundled/inspector.html?ws="; | 29 "chrome-devtools://devtools/bundled/inspector.html?ws="; |
| 30 | 30 |
| 31 bool IsUiDevToolsEnabled() { | 31 bool IsUiDevToolsEnabled() { |
| 32 return base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableUiDevTools); | 32 return base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableUiDevTools); |
| 33 } | 33 } |
| 34 | 34 |
| 35 int GetUiDevToolsPort() { | 35 int GetUiDevToolsPort() { |
| 36 DCHECK(IsUiDevToolsEnabled()); | 36 DCHECK(IsUiDevToolsEnabled()); |
| 37 // This value is duplicated in the chrome://flags description. |
| 37 constexpr int kDefaultPort = 9223; | 38 constexpr int kDefaultPort = 9223; |
| 38 int port; | 39 int port; |
| 39 if (!base::StringToInt( | 40 if (!base::StringToInt( |
| 40 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 41 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 41 kEnableUiDevTools), | 42 kEnableUiDevTools), |
| 42 &port)) | 43 &port)) |
| 43 port = kDefaultPort; | 44 port = kDefaultPort; |
| 44 return port; | 45 return port; |
| 45 } | 46 } |
| 46 | 47 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 UiDevToolsClient* client = it->second; | 177 UiDevToolsClient* client = it->second; |
| 177 DCHECK(client); | 178 DCHECK(client); |
| 178 main_thread_task_runner_->PostTask( | 179 main_thread_task_runner_->PostTask( |
| 179 FROM_HERE, | 180 FROM_HERE, |
| 180 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client))); | 181 base::Bind(&UiDevToolsClient::Disconnect, base::Unretained(client))); |
| 181 connections_.erase(it); | 182 connections_.erase(it); |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace devtools | 185 } // namespace devtools |
| 185 } // namespace ui | 186 } // namespace ui |
| OLD | NEW |