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/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 11 matching lines...) Expand all Loading... | |
| 22 #include "courgette/third_party/bsdiff.h" | 22 #include "courgette/third_party/bsdiff.h" |
| 23 #include "ipc/ipc_channel.h" | 23 #include "ipc/ipc_channel.h" |
| 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/codec/jpeg_codec.h" | 27 #include "ui/gfx/codec/jpeg_codec.h" |
| 28 #include "ui/gfx/geometry/size.h" | 28 #include "ui/gfx/geometry/size.h" |
| 29 | 29 |
| 30 #if !defined(OS_ANDROID) | 30 #if !defined(OS_ANDROID) |
| 31 #include "chrome/utility/profile_import_handler.h" | 31 #include "chrome/utility/profile_import_handler.h" |
| 32 #include "content/public/common/resource_usage_reporter.mojom.h" | |
| 32 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 33 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 34 #include "net/proxy/proxy_resolver_v8.h" | |
| 35 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | |
| 33 #endif | 36 #endif |
| 34 | 37 |
| 35 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) | 38 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) |
| 36 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" | 39 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" |
| 37 #endif | 40 #endif |
| 38 | 41 |
| 39 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 40 #include "chrome/utility/font_cache_handler_win.h" | 43 #include "chrome/utility/font_cache_handler_win.h" |
| 41 #include "chrome/utility/shell_handler_win.h" | 44 #include "chrome/utility/shell_handler_win.h" |
| 42 #endif | 45 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 | 83 |
| 81 #if !defined(OS_ANDROID) | 84 #if !defined(OS_ANDROID) |
| 82 void CreateProxyResolverFactory( | 85 void CreateProxyResolverFactory( |
| 83 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | 86 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { |
| 84 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | 87 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it |
| 85 // is connected to. When that message pipe is closed, either explicitly on the | 88 // is connected to. When that message pipe is closed, either explicitly on the |
| 86 // other end (in the browser process), or by a connection error, this object | 89 // other end (in the browser process), or by a connection error, this object |
| 87 // will be destroyed. | 90 // will be destroyed. |
| 88 new net::MojoProxyResolverFactoryImpl(request.Pass()); | 91 new net::MojoProxyResolverFactoryImpl(request.Pass()); |
| 89 } | 92 } |
| 93 | |
| 94 class ResourceUsageReporterImpl : public content::ResourceUsageReporter { | |
| 95 public: | |
| 96 ResourceUsageReporterImpl( | |
|
ncarter (slow)
2015/05/01 21:16:52
explicit
Anand Mistry (off Chromium)
2015/05/06 02:44:18
Done.
| |
| 97 mojo::InterfaceRequest<content::ResourceUsageReporter> req) | |
| 98 : binding_(this, req.Pass()) {} | |
| 99 ~ResourceUsageReporterImpl() override {} | |
| 100 | |
| 101 private: | |
| 102 void GetUsageData(const mojo::Callback<void(content::ResourceUsageDataPtr)>& | |
| 103 callback) override { | |
| 104 content::ResourceUsageDataPtr data = content::ResourceUsageData::New(); | |
| 105 size_t total_heap_size = net::ProxyResolverV8::GetTotalHeapSize(); | |
| 106 if (total_heap_size) { | |
| 107 data->reports_v8_stats = true; | |
| 108 data->v8_memory_allocated = total_heap_size; | |
| 109 data->v8_memory_used = net::ProxyResolverV8::GetUsedHeapSize(); | |
| 110 } | |
| 111 callback.Run(data.Pass()); | |
| 112 } | |
| 113 | |
| 114 mojo::StrongBinding<content::ResourceUsageReporter> binding_; | |
| 115 }; | |
| 116 | |
| 117 void CreateResourceUsageReporter( | |
| 118 mojo::InterfaceRequest<content::ResourceUsageReporter> request) { | |
| 119 new ResourceUsageReporterImpl(request.Pass()); | |
| 120 } | |
| 90 #endif // OS_ANDROID | 121 #endif // OS_ANDROID |
| 91 | 122 |
| 92 } // namespace | 123 } // namespace |
| 93 | 124 |
| 94 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 125 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
| 95 IPC::Channel::kMaximumMessageSize; | 126 IPC::Channel::kMaximumMessageSize; |
| 96 | 127 |
| 97 ChromeContentUtilityClient::ChromeContentUtilityClient() | 128 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 98 : filter_messages_(false) { | 129 : filter_messages_(false) { |
| 99 #if !defined(OS_ANDROID) | 130 #if !defined(OS_ANDROID) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 } | 211 } |
| 181 | 212 |
| 182 return handled; | 213 return handled; |
| 183 } | 214 } |
| 184 | 215 |
| 185 void ChromeContentUtilityClient::RegisterMojoServices( | 216 void ChromeContentUtilityClient::RegisterMojoServices( |
| 186 content::ServiceRegistry* registry) { | 217 content::ServiceRegistry* registry) { |
| 187 #if !defined(OS_ANDROID) | 218 #if !defined(OS_ANDROID) |
| 188 registry->AddService<net::interfaces::ProxyResolverFactory>( | 219 registry->AddService<net::interfaces::ProxyResolverFactory>( |
| 189 base::Bind(CreateProxyResolverFactory)); | 220 base::Bind(CreateProxyResolverFactory)); |
| 221 registry->AddService<content::ResourceUsageReporter>( | |
| 222 base::Bind(CreateResourceUsageReporter)); | |
| 190 #endif | 223 #endif |
| 191 } | 224 } |
| 192 | 225 |
| 193 // static | 226 // static |
| 194 void ChromeContentUtilityClient::PreSandboxStartup() { | 227 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 195 #if defined(ENABLE_EXTENSIONS) | 228 #if defined(ENABLE_EXTENSIONS) |
| 196 extensions::ExtensionsHandler::PreSandboxStartup(); | 229 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 197 #endif | 230 #endif |
| 198 | 231 |
| 199 #if defined(ENABLE_MDNS) | 232 #if defined(ENABLE_MDNS) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 432 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
| 400 // Only one IPCDataSource may be created and added to the list of handlers. | 433 // Only one IPCDataSource may be created and added to the list of handlers. |
| 401 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 434 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
| 402 handlers_.push_back(source); | 435 handlers_.push_back(source); |
| 403 | 436 |
| 404 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 437 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
| 405 source, mime_type, get_attached_images); | 438 source, mime_type, get_attached_images); |
| 406 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 439 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
| 407 } | 440 } |
| 408 #endif | 441 #endif |
| OLD | NEW |