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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/common/chrome_utility_messages.h" | 12 #include "chrome/common/chrome_utility_messages.h" |
13 #include "chrome/common/safe_browsing/zip_analyzer.h" | 13 #include "chrome/common/safe_browsing/zip_analyzer.h" |
14 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 14 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
15 #include "chrome/utility/utility_message_handler.h" | 15 #include "chrome/utility/utility_message_handler.h" |
16 #include "content/public/child/image_decoder_utils.h" | 16 #include "content/public/child/image_decoder_utils.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/process_resource_service.mojom.h" |
| 19 #include "content/public/common/service_registry.h" |
18 #include "content/public/utility/utility_thread.h" | 20 #include "content/public/utility/utility_thread.h" |
19 #include "courgette/courgette.h" | 21 #include "courgette/courgette.h" |
20 #include "courgette/third_party/bsdiff.h" | 22 #include "courgette/third_party/bsdiff.h" |
21 #include "ipc/ipc_channel.h" | 23 #include "ipc/ipc_channel.h" |
| 24 #include "net/proxy/proxy_resolver.mojom.h" |
| 25 #include "net/proxy/proxy_resolver_mojo_host.h" |
| 26 #include "net/proxy/proxy_resolver_v8.h" |
22 #include "skia/ext/image_operations.h" | 27 #include "skia/ext/image_operations.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "third_party/zlib/google/zip.h" | 29 #include "third_party/zlib/google/zip.h" |
25 #include "ui/gfx/codec/jpeg_codec.h" | 30 #include "ui/gfx/codec/jpeg_codec.h" |
26 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
27 | 32 |
28 #if !defined(OS_ANDROID) | 33 #if !defined(OS_ANDROID) |
29 #include "chrome/utility/profile_import_handler.h" | 34 #include "chrome/utility/profile_import_handler.h" |
30 #endif | 35 #endif |
31 | 36 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 IPC_END_MESSAGE_MAP() | 158 IPC_END_MESSAGE_MAP() |
154 | 159 |
155 for (Handlers::iterator it = handlers_.begin(); | 160 for (Handlers::iterator it = handlers_.begin(); |
156 !handled && it != handlers_.end(); ++it) { | 161 !handled && it != handlers_.end(); ++it) { |
157 handled = (*it)->OnMessageReceived(message); | 162 handled = (*it)->OnMessageReceived(message); |
158 } | 163 } |
159 | 164 |
160 return handled; | 165 return handled; |
161 } | 166 } |
162 | 167 |
| 168 static bool g_v8_proxy_created = false; |
| 169 |
| 170 class ProcessResourceServiceImpl |
| 171 : public mojo::InterfaceImpl<content::ProcessResourceService> { |
| 172 public: |
| 173 ProcessResourceServiceImpl() {} |
| 174 ~ProcessResourceServiceImpl() override {} |
| 175 |
| 176 private: |
| 177 void GetResourceData( |
| 178 const mojo::Callback<void(content::ResourceDataPtr)>& callback) override { |
| 179 content::ResourceDataPtr data = content::ResourceData::New(); |
| 180 data->reports_v8_stats = g_v8_proxy_created; |
| 181 if (g_v8_proxy_created) { |
| 182 data->v8_memory_allocated = net::ProxyResolverV8::GetTotalHeapSize(); |
| 183 data->v8_memory_used = net::ProxyResolverV8::GetUsedHeapSize(); |
| 184 } |
| 185 callback.Run(data.Pass()); |
| 186 } |
| 187 }; |
| 188 |
| 189 static void CreateProcessResourceService( |
| 190 mojo::InterfaceRequest<content::ProcessResourceService> request) { |
| 191 mojo::BindToRequest(new ProcessResourceServiceImpl, &request); |
| 192 } |
| 193 |
| 194 static void CreateProxyResolverFactory( |
| 195 mojo::InterfaceRequest<net::proxy::ResolverFactory> request) { |
| 196 g_v8_proxy_created = true; |
| 197 mojo::BindToRequest(new net::ProxyResolverMojoFactory(nullptr), &request); |
| 198 } |
| 199 |
| 200 void ChromeContentUtilityClient::RegisterMojoServices( |
| 201 content::ServiceRegistry* registry) { |
| 202 registry->AddService<content::ProcessResourceService>(base::Bind( |
| 203 CreateProcessResourceService)); |
| 204 registry->AddService<net::proxy::ResolverFactory>(base::Bind( |
| 205 CreateProxyResolverFactory)); |
| 206 } |
| 207 |
163 // static | 208 // static |
164 void ChromeContentUtilityClient::PreSandboxStartup() { | 209 void ChromeContentUtilityClient::PreSandboxStartup() { |
165 #if defined(ENABLE_EXTENSIONS) | 210 #if defined(ENABLE_EXTENSIONS) |
166 extensions::ExtensionsHandler::PreSandboxStartup(); | 211 extensions::ExtensionsHandler::PreSandboxStartup(); |
167 #endif | 212 #endif |
168 | 213 |
169 #if defined(ENABLE_PRINT_PREVIEW) || defined(OS_WIN) | 214 #if defined(ENABLE_PRINT_PREVIEW) || defined(OS_WIN) |
170 PrintingHandler::PreSandboxStartup(); | 215 PrintingHandler::PreSandboxStartup(); |
171 #endif | 216 #endif |
172 | 217 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 393 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
349 // Only one IPCDataSource may be created and added to the list of handlers. | 394 // Only one IPCDataSource may be created and added to the list of handlers. |
350 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 395 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
351 handlers_.push_back(source); | 396 handlers_.push_back(source); |
352 | 397 |
353 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 398 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
354 source, mime_type, get_attached_images); | 399 source, mime_type, get_attached_images); |
355 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 400 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
356 } | 401 } |
357 #endif | 402 #endif |
OLD | NEW |