Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: content/browser/devtools/render_frame_devtools_agent_host.cc

Issue 2873393002: [DevTools] Fix telemetry flakiness based on target type (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/devtools/render_frame_devtools_agent_host.h" 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); 465 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host));
466 466
467 if (web_contents() && web_contents()->GetCrashedStatus() != 467 if (web_contents() && web_contents()->GetCrashedStatus() !=
468 base::TERMINATION_STATUS_STILL_RUNNING) { 468 base::TERMINATION_STATUS_STILL_RUNNING) {
469 current_frame_crashed_ = true; 469 current_frame_crashed_ = true;
470 } 470 }
471 471
472 g_instances.Get().push_back(this); 472 g_instances.Get().push_back(this);
473 AddRef(); // Balanced in RenderFrameHostDestroyed. 473 AddRef(); // Balanced in RenderFrameHostDestroyed.
474 474
475 DevToolsManager* manager = DevToolsManager::GetInstance();
476 if (manager->delegate()) {
477 type_ = manager->delegate()->GetTargetType(host);
478 title_ = manager->delegate()->GetTargetTitle(host);
479 }
480
481 NotifyCreated(); 475 NotifyCreated();
482 } 476 }
483 477
484 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { 478 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) {
485 DCHECK(!pending_); 479 DCHECK(!pending_);
486 current_frame_crashed_ = false; 480 current_frame_crashed_ = false;
487 pending_.reset(new FrameHostHolder(this, host)); 481 pending_.reset(new FrameHostHolder(this, host));
488 if (IsAttached()) 482 if (IsAttached())
489 pending_->Reattach(current_.get()); 483 pending_->Reattach(current_.get());
490 484
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); 1007 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents());
1014 if (!contents) 1008 if (!contents)
1015 return ""; 1009 return "";
1016 contents = contents->GetOuterWebContents(); 1010 contents = contents->GetOuterWebContents();
1017 if (contents) 1011 if (contents)
1018 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); 1012 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId();
1019 return ""; 1013 return "";
1020 } 1014 }
1021 1015
1022 std::string RenderFrameDevToolsAgentHost::GetType() { 1016 std::string RenderFrameDevToolsAgentHost::GetType() {
1023 if (!type_.empty()) 1017 DevToolsManager* manager = DevToolsManager::GetInstance();
1024 return type_; 1018 if (manager->delegate() && current_) {
1019 std::string type = manager->delegate()->GetTargetType(current_->host());
1020 if (!type.empty())
1021 return type;
1022 }
1023
1025 if (IsChildFrame()) 1024 if (IsChildFrame())
1026 return kTypeFrame; 1025 return kTypeFrame;
1027 return kTypePage; 1026 return kTypePage;
1028 } 1027 }
1029 1028
1030 std::string RenderFrameDevToolsAgentHost::GetTitle() { 1029 std::string RenderFrameDevToolsAgentHost::GetTitle() {
1031 if (!title_.empty()) 1030 DevToolsManager* manager = DevToolsManager::GetInstance();
1032 return title_; 1031 if (manager->delegate() && current_) {
1032 std::string title = manager->delegate()->GetTargetTitle(current_->host());
1033 if (!title.empty())
1034 return title;
1035 }
1036
1033 if (current_ && current_->host()->GetParent()) 1037 if (current_ && current_->host()->GetParent())
1034 return current_->host()->GetLastCommittedURL().spec(); 1038 return current_->host()->GetLastCommittedURL().spec();
1035 content::WebContents* web_contents = GetWebContents(); 1039 content::WebContents* web_contents = GetWebContents();
1036 if (web_contents) 1040 if (web_contents)
1037 return base::UTF16ToUTF8(web_contents->GetTitle()); 1041 return base::UTF16ToUTF8(web_contents->GetTitle());
1038 return GetURL().spec(); 1042 return GetURL().spec();
1039 } 1043 }
1040 1044
1041 std::string RenderFrameDevToolsAgentHost::GetDescription() { 1045 std::string RenderFrameDevToolsAgentHost::GetDescription() {
1042 DevToolsManager* manager = DevToolsManager::GetInstance(); 1046 DevToolsManager* manager = DevToolsManager::GetInstance();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 RenderFrameHost* host) { 1169 RenderFrameHost* host) {
1166 return (current_ && current_->host() == host) || 1170 return (current_ && current_->host() == host) ||
1167 (pending_ && pending_->host() == host); 1171 (pending_ && pending_->host() == host);
1168 } 1172 }
1169 1173
1170 bool RenderFrameDevToolsAgentHost::IsChildFrame() { 1174 bool RenderFrameDevToolsAgentHost::IsChildFrame() {
1171 return current_ && current_->host()->GetParent(); 1175 return current_ && current_->host()->GetParent();
1172 } 1176 }
1173 1177
1174 } // namespace content 1178 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698