| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/renderer/chrome_content_renderer_client.h" | 20 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 21 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me
ssages.h" |
| 22 #include "content/public/common/content_constants.h" | 22 #include "content/public/common/content_constants.h" |
| 23 #include "content/public/renderer/document_state.h" | 23 #include "content/public/renderer/document_state.h" |
| 24 #include "content/public/renderer/render_thread.h" | 24 #include "content/public/renderer/render_thread.h" |
| 25 #include "content/public/renderer/render_view.h" | 25 #include "content/public/renderer/render_view.h" |
| 26 #include "extensions/common/url_pattern.h" | 26 #include "extensions/common/url_pattern.h" |
| 27 #include "net/base/url_util.h" | 27 #include "net/base/url_util.h" |
| 28 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
| 29 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 29 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 30 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 30 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 31 #include "third_party/WebKit/public/web/WebDocument.h" | 31 #include "third_party/WebKit/public/web/WebDocument.h" |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 break; | 717 break; |
| 718 default: | 718 default: |
| 719 break; | 719 break; |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 | 723 |
| 724 } // namespace | 724 } // namespace |
| 725 | 725 |
| 726 PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view) | 726 PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view) |
| 727 : content::RenderViewObserver(render_view), | 727 : content::RenderViewObserver(render_view) { |
| 728 data_reduction_proxy_params_( | |
| 729 data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 730 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | |
| 731 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed) { | |
| 732 } | 728 } |
| 733 | 729 |
| 734 void PageLoadHistograms::Dump(WebFrame* frame) { | 730 void PageLoadHistograms::Dump(WebFrame* frame) { |
| 735 // We only dump histograms for main frames. | 731 // We only dump histograms for main frames. |
| 736 // In the future, it may be interesting to tag subframes and dump them too. | 732 // In the future, it may be interesting to tag subframes and dump them too. |
| 737 if (!frame || frame->parent()) | 733 if (!frame || frame->parent()) |
| 738 return; | 734 return; |
| 739 | 735 |
| 740 // Only dump for supported schemes. | 736 // Only dump for supported schemes. |
| 741 URLPattern::SchemeMasks scheme_type = | 737 URLPattern::SchemeMasks scheme_type = |
| 742 GetSupportedSchemeType(frame->document().url()); | 738 GetSupportedSchemeType(frame->document().url()); |
| 743 if (scheme_type == 0) | 739 if (scheme_type == 0) |
| 744 return; | 740 return; |
| 745 | 741 |
| 746 // Ignore multipart requests. | 742 // Ignore multipart requests. |
| 747 if (frame->dataSource()->response().isMultipartPayload()) | 743 if (frame->dataSource()->response().isMultipartPayload()) |
| 748 return; | 744 return; |
| 749 | 745 |
| 750 DocumentState* document_state = | 746 DocumentState* document_state = |
| 751 DocumentState::FromDataSource(frame->dataSource()); | 747 DocumentState::FromDataSource(frame->dataSource()); |
| 752 | 748 |
| 753 bool data_reduction_proxy_was_used = | 749 bool data_reduction_proxy_was_used = false; |
| 754 data_reduction_proxy_params_.IsDataReductionProxy( | 750 if (!document_state->proxy_server().IsEmpty()) { |
| 755 document_state->proxy_server(), NULL); | 751 Send(new DataReductionProxyViewHostMsg_WasDataReductionProxyUsed( |
| 752 document_state->proxy_server(), &data_reduction_proxy_was_used)); |
| 753 } else { |
| 754 data_reduction_proxy_was_used = false; |
| 755 } |
| 756 |
| 756 bool came_from_websearch = | 757 bool came_from_websearch = |
| 757 IsFromGoogleSearchResult(frame->document().url(), | 758 IsFromGoogleSearchResult(frame->document().url(), |
| 758 GURL(frame->document().referrer())); | 759 GURL(frame->document().referrer())); |
| 759 int websearch_chrome_joint_experiment_id = kNoExperiment; | 760 int websearch_chrome_joint_experiment_id = kNoExperiment; |
| 760 bool is_preview = false; | 761 bool is_preview = false; |
| 761 if (came_from_websearch) { | 762 if (came_from_websearch) { |
| 762 websearch_chrome_joint_experiment_id = | 763 websearch_chrome_joint_experiment_id = |
| 763 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); | 764 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); |
| 764 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); | 765 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); |
| 765 } | 766 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 818 |
| 818 DCHECK(document_state); | 819 DCHECK(document_state); |
| 819 DCHECK(ds); | 820 DCHECK(ds); |
| 820 GURL url(ds->request().url()); | 821 GURL url(ds->request().url()); |
| 821 Time start = document_state->start_load_time(); | 822 Time start = document_state->start_load_time(); |
| 822 Time finish = document_state->finish_load_time(); | 823 Time finish = document_state->finish_load_time(); |
| 823 // TODO(mbelshe): should we log more stats? | 824 // TODO(mbelshe): should we log more stats? |
| 824 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 825 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 825 << url.spec(); | 826 << url.spec(); |
| 826 } | 827 } |
| OLD | NEW |