OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/device/devtools_device_discovery.h" | 5 #include "chrome/browser/devtools/device/devtools_device_discovery.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/user_metrics.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chrome/browser/devtools/devtools_protocol.h" | 17 #include "chrome/browser/devtools/devtools_protocol.h" |
17 #include "chrome/browser/devtools/devtools_window.h" | 18 #include "chrome/browser/devtools/devtools_window.h" |
18 #include "content/public/browser/devtools_agent_host.h" | 19 #include "content/public/browser/devtools_agent_host.h" |
19 #include "content/public/browser/devtools_external_agent_proxy.h" | 20 #include "content/public/browser/devtools_external_agent_proxy.h" |
20 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" | 21 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" |
21 #include "content/public/browser/user_metrics.h" | |
22 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 using content::DevToolsAgentHost; | 25 using content::DevToolsAgentHost; |
26 using RemoteBrowser = DevToolsDeviceDiscovery::RemoteBrowser; | 26 using RemoteBrowser = DevToolsDeviceDiscovery::RemoteBrowser; |
27 using RemoteDevice = DevToolsDeviceDiscovery::RemoteDevice; | 27 using RemoteDevice = DevToolsDeviceDiscovery::RemoteDevice; |
28 using RemotePage = DevToolsDeviceDiscovery::RemotePage; | 28 using RemotePage = DevToolsDeviceDiscovery::RemotePage; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 socket_opened_(false), | 253 socket_opened_(false), |
254 agent_host_(nullptr), | 254 agent_host_(nullptr), |
255 proxy_(nullptr) { | 255 proxy_(nullptr) { |
256 } | 256 } |
257 | 257 |
258 AgentHostDelegate::~AgentHostDelegate() { | 258 AgentHostDelegate::~AgentHostDelegate() { |
259 } | 259 } |
260 | 260 |
261 void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) { | 261 void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) { |
262 proxy_ = proxy; | 262 proxy_ = proxy; |
263 content::RecordAction( | 263 base::RecordAction( |
264 base::StartsWith(browser_id_, kWebViewSocketPrefix, | 264 base::StartsWith(browser_id_, kWebViewSocketPrefix, |
265 base::CompareCase::SENSITIVE) | 265 base::CompareCase::SENSITIVE) |
266 ? base::UserMetricsAction("DevTools_InspectAndroidWebView") | 266 ? base::UserMetricsAction("DevTools_InspectAndroidWebView") |
267 : base::UserMetricsAction("DevTools_InspectAndroidPage")); | 267 : base::UserMetricsAction("DevTools_InspectAndroidPage")); |
268 web_socket_.reset( | 268 web_socket_.reset( |
269 device_->CreateWebSocket(browser_id_, target_path_, this)); | 269 device_->CreateWebSocket(browser_id_, target_path_, this)); |
270 } | 270 } |
271 | 271 |
272 void AgentHostDelegate::Detach() { | 272 void AgentHostDelegate::Detach() { |
273 web_socket_.reset(); | 273 web_socket_.reset(); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 617 } |
618 | 618 |
619 void DevToolsDeviceDiscovery::ReceivedDeviceList( | 619 void DevToolsDeviceDiscovery::ReceivedDeviceList( |
620 const CompleteDevices& complete_devices) { | 620 const CompleteDevices& complete_devices) { |
621 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 621 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
622 task_scheduler_.Run(base::Bind(&DevToolsDeviceDiscovery::RequestDeviceList, | 622 task_scheduler_.Run(base::Bind(&DevToolsDeviceDiscovery::RequestDeviceList, |
623 weak_factory_.GetWeakPtr())); | 623 weak_factory_.GetWeakPtr())); |
624 // |callback_| should be run last as it may destroy |this|. | 624 // |callback_| should be run last as it may destroy |this|. |
625 callback_.Run(complete_devices); | 625 callback_.Run(complete_devices); |
626 } | 626 } |
OLD | NEW |