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/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "skia/ext/image_operations.h" | 24 #include "skia/ext/image_operations.h" |
25 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
26 #include "third_party/zlib/google/zip.h" | 26 #include "third_party/zlib/google/zip.h" |
27 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
28 | 28 |
29 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
30 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h" | 30 #include "ui/gfx/chromeos/codec/jpeg_codec_robust_slow.h" |
31 #endif | 31 #endif |
32 | 32 |
33 #if !defined(OS_ANDROID) | 33 #if !defined(OS_ANDROID) |
| 34 #include "chrome/common/resource_usage_reporter.mojom.h" |
34 #include "chrome/utility/profile_import_handler.h" | 35 #include "chrome/utility/profile_import_handler.h" |
35 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 36 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 37 #include "net/proxy/proxy_resolver_v8.h" |
| 38 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
36 #endif | 39 #endif |
37 | 40 |
38 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | 41 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) |
39 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 42 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
40 #endif | 43 #endif |
41 | 44 |
42 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
43 #include "chrome/utility/font_cache_handler_win.h" | 46 #include "chrome/utility/font_cache_handler_win.h" |
44 #include "chrome/utility/shell_handler_win.h" | 47 #include "chrome/utility/shell_handler_win.h" |
45 #endif | 48 #endif |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 86 |
84 #if !defined(OS_ANDROID) | 87 #if !defined(OS_ANDROID) |
85 void CreateProxyResolverFactory( | 88 void CreateProxyResolverFactory( |
86 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | 89 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { |
87 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | 90 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it |
88 // is connected to. When that message pipe is closed, either explicitly on the | 91 // is connected to. When that message pipe is closed, either explicitly on the |
89 // other end (in the browser process), or by a connection error, this object | 92 // other end (in the browser process), or by a connection error, this object |
90 // will be destroyed. | 93 // will be destroyed. |
91 new net::MojoProxyResolverFactoryImpl(request.Pass()); | 94 new net::MojoProxyResolverFactoryImpl(request.Pass()); |
92 } | 95 } |
| 96 |
| 97 class ResourceUsageReporterImpl : public ResourceUsageReporter { |
| 98 public: |
| 99 explicit ResourceUsageReporterImpl( |
| 100 mojo::InterfaceRequest<ResourceUsageReporter> req) |
| 101 : binding_(this, req.Pass()) {} |
| 102 ~ResourceUsageReporterImpl() override {} |
| 103 |
| 104 private: |
| 105 void GetUsageData( |
| 106 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override { |
| 107 ResourceUsageDataPtr data = ResourceUsageData::New(); |
| 108 size_t total_heap_size = net::ProxyResolverV8::GetTotalHeapSize(); |
| 109 if (total_heap_size) { |
| 110 data->reports_v8_stats = true; |
| 111 data->v8_bytes_allocated = total_heap_size; |
| 112 data->v8_bytes_used = net::ProxyResolverV8::GetUsedHeapSize(); |
| 113 } |
| 114 callback.Run(data.Pass()); |
| 115 } |
| 116 |
| 117 mojo::StrongBinding<ResourceUsageReporter> binding_; |
| 118 }; |
| 119 |
| 120 void CreateResourceUsageReporter( |
| 121 mojo::InterfaceRequest<ResourceUsageReporter> request) { |
| 122 new ResourceUsageReporterImpl(request.Pass()); |
| 123 } |
93 #endif // OS_ANDROID | 124 #endif // OS_ANDROID |
94 | 125 |
95 } // namespace | 126 } // namespace |
96 | 127 |
97 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 128 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
98 IPC::Channel::kMaximumMessageSize; | 129 IPC::Channel::kMaximumMessageSize; |
99 | 130 |
100 ChromeContentUtilityClient::ChromeContentUtilityClient() | 131 ChromeContentUtilityClient::ChromeContentUtilityClient() |
101 : filter_messages_(false) { | 132 : filter_messages_(false) { |
102 #if !defined(OS_ANDROID) | 133 #if !defined(OS_ANDROID) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 216 } |
186 | 217 |
187 return handled; | 218 return handled; |
188 } | 219 } |
189 | 220 |
190 void ChromeContentUtilityClient::RegisterMojoServices( | 221 void ChromeContentUtilityClient::RegisterMojoServices( |
191 content::ServiceRegistry* registry) { | 222 content::ServiceRegistry* registry) { |
192 #if !defined(OS_ANDROID) | 223 #if !defined(OS_ANDROID) |
193 registry->AddService<net::interfaces::ProxyResolverFactory>( | 224 registry->AddService<net::interfaces::ProxyResolverFactory>( |
194 base::Bind(CreateProxyResolverFactory)); | 225 base::Bind(CreateProxyResolverFactory)); |
| 226 registry->AddService<ResourceUsageReporter>( |
| 227 base::Bind(CreateResourceUsageReporter)); |
195 #endif | 228 #endif |
196 } | 229 } |
197 | 230 |
198 // static | 231 // static |
199 void ChromeContentUtilityClient::PreSandboxStartup() { | 232 void ChromeContentUtilityClient::PreSandboxStartup() { |
200 #if defined(ENABLE_EXTENSIONS) | 233 #if defined(ENABLE_EXTENSIONS) |
201 extensions::ExtensionsHandler::PreSandboxStartup(); | 234 extensions::ExtensionsHandler::PreSandboxStartup(); |
202 #endif | 235 #endif |
203 | 236 |
204 #if defined(ENABLE_MDNS) | 237 #if defined(ENABLE_MDNS) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 441 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
409 // Only one IPCDataSource may be created and added to the list of handlers. | 442 // Only one IPCDataSource may be created and added to the list of handlers. |
410 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 443 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
411 handlers_.push_back(source); | 444 handlers_.push_back(source); |
412 | 445 |
413 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 446 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
414 source, mime_type, get_attached_images); | 447 source, mime_type, get_attached_images); |
415 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 448 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
416 } | 449 } |
417 #endif | 450 #endif |
OLD | NEW |