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 "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 Loading... | |
| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (host == "mail.google.com") | 283 if (host == "mail.google.com") |
| 282 return ".gmail"; | 284 return ".gmail"; |
| 283 if (host == "docs.google.com" || host == "drive.google.com") | 285 if (host == "docs.google.com" || host == "drive.google.com") |
| 284 return ".docs"; | 286 return ".docs"; |
| 285 if (host == "plus.google.com") | 287 if (host == "plus.google.com") |
| 286 return ".plus"; | 288 return ".plus"; |
| 287 if (host == "inbox.google.com") | 289 if (host == "inbox.google.com") |
| 288 return ".inbox"; | 290 return ".inbox"; |
| 289 if (host == "www.youtube.com") | 291 if (host == "www.youtube.com") |
| 290 return ".youtube"; | 292 return ".youtube"; |
| 293 | |
| 294 // The Top10 sites have different TLD and/or subdomains | |
| 295 // depending on the localization | |
| 296 if (host == "sina.com.cn") | |
| 297 return ".top10"; | |
| 298 | |
| 299 std::string domain = | |
| 300 net::registry_controlled_domains::GetDomainAndRegistry( | |
| 301 host, | |
| 302 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | |
| 303 | |
| 304 if (!domain.empty()) { | |
| 305 std::vector<base::StringPiece> host_tokens = base::SplitStringPiece( | |
| 306 domain, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | |
| 307 | |
| 308 if (host_tokens.size() >= 2) { | |
|
jochen (gone - plz use gerrit)
2015/10/23 12:16:21
why >= 2?
what's wrong with e.g. amazon.com?
giv
battre
2015/10/23 17:49:59
Do you expect that the traffic to sites not owned
Michael Hablich
2015/10/26 13:10:39
on '.size() >= 2':
Well, it will trigger for 'amaz
| |
| 309 if ((host_tokens[0] == "facebook") || | |
| 310 (host_tokens[0] == "baidu") || | |
| 311 (host_tokens[0] == "yahoo") || | |
| 312 (host_tokens[0] == "amazon") || | |
| 313 (host_tokens[0] == "qq") || | |
| 314 (host_tokens[0] == "twitter") || | |
| 315 (host_tokens[0] == "taobao") || | |
| 316 (host_tokens[0] == "live") || | |
| 317 (host_tokens[0] == "wikipedia")) { | |
| 318 return ".top10"; | |
|
Alexei Svitkine (slow)
2015/10/22 16:43:06
Can you make a helper function IsAlexaTop10Site()
Michael Hablich
2015/10/26 13:10:39
Done.
| |
| 319 } | |
| 320 } | |
| 321 } | |
| 322 | |
| 291 return std::string(); | 323 return std::string(); |
| 292 } | 324 } |
| 293 | 325 |
| 294 void* CreateHistogram( | 326 void* CreateHistogram( |
| 295 const char *name, int min, int max, size_t buckets) { | 327 const char *name, int min, int max, size_t buckets) { |
| 296 if (min <= 0) | 328 if (min <= 0) |
| 297 min = 1; | 329 min = 1; |
| 298 std::string histogram_name; | 330 std::string histogram_name; |
| 299 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 331 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 300 if (render_thread_impl) { // Can be null in tests. | 332 if (render_thread_impl) { // Can be null in tests. |
| (...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1965 } | 1997 } |
| 1966 | 1998 |
| 1967 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1999 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 1968 size_t erased = | 2000 size_t erased = |
| 1969 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2001 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 1970 routing_id_); | 2002 routing_id_); |
| 1971 DCHECK_EQ(1u, erased); | 2003 DCHECK_EQ(1u, erased); |
| 1972 } | 2004 } |
| 1973 | 2005 |
| 1974 } // namespace content | 2006 } // namespace content |
| OLD | NEW |