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> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
22 #include "base/metrics/field_trial.h" | 22 #include "base/metrics/field_trial.h" |
23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
24 #include "base/metrics/statistics_recorder.h" | 24 #include "base/metrics/statistics_recorder.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/single_thread_task_runner.h" | 26 #include "base/single_thread_task_runner.h" |
27 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
28 #include "base/threading/platform_thread.h" | 28 #include "base/threading/platform_thread.h" |
29 #include "base/threading/thread_task_runner_handle.h" | 29 #include "base/threading/thread_task_runner_handle.h" |
30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "chrome/common/cache_stats_recorder.mojom.h" |
31 #include "chrome/common/child_process_logging.h" | 32 #include "chrome/common/child_process_logging.h" |
32 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
33 #include "chrome/common/field_trial_recorder.mojom.h" | 34 #include "chrome/common/field_trial_recorder.mojom.h" |
34 #include "chrome/common/media/media_resource_provider.h" | 35 #include "chrome/common/media/media_resource_provider.h" |
35 #include "chrome/common/net/net_resource_provider.h" | 36 #include "chrome/common/net/net_resource_provider.h" |
36 #include "chrome/common/render_messages.h" | 37 #include "chrome/common/render_messages.h" |
37 #include "chrome/common/resource_usage_reporter.mojom.h" | 38 #include "chrome/common/resource_usage_reporter.mojom.h" |
38 #include "chrome/common/resource_usage_reporter_type_converters.h" | 39 #include "chrome/common/resource_usage_reporter_type_converters.h" |
39 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
40 #include "chrome/renderer/content_settings_observer.h" | 41 #include "chrome/renderer/content_settings_observer.h" |
41 #include "chrome/renderer/security_filter_peer.h" | 42 #include "chrome/renderer/security_filter_peer.h" |
42 #include "components/visitedlink/renderer/visitedlink_slave.h" | 43 #include "components/visitedlink/renderer/visitedlink_slave.h" |
43 #include "content/public/child/resource_dispatcher_delegate.h" | 44 #include "content/public/child/resource_dispatcher_delegate.h" |
44 #include "content/public/common/associated_interface_registry.h" | 45 #include "content/public/common/associated_interface_registry.h" |
45 #include "content/public/common/content_switches.h" | 46 #include "content/public/common/content_switches.h" |
46 #include "content/public/renderer/render_thread.h" | 47 #include "content/public/renderer/render_thread.h" |
47 #include "content/public/renderer/render_view.h" | 48 #include "content/public/renderer/render_view.h" |
48 #include "content/public/renderer/render_view_visitor.h" | 49 #include "content/public/renderer/render_view_visitor.h" |
49 #include "extensions/features/features.h" | 50 #include "extensions/features/features.h" |
| 51 #include "ipc/ipc_sync_channel.h" |
50 #include "media/base/localized_strings.h" | 52 #include "media/base/localized_strings.h" |
51 #include "mojo/public/cpp/bindings/strong_binding.h" | 53 #include "mojo/public/cpp/bindings/strong_binding.h" |
52 #include "net/base/net_errors.h" | 54 #include "net/base/net_errors.h" |
53 #include "net/base/net_module.h" | 55 #include "net/base/net_module.h" |
54 #include "services/service_manager/public/cpp/interface_provider.h" | 56 #include "services/service_manager/public/cpp/interface_provider.h" |
55 #include "services/service_manager/public/cpp/interface_registry.h" | 57 #include "services/service_manager/public/cpp/interface_registry.h" |
56 #include "third_party/WebKit/public/platform/WebCache.h" | 58 #include "third_party/WebKit/public/platform/WebCache.h" |
57 #include "third_party/WebKit/public/web/WebDocument.h" | 59 #include "third_party/WebKit/public/web/WebDocument.h" |
58 #include "third_party/WebKit/public/web/WebFrame.h" | 60 #include "third_party/WebKit/public/web/WebFrame.h" |
59 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 61 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 std::move(current_peer), RenderThread::Get(), mime_type, url); | 112 std::move(current_peer), RenderThread::Get(), mime_type, url); |
111 #else | 113 #else |
112 return current_peer; | 114 return current_peer; |
113 #endif | 115 #endif |
114 } | 116 } |
115 | 117 |
116 private: | 118 private: |
117 void InformHostOfCacheStats() { | 119 void InformHostOfCacheStats() { |
118 WebCache::UsageStats stats; | 120 WebCache::UsageStats stats; |
119 WebCache::getUsageStats(&stats); | 121 WebCache::getUsageStats(&stats); |
120 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats( | 122 if (!cache_stats_recorder_) |
121 static_cast<uint64_t>(stats.capacity), | 123 RenderThread::Get()->GetChannel()->GetRemoteAssociatedInterface( |
122 static_cast<uint64_t>(stats.size))); | 124 &cache_stats_recorder_); |
| 125 cache_stats_recorder_->RecordCacheStats(stats.capacity, stats.size); |
123 } | 126 } |
124 | 127 |
| 128 chrome::mojom::CacheStatsRecorderAssociatedPtr cache_stats_recorder_; |
| 129 |
125 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; | 130 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; |
126 | 131 |
127 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); |
128 }; | 133 }; |
129 | 134 |
130 static const int kWaitForWorkersStatsTimeoutMS = 20; | 135 static const int kWaitForWorkersStatsTimeoutMS = 20; |
131 | 136 |
132 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter { | 137 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter { |
133 public: | 138 public: |
134 explicit ResourceUsageReporterImpl( | 139 explicit ResourceUsageReporterImpl( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 327 |
323 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( | 328 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( |
324 chrome::mojom::RendererConfigurationAssociatedRequest request) { | 329 chrome::mojom::RendererConfigurationAssociatedRequest request) { |
325 renderer_configuration_bindings_.AddBinding(this, std::move(request)); | 330 renderer_configuration_bindings_.AddBinding(this, std::move(request)); |
326 } | 331 } |
327 | 332 |
328 const RendererContentSettingRules* | 333 const RendererContentSettingRules* |
329 ChromeRenderThreadObserver::content_setting_rules() const { | 334 ChromeRenderThreadObserver::content_setting_rules() const { |
330 return &content_setting_rules_; | 335 return &content_setting_rules_; |
331 } | 336 } |
OLD | NEW |