Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 1028543002: Turn the utility process image decoder into a Mojo service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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/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/common/safe_browsing/zip_analyzer_results.h" 14 #include "chrome/common/safe_browsing/zip_analyzer_results.h"
15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" 15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
16 #include "chrome/utility/utility_message_handler.h" 16 #include "chrome/utility/utility_message_handler.h"
17 #include "components/image_decoder/image_decoder_impl.h"
17 #include "content/public/child/image_decoder_utils.h" 18 #include "content/public/child/image_decoder_utils.h"
18 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
19 #include "content/public/common/service_registry.h" 20 #include "content/public/common/service_registry.h"
20 #include "content/public/utility/utility_thread.h" 21 #include "content/public/utility/utility_thread.h"
21 #include "courgette/courgette.h" 22 #include "courgette/courgette.h"
22 #include "courgette/third_party/bsdiff.h" 23 #include "courgette/third_party/bsdiff.h"
23 #include "ipc/ipc_channel.h" 24 #include "ipc/ipc_channel.h"
24 #include "skia/ext/image_operations.h" 25 #include "skia/ext/image_operations.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/zlib/google/zip.h" 27 #include "third_party/zlib/google/zip.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void FinishParseMediaMetadata( 72 void FinishParseMediaMetadata(
72 metadata::MediaMetadataParser* /* parser */, 73 metadata::MediaMetadataParser* /* parser */,
73 const extensions::api::media_galleries::MediaMetadata& metadata, 74 const extensions::api::media_galleries::MediaMetadata& metadata,
74 const std::vector<metadata::AttachedImage>& attached_images) { 75 const std::vector<metadata::AttachedImage>& attached_images) {
75 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( 76 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished(
76 true, *metadata.ToValue(), attached_images)); 77 true, *metadata.ToValue(), attached_images));
77 ReleaseProcessIfNeeded(); 78 ReleaseProcessIfNeeded();
78 } 79 }
79 #endif 80 #endif
80 81
81 #if !defined(OS_ANDROID) 82 template <class Interface, class Impl>
82 void CreateProxyResolverFactory( 83 void CreateMojoService(mojo::InterfaceRequest<Interface> request) {
83 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { 84 // The Mojo service implementation is assumed to use a StrongBinding<>, which
84 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it 85 // causes the implementation to be deleted automatically when the Mojo
85 // is connected to. When that message pipe is closed, either explicitly on the 86 // connection is closed.
86 // other end (in the browser process), or by a connection error, this object 87 new Impl(request.Pass());
87 // will be destroyed.
88 new net::MojoProxyResolverFactoryImpl(request.Pass());
89 } 88 }
90 #endif // OS_ANDROID
91 89
92 } // namespace 90 } // namespace
93 91
94 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = 92 int64_t ChromeContentUtilityClient::max_ipc_message_size_ =
95 IPC::Channel::kMaximumMessageSize; 93 IPC::Channel::kMaximumMessageSize;
96 94
97 ChromeContentUtilityClient::ChromeContentUtilityClient() 95 ChromeContentUtilityClient::ChromeContentUtilityClient()
98 : filter_messages_(false) { 96 : filter_messages_(false) {
99 #if !defined(OS_ANDROID) 97 #if !defined(OS_ANDROID)
100 handlers_.push_back(new ProfileImportHandler()); 98 handlers_.push_back(new ProfileImportHandler());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 handled = (*it)->OnMessageReceived(message); 177 handled = (*it)->OnMessageReceived(message);
180 } 178 }
181 179
182 return handled; 180 return handled;
183 } 181 }
184 182
185 void ChromeContentUtilityClient::RegisterMojoServices( 183 void ChromeContentUtilityClient::RegisterMojoServices(
186 content::ServiceRegistry* registry) { 184 content::ServiceRegistry* registry) {
187 #if !defined(OS_ANDROID) 185 #if !defined(OS_ANDROID)
188 registry->AddService<net::interfaces::ProxyResolverFactory>( 186 registry->AddService<net::interfaces::ProxyResolverFactory>(
189 base::Bind(CreateProxyResolverFactory)); 187 base::Bind(CreateMojoService<net::interfaces::ProxyResolverFactory,
188 net::MojoProxyResolverFactoryImpl>));
190 #endif 189 #endif
190 registry->AddService<image_decoder::ImageDecoder>(base::Bind(
191 CreateMojoService<image_decoder::ImageDecoder,
192 image_decoder::ImageDecoderImpl>));
191 } 193 }
192 194
193 // static 195 // static
194 void ChromeContentUtilityClient::PreSandboxStartup() { 196 void ChromeContentUtilityClient::PreSandboxStartup() {
195 #if defined(ENABLE_EXTENSIONS) 197 #if defined(ENABLE_EXTENSIONS)
196 extensions::ExtensionsHandler::PreSandboxStartup(); 198 extensions::ExtensionsHandler::PreSandboxStartup();
197 #endif 199 #endif
198 200
199 #if defined(ENABLE_MDNS) 201 #if defined(ENABLE_MDNS)
200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 202 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 const std::string& mime_type, int64 total_size, bool get_attached_images) { 404 const std::string& mime_type, int64 total_size, bool get_attached_images) {
403 // Only one IPCDataSource may be created and added to the list of handlers. 405 // Only one IPCDataSource may be created and added to the list of handlers.
404 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); 406 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
405 handlers_.push_back(source); 407 handlers_.push_back(source);
406 408
407 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 409 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
408 source, mime_type, get_attached_images); 410 source, mime_type, get_attached_images);
409 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); 411 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
410 } 412 }
411 #endif 413 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698