Index: chrome/browser/devtools/devtools_targets_ui.cc |
diff --git a/chrome/browser/devtools/devtools_targets_ui.cc b/chrome/browser/devtools/devtools_targets_ui.cc |
index bf405f30362f38942e96b6401806d290ef841370..a48364b02623707e3ef3cef5898c951211d09d31 100644 |
--- a/chrome/browser/devtools/devtools_targets_ui.cc |
+++ b/chrome/browser/devtools/devtools_targets_ui.cc |
@@ -16,10 +16,10 @@ |
#include "base/values.h" |
#include "base/version.h" |
#include "chrome/browser/devtools/device/devtools_android_bridge.h" |
-#include "chrome/browser/devtools/devtools_target_impl.h" |
#include "content/public/browser/browser_child_process_observer.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/child_process_data.h" |
+#include "content/public/browser/devtools_agent_host.h" |
#include "content/public/browser/notification_observer.h" |
#include "content/public/browser/notification_registrar.h" |
#include "content/public/browser/notification_service.h" |
@@ -31,6 +31,7 @@ |
#include "net/base/escape.h" |
using content::BrowserThread; |
+using content::DevToolsAgentHost; |
namespace { |
@@ -173,7 +174,7 @@ private: |
void ScheduleUpdate(); |
void UpdateTargets(); |
- void SendTargets(const std::vector<DevToolsTargetImpl*>& targets); |
+ void SendTargets(const DevToolsAgentHost::List& targets); |
content::NotificationRegistrar notification_registrar_; |
std::unique_ptr<CancelableTimer> timer_; |
@@ -226,24 +227,22 @@ void LocalTargetsUIHandler::ScheduleUpdate() { |
} |
void LocalTargetsUIHandler::UpdateTargets() { |
- SendTargets(DevToolsTargetImpl::EnumerateAll()); |
+ SendTargets(DevToolsAgentHost::GetOrCreateAll()); |
} |
void LocalTargetsUIHandler::SendTargets( |
- const std::vector<DevToolsTargetImpl*>& targets) { |
+ const content::DevToolsAgentHost::List& targets) { |
base::ListValue list_value; |
std::map<std::string, base::DictionaryValue*> id_to_descriptor; |
- base::STLDeleteValues(&targets_); |
- for (DevToolsTargetImpl* target : targets) { |
- scoped_refptr<content::DevToolsAgentHost> host = target->GetAgentHost(); |
- targets_[host->GetId()] = target; |
- id_to_descriptor[host->GetId()] = Serialize(*target); |
+ targets_.clear(); |
+ for (scoped_refptr<DevToolsAgentHost> host : targets) { |
+ targets_[host->GetId()] = host; |
+ id_to_descriptor[host->GetId()] = Serialize(host); |
} |
- for (TargetMap::iterator it(targets_.begin()); it != targets_.end(); ++it) { |
- DevToolsTargetImpl* target = it->second; |
- scoped_refptr<content::DevToolsAgentHost> host = target->GetAgentHost(); |
+ for (auto& it : targets_) { |
+ scoped_refptr<DevToolsAgentHost> host = it.second; |
base::DictionaryValue* descriptor = id_to_descriptor[host->GetId()]; |
std::string parent_id = host->GetParentId(); |
if (parent_id.empty() || id_to_descriptor.count(parent_id) == 0) { |
@@ -273,7 +272,7 @@ class AdbTargetsUIHandler |
void Open(const std::string& browser_id, const std::string& url) override; |
- scoped_refptr<content::DevToolsAgentHost> GetBrowserAgentHost( |
+ scoped_refptr<DevToolsAgentHost> GetBrowserAgentHost( |
const std::string& browser_id) override; |
private: |
@@ -313,7 +312,7 @@ void AdbTargetsUIHandler::Open(const std::string& browser_id, |
android_bridge_->OpenRemotePage(it->second, url); |
} |
-scoped_refptr<content::DevToolsAgentHost> |
+scoped_refptr<DevToolsAgentHost> |
AdbTargetsUIHandler::GetBrowserAgentHost( |
const std::string& browser_id) { |
RemoteBrowsers::iterator it = remote_browsers_.find(browser_id); |
@@ -326,7 +325,7 @@ AdbTargetsUIHandler::GetBrowserAgentHost( |
void AdbTargetsUIHandler::DeviceListChanged( |
const DevToolsAndroidBridge::RemoteDevices& devices) { |
remote_browsers_.clear(); |
- base::STLDeleteValues(&targets_); |
+ targets_.clear(); |
if (!android_bridge_) |
return; |
@@ -368,9 +367,9 @@ void AdbTargetsUIHandler::DeviceListChanged( |
remote_browsers_[browser_id] = browser; |
browser_data->Set(kAdbPagesList, page_list); |
for (const auto& page : browser->pages()) { |
- DevToolsTargetImpl* target = android_bridge_->CreatePageTarget(page); |
- scoped_refptr<content::DevToolsAgentHost> host = target->GetAgentHost(); |
- base::DictionaryValue* target_data = Serialize(*target); |
+ scoped_refptr<DevToolsAgentHost> host = |
+ android_bridge_->CreatePageTarget(page); |
+ base::DictionaryValue* target_data = Serialize(host); |
target_data->SetBoolean( |
kAdbAttachedForeignField, |
host->IsAttached() && |
@@ -381,7 +380,7 @@ void AdbTargetsUIHandler::DeviceListChanged( |
gfx::Size screen_size = device->screen_size(); |
target_data->SetInteger(kAdbScreenWidthField, screen_size.width()); |
target_data->SetInteger(kAdbScreenHeightField, screen_size.height()); |
- targets_[host->GetId()] = target; |
+ targets_[host->GetId()] = host; |
page_list->Append(target_data); |
} |
browser_list->Append(std::move(browser_data)); |
@@ -404,7 +403,6 @@ DevToolsTargetsUIHandler::DevToolsTargetsUIHandler( |
} |
DevToolsTargetsUIHandler::~DevToolsTargetsUIHandler() { |
- base::STLDeleteValues(&targets_); |
} |
// static |
@@ -424,7 +422,7 @@ DevToolsTargetsUIHandler::CreateForAdb( |
new AdbTargetsUIHandler(callback, profile)); |
} |
-DevToolsTargetImpl* DevToolsTargetsUIHandler::GetTarget( |
+scoped_refptr<DevToolsAgentHost> DevToolsTargetsUIHandler::GetTarget( |
const std::string& target_id) { |
TargetMap::iterator it = targets_.find(target_id); |
if (it != targets_.end()) |
@@ -436,15 +434,14 @@ void DevToolsTargetsUIHandler::Open(const std::string& browser_id, |
const std::string& url) { |
} |
-scoped_refptr<content::DevToolsAgentHost> |
+scoped_refptr<DevToolsAgentHost> |
DevToolsTargetsUIHandler::GetBrowserAgentHost(const std::string& browser_id) { |
return NULL; |
} |
base::DictionaryValue* DevToolsTargetsUIHandler::Serialize( |
- const DevToolsTargetImpl& target) { |
+ scoped_refptr<DevToolsAgentHost> host) { |
base::DictionaryValue* target_data = new base::DictionaryValue(); |
- scoped_refptr<content::DevToolsAgentHost> host = target.GetAgentHost(); |
target_data->SetString(kTargetSourceField, source_id_); |
target_data->SetString(kTargetIdField, host->GetId()); |
target_data->SetString(kTargetTypeField, host->GetType()); |