Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tracing/navigation_tracing.h" | 5 #include "chrome/browser/tracing/navigation_tracing.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/tracing/crash_service_uploader.h" | 12 #include "chrome/browser/tracing/crash_service_uploader.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "components/tracing/common/tracing_switches.h" | 14 #include "components/tracing/common/tracing_switches.h" |
| 15 #include "content/public/browser/background_tracing_config.h" | 15 #include "content/public/browser/background_tracing_config.h" |
| 16 #include "content/public/browser/background_tracing_manager.h" | 16 #include "content/public/browser/background_tracing_manager.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/navigation_handle.h" | |
| 18 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 19 | 20 |
| 20 DEFINE_WEB_CONTENTS_USER_DATA_KEY(tracing::NavigationTracingObserver); | 21 DEFINE_WEB_CONTENTS_USER_DATA_KEY(tracing::NavigationTracingObserver); |
| 21 | 22 |
| 22 using content::RenderFrameHost; | 23 using content::RenderFrameHost; |
| 23 | 24 |
| 24 namespace tracing { | 25 namespace tracing { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 content::BackgroundTracingManager::NO_DATA_FILTERING); | 95 content::BackgroundTracingManager::NO_DATA_FILTERING); |
| 95 } | 96 } |
| 96 | 97 |
| 97 bool NavigationTracingObserver::IsEnabled() { | 98 bool NavigationTracingObserver::IsEnabled() { |
| 98 return content::BackgroundTracingManager::GetInstance()->HasActiveScenario(); | 99 return content::BackgroundTracingManager::GetInstance()->HasActiveScenario(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 NavigationTracingObserver::NavigationTracingObserver( | 102 NavigationTracingObserver::NavigationTracingObserver( |
| 102 content::WebContents* web_contents) | 103 content::WebContents* web_contents) |
| 103 : content::WebContentsObserver(web_contents) { | 104 : content::WebContentsObserver(web_contents) { |
| 104 if (navigation_handle == -1) { | 105 if (navigation_handle_ == -1) { |
| 105 navigation_handle = | 106 navigation_handle_ = |
| 106 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( | 107 content::BackgroundTracingManager::GetInstance()->RegisterTriggerType( |
| 107 kNavigationTracingConfig); | 108 kNavigationTracingConfig); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 NavigationTracingObserver::~NavigationTracingObserver() { | 112 NavigationTracingObserver::~NavigationTracingObserver() { |
| 112 } | 113 } |
| 113 | 114 |
| 114 void NavigationTracingObserver::DidStartProvisionalLoadForFrame( | 115 void NavigationTracingObserver::DidStartNavigation( |
| 115 content::RenderFrameHost* render_frame_host, | 116 content::NavigationHandle* navigation_handle) { |
| 116 const GURL& validated_url, | 117 if (navigation_handle->IsInMainFrame()) { |
|
fmeawad
2017/01/26 15:44:37
Does this excludes sub-frames? We are only interes
jam
2017/01/26 16:33:35
right !render_frame_host->GetParent() is equivalen
| |
| 117 bool is_error_page) { | |
| 118 if (!render_frame_host->GetParent() && !is_error_page) { | |
| 119 content::BackgroundTracingManager::GetInstance()->TriggerNamedEvent( | 118 content::BackgroundTracingManager::GetInstance()->TriggerNamedEvent( |
| 120 navigation_handle, | 119 navigation_handle_, |
| 121 content::BackgroundTracingManager::StartedFinalizingCallback()); | 120 content::BackgroundTracingManager::StartedFinalizingCallback()); |
| 122 } | 121 } |
| 123 } | 122 } |
| 124 | 123 |
| 125 content::BackgroundTracingManager::TriggerHandle | 124 content::BackgroundTracingManager::TriggerHandle |
| 126 NavigationTracingObserver::navigation_handle = -1; | 125 NavigationTracingObserver::navigation_handle_ = -1; |
| 127 | 126 |
| 128 } // namespace tracing | 127 } // namespace tracing |
| OLD | NEW |