Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/renderer/page_load_histograms.h" | 5 #include "chrome/renderer/page_load_histograms.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/metrics/persistent_histogram_allocator.h" | |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/renderer/searchbox/search_bouncer.h" | 24 #include "chrome/renderer/searchbox/search_bouncer.h" |
| 24 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" | 25 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" |
| 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 DumpDeprecatedHistograms(frame->performance(), document_state, | 870 DumpDeprecatedHistograms(frame->performance(), document_state, |
| 870 data_reduction_proxy_was_used, | 871 data_reduction_proxy_was_used, |
| 871 came_from_websearch, | 872 came_from_websearch, |
| 872 websearch_chrome_joint_experiment_id, | 873 websearch_chrome_joint_experiment_id, |
| 873 is_preview, | 874 is_preview, |
| 874 scheme_type); | 875 scheme_type); |
| 875 | 876 |
| 876 // Log the PLT to the info log. | 877 // Log the PLT to the info log. |
| 877 LogPageLoadTime(document_state, frame->dataSource()); | 878 LogPageLoadTime(document_state, frame->dataSource()); |
| 878 | 879 |
| 879 // Since there are currently no guarantees that renderer histograms will be | 880 // If persistent histograms are not enabled, initiate a PostTask here to be |
| 880 // sent to the browser, we initiate a PostTask here to be sure that we send | 881 // sure that we send the histograms generated. Without this call, pages |
| 881 // the histograms we generated. Without this call, pages that don't have an | 882 // that don't have an on-close-handler might generate data that is lost if |
| 882 // on-close-handler might generate data that is lost when the renderer is | 883 // the renderer is shutdown abruptly (e.g. the user closed the tab). |
|
Alexei Svitkine (slow)
2016/08/10 15:44:28
Maybe add a TODO to clean this up when persistent
bcwhite
2016/08/10 16:30:55
Done.
| |
| 883 // shutdown abruptly (perchance because the user closed the tab). | 884 if (!base::GlobalHistogramAllocator::Get()) { |
| 884 // TODO(jar) BUG=33233: This needs to be moved to a PostDelayedTask, and it | 885 content::RenderThread::Get()->UpdateHistograms( |
| 885 // should post when the onload is complete, so that it doesn't interfere with | 886 content::kHistogramSynchronizerReservedSequenceNumber); |
| 886 // the next load. | 887 } |
| 887 content::RenderThread::Get()->UpdateHistograms( | |
| 888 content::kHistogramSynchronizerReservedSequenceNumber); | |
| 889 } | 888 } |
| 890 | 889 |
| 891 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { | 890 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { |
| 892 Dump(frame); | 891 Dump(frame); |
| 893 } | 892 } |
| 894 | 893 |
| 895 void PageLoadHistograms::ClosePage() { | 894 void PageLoadHistograms::ClosePage() { |
| 896 // TODO(davemoore) This code should be removed once willClose() gets | 895 // TODO(davemoore) This code should be removed once willClose() gets |
| 897 // called when a page is destroyed. page_load_histograms_.Dump() is safe | 896 // called when a page is destroyed. page_load_histograms_.Dump() is safe |
| 898 // to call multiple times for the same frame, but it will simplify things. | 897 // to call multiple times for the same frame, but it will simplify things. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 912 Time start = document_state->start_load_time(); | 911 Time start = document_state->start_load_time(); |
| 913 Time finish = document_state->finish_load_time(); | 912 Time finish = document_state->finish_load_time(); |
| 914 // TODO(mbelshe): should we log more stats? | 913 // TODO(mbelshe): should we log more stats? |
| 915 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 914 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 916 << url.spec(); | 915 << url.spec(); |
| 917 } | 916 } |
| 918 | 917 |
| 919 void PageLoadHistograms::OnDestruct() { | 918 void PageLoadHistograms::OnDestruct() { |
| 920 delete this; | 919 delete this; |
| 921 } | 920 } |
| OLD | NEW |