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/chrome_render_thread_observer.h" | 5 #include "chrome/renderer/chrome_render_thread_observer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/location.h" | 18 #include "base/location.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 23 #include "base/metrics/statistics_recorder.h" | 23 #include "base/metrics/statistics_recorder.h" |
| 24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 25 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/platform_thread.h" | 27 #include "base/threading/platform_thread.h" |
| 28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "chrome/common/cache_stats_recorder.mojom.h" | |
| 30 #include "chrome/common/child_process_logging.h" | 31 #include "chrome/common/child_process_logging.h" |
| 31 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/media/media_resource_provider.h" | 33 #include "chrome/common/media/media_resource_provider.h" |
| 33 #include "chrome/common/net/net_resource_provider.h" | 34 #include "chrome/common/net/net_resource_provider.h" |
| 34 #include "chrome/common/render_messages.h" | 35 #include "chrome/common/render_messages.h" |
| 35 #include "chrome/common/resource_usage_reporter.mojom.h" | 36 #include "chrome/common/resource_usage_reporter.mojom.h" |
| 36 #include "chrome/common/resource_usage_reporter_type_converters.h" | 37 #include "chrome/common/resource_usage_reporter_type_converters.h" |
| 37 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 38 #include "chrome/renderer/content_settings_observer.h" | 39 #include "chrome/renderer/content_settings_observer.h" |
| 39 #include "chrome/renderer/security_filter_peer.h" | 40 #include "chrome/renderer/security_filter_peer.h" |
| 40 #include "components/visitedlink/renderer/visitedlink_slave.h" | 41 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 41 #include "content/public/child/child_thread.h" | 42 #include "content/public/child/child_thread.h" |
| 42 #include "content/public/child/resource_dispatcher_delegate.h" | 43 #include "content/public/child/resource_dispatcher_delegate.h" |
| 43 #include "content/public/common/associated_interface_registry.h" | 44 #include "content/public/common/associated_interface_registry.h" |
| 44 #include "content/public/common/content_switches.h" | 45 #include "content/public/common/content_switches.h" |
| 45 #include "content/public/common/service_manager_connection.h" | 46 #include "content/public/common/service_manager_connection.h" |
| 46 #include "content/public/common/service_names.mojom.h" | 47 #include "content/public/common/service_names.mojom.h" |
| 47 #include "content/public/common/simple_connection_filter.h" | 48 #include "content/public/common/simple_connection_filter.h" |
| 48 #include "content/public/renderer/render_thread.h" | 49 #include "content/public/renderer/render_thread.h" |
| 49 #include "content/public/renderer/render_view.h" | 50 #include "content/public/renderer/render_view.h" |
| 50 #include "content/public/renderer/render_view_visitor.h" | 51 #include "content/public/renderer/render_view_visitor.h" |
| 51 #include "extensions/features/features.h" | 52 #include "extensions/features/features.h" |
| 53 #include "ipc/ipc_sync_channel.h" | |
| 52 #include "media/base/localized_strings.h" | 54 #include "media/base/localized_strings.h" |
| 53 #include "mojo/public/cpp/bindings/strong_binding.h" | 55 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 54 #include "net/base/net_errors.h" | 56 #include "net/base/net_errors.h" |
| 55 #include "net/base/net_module.h" | 57 #include "net/base/net_module.h" |
| 56 #include "services/service_manager/public/cpp/binder_registry.h" | 58 #include "services/service_manager/public/cpp/binder_registry.h" |
| 57 #include "services/service_manager/public/cpp/connector.h" | 59 #include "services/service_manager/public/cpp/connector.h" |
| 58 #include "third_party/WebKit/public/platform/WebCache.h" | 60 #include "third_party/WebKit/public/platform/WebCache.h" |
| 59 #include "third_party/WebKit/public/web/WebDocument.h" | 61 #include "third_party/WebKit/public/web/WebDocument.h" |
| 60 #include "third_party/WebKit/public/web/WebFrame.h" | 62 #include "third_party/WebKit/public/web/WebFrame.h" |
| 61 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 63 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 std::move(current_peer), RenderThread::Get(), mime_type, url); | 114 std::move(current_peer), RenderThread::Get(), mime_type, url); |
| 113 #else | 115 #else |
| 114 return current_peer; | 116 return current_peer; |
| 115 #endif | 117 #endif |
| 116 } | 118 } |
| 117 | 119 |
| 118 private: | 120 private: |
| 119 void InformHostOfCacheStats() { | 121 void InformHostOfCacheStats() { |
| 120 WebCache::UsageStats stats; | 122 WebCache::UsageStats stats; |
| 121 WebCache::GetUsageStats(&stats); | 123 WebCache::GetUsageStats(&stats); |
| 122 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats( | 124 if (!cache_stats_recorder_) |
|
sky
2017/04/21 04:30:39
{} (as body spans multiple lines).
nigeltao1
2017/04/21 23:54:09
Done.
| |
| 123 static_cast<uint64_t>(stats.capacity), | 125 RenderThread::Get()->GetChannel()->GetRemoteAssociatedInterface( |
| 124 static_cast<uint64_t>(stats.size))); | 126 &cache_stats_recorder_); |
| 127 cache_stats_recorder_->RecordCacheStats(stats.capacity, stats.size); | |
| 125 } | 128 } |
| 126 | 129 |
| 130 chrome::mojom::CacheStatsRecorderAssociatedPtr cache_stats_recorder_; | |
| 131 | |
| 127 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; | 132 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; |
| 128 | 133 |
| 129 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); | 134 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); |
| 130 }; | 135 }; |
| 131 | 136 |
| 132 static const int kWaitForWorkersStatsTimeoutMS = 20; | 137 static const int kWaitForWorkersStatsTimeoutMS = 20; |
| 133 | 138 |
| 134 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter { | 139 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter { |
| 135 public: | 140 public: |
| 136 explicit ResourceUsageReporterImpl( | 141 explicit ResourceUsageReporterImpl( |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 | 320 |
| 316 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( | 321 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( |
| 317 chrome::mojom::RendererConfigurationAssociatedRequest request) { | 322 chrome::mojom::RendererConfigurationAssociatedRequest request) { |
| 318 renderer_configuration_bindings_.AddBinding(this, std::move(request)); | 323 renderer_configuration_bindings_.AddBinding(this, std::move(request)); |
| 319 } | 324 } |
| 320 | 325 |
| 321 const RendererContentSettingRules* | 326 const RendererContentSettingRules* |
| 322 ChromeRenderThreadObserver::content_setting_rules() const { | 327 ChromeRenderThreadObserver::content_setting_rules() const { |
| 323 return &content_setting_rules_; | 328 return &content_setting_rules_; |
| 324 } | 329 } |
| OLD | NEW |