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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 1399853004: Collect separate V8 histograms for Top10 non-Google sites (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed UnitTests so they don't need to convert bool Created 5 years, 1 month 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/renderer/render_thread_impl.h ('k') | content/renderer/render_thread_impl_unittest.cc » ('j') | 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/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/allocator/allocator_extension.h" 12 #include "base/allocator/allocator_extension.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/discardable_memory_allocator.h" 17 #include "base/memory/discardable_memory_allocator.h"
18 #include "base/memory/shared_memory.h" 18 #include "base/memory/shared_memory.h"
19 #include "base/metrics/field_trial.h" 19 #include "base/metrics/field_trial.h"
20 #include "base/metrics/histogram.h" 20 #include "base/metrics/histogram.h"
21 #include "base/path_service.h" 21 #include "base/path_service.h"
22 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
23 #include "base/strings/string16.h" 23 #include "base/strings/string16.h"
24 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/string_split.h"
25 #include "base/strings/string_tokenizer.h" 26 #include "base/strings/string_tokenizer.h"
26 #include "base/strings/sys_string_conversions.h" 27 #include "base/strings/sys_string_conversions.h"
27 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
28 #include "base/thread_task_runner_handle.h" 29 #include "base/thread_task_runner_handle.h"
29 #include "base/threading/simple_thread.h" 30 #include "base/threading/simple_thread.h"
30 #include "base/threading/thread_local.h" 31 #include "base/threading/thread_local.h"
31 #include "base/threading/thread_restrictions.h" 32 #include "base/threading/thread_restrictions.h"
32 #include "base/trace_event/memory_dump_manager.h" 33 #include "base/trace_event/memory_dump_manager.h"
33 #include "base/trace_event/trace_event.h" 34 #include "base/trace_event/trace_event.h"
34 #include "base/values.h" 35 #include "base/values.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 125 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
125 #include "ipc/ipc_channel_handle.h" 126 #include "ipc/ipc_channel_handle.h"
126 #include "ipc/ipc_platform_file.h" 127 #include "ipc/ipc_platform_file.h"
127 #include "ipc/mojo/ipc_channel_mojo.h" 128 #include "ipc/mojo/ipc_channel_mojo.h"
128 #include "media/base/audio_hardware_config.h" 129 #include "media/base/audio_hardware_config.h"
129 #include "media/base/media.h" 130 #include "media/base/media.h"
130 #include "media/renderers/gpu_video_accelerator_factories.h" 131 #include "media/renderers/gpu_video_accelerator_factories.h"
131 #include "mojo/common/common_type_converters.h" 132 #include "mojo/common/common_type_converters.h"
132 #include "net/base/net_errors.h" 133 #include "net/base/net_errors.h"
133 #include "net/base/port_util.h" 134 #include "net/base/port_util.h"
135 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
134 #include "skia/ext/event_tracer_impl.h" 136 #include "skia/ext/event_tracer_impl.h"
135 #include "skia/ext/skia_memory_dump_provider.h" 137 #include "skia/ext/skia_memory_dump_provider.h"
136 #include "third_party/WebKit/public/platform/WebImageGenerator.h" 138 #include "third_party/WebKit/public/platform/WebImageGenerator.h"
137 #include "third_party/WebKit/public/platform/WebString.h" 139 #include "third_party/WebKit/public/platform/WebString.h"
138 #include "third_party/WebKit/public/platform/WebThread.h" 140 #include "third_party/WebKit/public/platform/WebThread.h"
139 #include "third_party/WebKit/public/web/WebCache.h" 141 #include "third_party/WebKit/public/web/WebCache.h"
140 #include "third_party/WebKit/public/web/WebColorName.h" 142 #include "third_party/WebKit/public/web/WebColorName.h"
141 #include "third_party/WebKit/public/web/WebDatabase.h" 143 #include "third_party/WebKit/public/web/WebDatabase.h"
142 #include "third_party/WebKit/public/web/WebDocument.h" 144 #include "third_party/WebKit/public/web/WebDocument.h"
143 #include "third_party/WebKit/public/web/WebFrame.h" 145 #include "third_party/WebKit/public/web/WebFrame.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 272 }
271 273
272 private: 274 private:
273 const std::string scheme_; 275 const std::string scheme_;
274 const std::string host_; 276 const std::string host_;
275 const double zoom_level_; 277 const double zoom_level_;
276 278
277 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); 279 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
278 }; 280 };
279 281
280 std::string HostToCustomHistogramSuffix(const std::string& host) {
281 if (host == "mail.google.com")
282 return ".gmail";
283 if (host == "docs.google.com" || host == "drive.google.com")
284 return ".docs";
285 if (host == "plus.google.com")
286 return ".plus";
287 if (host == "inbox.google.com")
288 return ".inbox";
289 if (host == "www.youtube.com")
290 return ".youtube";
291 return std::string();
292 }
293
294 void* CreateHistogram( 282 void* CreateHistogram(
295 const char *name, int min, int max, size_t buckets) { 283 const char *name, int min, int max, size_t buckets) {
296 if (min <= 0) 284 if (min <= 0)
297 min = 1; 285 min = 1;
298 std::string histogram_name; 286 std::string histogram_name;
299 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); 287 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
300 if (render_thread_impl) { // Can be null in tests. 288 if (render_thread_impl) { // Can be null in tests.
301 histogram_name = render_thread_impl-> 289 histogram_name = render_thread_impl->
302 histogram_customizer()->ConvertToCustomHistogramName(name); 290 histogram_customizer()->ConvertToCustomHistogramName(name);
303 } else { 291 } else {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 484
497 void RenderThreadImpl::HistogramCustomizer::SetCommonHost( 485 void RenderThreadImpl::HistogramCustomizer::SetCommonHost(
498 const std::string& host) { 486 const std::string& host) {
499 if (host != common_host_) { 487 if (host != common_host_) {
500 common_host_ = host; 488 common_host_ = host;
501 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host); 489 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host);
502 blink::mainThreadIsolate()->SetCreateHistogramFunction(CreateHistogram); 490 blink::mainThreadIsolate()->SetCreateHistogramFunction(CreateHistogram);
503 } 491 }
504 } 492 }
505 493
494 std::string RenderThreadImpl::HistogramCustomizer::HostToCustomHistogramSuffix(
495 const std::string& host) {
496 if (host == "mail.google.com")
497 return ".gmail";
498 if (host == "docs.google.com" || host == "drive.google.com")
499 return ".docs";
500 if (host == "plus.google.com")
501 return ".plus";
502 if (host == "inbox.google.com")
503 return ".inbox";
504 if (host == "www.youtube.com")
505 return ".youtube";
506 if (IsAlexaTop10NonGoogleSite(host))
507 return ".top10";
508
509 return std::string();
510 }
511
512 bool RenderThreadImpl::HistogramCustomizer::IsAlexaTop10NonGoogleSite(
513 const std::string& host) {
514 // The Top10 sites have different TLD and/or subdomains depending on the
515 // localization.
516 if (host == "sina.com.cn")
517 return true;
518
519 std::string sanitized_host =
520 net::registry_controlled_domains::GetDomainAndRegistry(
521 host, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
522
523 if (sanitized_host == "facebook.com")
524 return true;
525 if (sanitized_host == "baidu.com")
526 return true;
527 if (sanitized_host == "qq.com")
528 return true;
529 if (sanitized_host == "twitter.com")
530 return true;
531 if (sanitized_host == "taobao.com")
532 return true;
533 if (sanitized_host == "live.com")
534 return true;
535
536 if (!sanitized_host.empty()) {
537 std::vector<base::StringPiece> host_tokens = base::SplitStringPiece(
538 sanitized_host, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
539
540 if (host_tokens.size() >= 2) {
541 if ((host_tokens[0] == "yahoo") || (host_tokens[0] == "amazon") ||
542 (host_tokens[0] == "wikipedia")) {
543 return true;
544 }
545 }
546 }
547 return false;
548 }
549
506 // static 550 // static
507 RenderThreadImpl* RenderThreadImpl::Create( 551 RenderThreadImpl* RenderThreadImpl::Create(
508 const InProcessChildThreadParams& params) { 552 const InProcessChildThreadParams& params) {
509 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler = 553 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler =
510 scheduler::RendererScheduler::Create(); 554 scheduler::RendererScheduler::Create();
511 return new RenderThreadImpl(params, renderer_scheduler.Pass()); 555 return new RenderThreadImpl(params, renderer_scheduler.Pass());
512 } 556 }
513 557
514 // static 558 // static
515 RenderThreadImpl* RenderThreadImpl::Create( 559 RenderThreadImpl* RenderThreadImpl::Create(
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 } 2009 }
1966 2010
1967 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2011 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
1968 size_t erased = 2012 size_t erased =
1969 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2013 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
1970 routing_id_); 2014 routing_id_);
1971 DCHECK_EQ(1u, erased); 2015 DCHECK_EQ(1u, erased);
1972 } 2016 }
1973 2017
1974 } // namespace content 2018 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_thread_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698