DevTools: Generate correct id for a remote target

BUG=338303

Review URL: https://codereview.chromium.org/144303005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247949 0039d316-1c4b-4281-b951-d872f2087c98
parent 2dd24c86
...@@ -846,7 +846,7 @@ class RemotePageTarget : public DevToolsTargetImpl { ...@@ -846,7 +846,7 @@ class RemotePageTarget : public DevToolsTargetImpl {
scoped_refptr<DevToolsAdbBridge::RemoteBrowser> browser_; scoped_refptr<DevToolsAdbBridge::RemoteBrowser> browser_;
std::string debug_url_; std::string debug_url_;
std::string frontend_url_; std::string frontend_url_;
std::string agent_id_; std::string remote_id_;
DISALLOW_COPY_AND_ASSIGN(RemotePageTarget); DISALLOW_COPY_AND_ASSIGN(RemotePageTarget);
}; };
...@@ -855,7 +855,7 @@ RemotePageTarget::RemotePageTarget( ...@@ -855,7 +855,7 @@ RemotePageTarget::RemotePageTarget(
const base::DictionaryValue& value) const base::DictionaryValue& value)
: browser_(browser) { : browser_(browser) {
type_ = "adb_page"; type_ = "adb_page";
value.GetString("id", &id_); value.GetString("id", &remote_id_);
std::string url; std::string url;
value.GetString("url", &url); value.GetString("url", &url);
url_ = GURL(url); url_ = GURL(url);
...@@ -868,12 +868,12 @@ RemotePageTarget::RemotePageTarget( ...@@ -868,12 +868,12 @@ RemotePageTarget::RemotePageTarget(
value.GetString("webSocketDebuggerUrl", &debug_url_); value.GetString("webSocketDebuggerUrl", &debug_url_);
value.GetString("devtoolsFrontendUrl", &frontend_url_); value.GetString("devtoolsFrontendUrl", &frontend_url_);
if (id_.empty() && !debug_url_.empty()) { if (remote_id_.empty() && !debug_url_.empty()) {
// Target id is not available until Chrome 26. Use page id at the end of // Target id is not available until Chrome 26. Use page id at the end of
// debug_url_ instead. For attached targets the id will remain empty. // debug_url_ instead. For attached targets the id will remain empty.
std::vector<std::string> parts; std::vector<std::string> parts;
Tokenize(debug_url_, "/", &parts); Tokenize(debug_url_, "/", &parts);
id_ = parts[parts.size()-1]; remote_id_ = parts[parts.size()-1];
} }
if (debug_url_.find("ws://") == 0) if (debug_url_.find("ws://") == 0)
...@@ -887,10 +887,10 @@ RemotePageTarget::RemotePageTarget( ...@@ -887,10 +887,10 @@ RemotePageTarget::RemotePageTarget(
if (frontend_url_.find("http:") == 0) if (frontend_url_.find("http:") == 0)
frontend_url_ = "https:" + frontend_url_.substr(5); frontend_url_ = "https:" + frontend_url_.substr(5);
agent_id_ = base::StringPrintf("%s:%s:%s", id_ = base::StringPrintf("%s:%s:%s",
browser_->device()->serial().c_str(), browser_->device()->serial().c_str(),
browser_->socket().c_str(), browser_->socket().c_str(),
id_.c_str()); remote_id_.c_str());
} }
RemotePageTarget::~RemotePageTarget() { RemotePageTarget::~RemotePageTarget() {
...@@ -901,14 +901,16 @@ bool RemotePageTarget::IsAttached() const { ...@@ -901,14 +901,16 @@ bool RemotePageTarget::IsAttached() const {
} }
void RemotePageTarget::Inspect(Profile* profile) const { void RemotePageTarget::Inspect(Profile* profile) const {
std::string request = base::StringPrintf(kActivatePageRequest, id_.c_str()); std::string request = base::StringPrintf(kActivatePageRequest,
remote_id_.c_str());
base::Closure inspect_callback = base::Bind(&AgentHostDelegate::Create, base::Closure inspect_callback = base::Bind(&AgentHostDelegate::Create,
id_, browser_, debug_url_, frontend_url_, profile); id_, browser_, debug_url_, frontend_url_, profile);
browser_->SendJsonRequest(request, inspect_callback); browser_->SendJsonRequest(request, inspect_callback);
} }
bool RemotePageTarget::Activate() const { bool RemotePageTarget::Activate() const {
std::string request = base::StringPrintf(kActivatePageRequest, id_.c_str()); std::string request = base::StringPrintf(kActivatePageRequest,
remote_id_.c_str());
browser_->SendJsonRequest(request, base::Closure()); browser_->SendJsonRequest(request, base::Closure());
return true; return true;
} }
...@@ -916,7 +918,8 @@ bool RemotePageTarget::Activate() const { ...@@ -916,7 +918,8 @@ bool RemotePageTarget::Activate() const {
bool RemotePageTarget::Close() const { bool RemotePageTarget::Close() const {
if (IsAttached()) if (IsAttached())
return false; return false;
std::string request = base::StringPrintf(kClosePageRequest, id_.c_str()); std::string request = base::StringPrintf(kClosePageRequest,
remote_id_.c_str());
browser_->SendJsonRequest(request, base::Closure()); browser_->SendJsonRequest(request, base::Closure());
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment