Chromium Code Reviews

Side by Side Diff: chrome/renderer/chrome_render_thread_observer.cc

Issue 2643183002: Convert ChromeViewHostMsg_UpdatedCacheStats to use mojo. (Closed)
Patch Set: Convert ChromeViewHostMsg_UpdatedCacheStats to use mojo. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 "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/resource_dispatcher_delegate.h" 42 #include "content/public/child/resource_dispatcher_delegate.h"
42 #include "content/public/common/associated_interface_registry.h" 43 #include "content/public/common/associated_interface_registry.h"
43 #include "content/public/common/content_switches.h" 44 #include "content/public/common/content_switches.h"
44 #include "content/public/common/service_names.mojom.h" 45 #include "content/public/common/service_names.mojom.h"
45 #include "content/public/renderer/render_thread.h" 46 #include "content/public/renderer/render_thread.h"
46 #include "content/public/renderer/render_view.h" 47 #include "content/public/renderer/render_view.h"
47 #include "content/public/renderer/render_view_visitor.h" 48 #include "content/public/renderer/render_view_visitor.h"
48 #include "extensions/features/features.h" 49 #include "extensions/features/features.h"
50 #include "ipc/ipc_sync_channel.h"
49 #include "media/base/localized_strings.h" 51 #include "media/base/localized_strings.h"
50 #include "mojo/public/cpp/bindings/strong_binding.h" 52 #include "mojo/public/cpp/bindings/strong_binding.h"
51 #include "net/base/net_errors.h" 53 #include "net/base/net_errors.h"
52 #include "net/base/net_module.h" 54 #include "net/base/net_module.h"
53 #include "services/service_manager/public/cpp/connector.h" 55 #include "services/service_manager/public/cpp/connector.h"
54 #include "services/service_manager/public/cpp/interface_registry.h" 56 #include "services/service_manager/public/cpp/interface_registry.h"
55 #include "third_party/WebKit/public/platform/WebCache.h" 57 #include "third_party/WebKit/public/platform/WebCache.h"
56 #include "third_party/WebKit/public/web/WebDocument.h" 58 #include "third_party/WebKit/public/web/WebDocument.h"
57 #include "third_party/WebKit/public/web/WebFrame.h" 59 #include "third_party/WebKit/public/web/WebFrame.h"
58 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 60 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
(...skipping 50 matching lines...)
109 std::move(current_peer), RenderThread::Get(), mime_type, url); 111 std::move(current_peer), RenderThread::Get(), mime_type, url);
110 #else 112 #else
111 return current_peer; 113 return current_peer;
112 #endif 114 #endif
113 } 115 }
114 116
115 private: 117 private:
116 void InformHostOfCacheStats() { 118 void InformHostOfCacheStats() {
117 WebCache::UsageStats stats; 119 WebCache::UsageStats stats;
118 WebCache::getUsageStats(&stats); 120 WebCache::getUsageStats(&stats);
119 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats( 121 if (!cache_stats_recorder_)
120 static_cast<uint64_t>(stats.capacity), 122 RenderThread::Get()->GetChannel()->GetRemoteAssociatedInterface(
121 static_cast<uint64_t>(stats.size))); 123 &cache_stats_recorder_);
124 cache_stats_recorder_->RecordCacheStats(stats.capacity, stats.size);
122 } 125 }
123 126
127 chrome::mojom::CacheStatsRecorderAssociatedPtr cache_stats_recorder_;
128
124 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_; 129 base::WeakPtrFactory<RendererResourceDelegate> weak_factory_;
125 130
126 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); 131 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
127 }; 132 };
128 133
129 static const int kWaitForWorkersStatsTimeoutMS = 20; 134 static const int kWaitForWorkersStatsTimeoutMS = 20;
130 135
131 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter { 136 class ResourceUsageReporterImpl : public chrome::mojom::ResourceUsageReporter {
132 public: 137 public:
133 explicit ResourceUsageReporterImpl( 138 explicit ResourceUsageReporterImpl(
(...skipping 171 matching lines...)
305 310
306 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest( 311 void ChromeRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
307 chrome::mojom::RendererConfigurationAssociatedRequest request) { 312 chrome::mojom::RendererConfigurationAssociatedRequest request) {
308 renderer_configuration_bindings_.AddBinding(this, std::move(request)); 313 renderer_configuration_bindings_.AddBinding(this, std::move(request));
309 } 314 }
310 315
311 const RendererContentSettingRules* 316 const RendererContentSettingRules*
312 ChromeRenderThreadObserver::content_setting_rules() const { 317 ChromeRenderThreadObserver::content_setting_rules() const {
313 return &content_setting_rules_; 318 return &content_setting_rules_;
314 } 319 }
OLDNEW

Powered by Google App Engine