| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/common/chrome_utility_messages.h" | 15 #include "chrome/common/chrome_utility_messages.h" |
| 15 #include "chrome/common/safe_browsing/zip_analyzer.h" | 16 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 16 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 17 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 17 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 18 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 74 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 #if !defined(OS_ANDROID) | 77 #if !defined(OS_ANDROID) |
| 77 void CreateProxyResolverFactory( | 78 void CreateProxyResolverFactory( |
| 78 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | 79 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { |
| 79 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | 80 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it |
| 80 // is connected to. When that message pipe is closed, either explicitly on the | 81 // is connected to. When that message pipe is closed, either explicitly on the |
| 81 // other end (in the browser process), or by a connection error, this object | 82 // other end (in the browser process), or by a connection error, this object |
| 82 // will be destroyed. | 83 // will be destroyed. |
| 83 new net::MojoProxyResolverFactoryImpl(request.Pass()); | 84 new net::MojoProxyResolverFactoryImpl(std::move(request)); |
| 84 } | 85 } |
| 85 | 86 |
| 86 class ResourceUsageReporterImpl : public ResourceUsageReporter { | 87 class ResourceUsageReporterImpl : public ResourceUsageReporter { |
| 87 public: | 88 public: |
| 88 explicit ResourceUsageReporterImpl( | 89 explicit ResourceUsageReporterImpl( |
| 89 mojo::InterfaceRequest<ResourceUsageReporter> req) | 90 mojo::InterfaceRequest<ResourceUsageReporter> req) |
| 90 : binding_(this, req.Pass()) {} | 91 : binding_(this, std::move(req)) {} |
| 91 ~ResourceUsageReporterImpl() override {} | 92 ~ResourceUsageReporterImpl() override {} |
| 92 | 93 |
| 93 private: | 94 private: |
| 94 void GetUsageData( | 95 void GetUsageData( |
| 95 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override { | 96 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override { |
| 96 ResourceUsageDataPtr data = ResourceUsageData::New(); | 97 ResourceUsageDataPtr data = ResourceUsageData::New(); |
| 97 size_t total_heap_size = net::ProxyResolverV8::GetTotalHeapSize(); | 98 size_t total_heap_size = net::ProxyResolverV8::GetTotalHeapSize(); |
| 98 if (total_heap_size) { | 99 if (total_heap_size) { |
| 99 data->reports_v8_stats = true; | 100 data->reports_v8_stats = true; |
| 100 data->v8_bytes_allocated = total_heap_size; | 101 data->v8_bytes_allocated = total_heap_size; |
| 101 data->v8_bytes_used = net::ProxyResolverV8::GetUsedHeapSize(); | 102 data->v8_bytes_used = net::ProxyResolverV8::GetUsedHeapSize(); |
| 102 } | 103 } |
| 103 callback.Run(data.Pass()); | 104 callback.Run(std::move(data)); |
| 104 } | 105 } |
| 105 | 106 |
| 106 mojo::StrongBinding<ResourceUsageReporter> binding_; | 107 mojo::StrongBinding<ResourceUsageReporter> binding_; |
| 107 }; | 108 }; |
| 108 | 109 |
| 109 void CreateResourceUsageReporter( | 110 void CreateResourceUsageReporter( |
| 110 mojo::InterfaceRequest<ResourceUsageReporter> request) { | 111 mojo::InterfaceRequest<ResourceUsageReporter> request) { |
| 111 new ResourceUsageReporterImpl(request.Pass()); | 112 new ResourceUsageReporterImpl(std::move(request)); |
| 112 } | 113 } |
| 113 #endif // OS_ANDROID | 114 #endif // OS_ANDROID |
| 114 | 115 |
| 115 } // namespace | 116 } // namespace |
| 116 | 117 |
| 117 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 118 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
| 118 IPC::Channel::kMaximumMessageSize; | 119 IPC::Channel::kMaximumMessageSize; |
| 119 | 120 |
| 120 ChromeContentUtilityClient::ChromeContentUtilityClient() | 121 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 121 : filter_messages_(false) { | 122 : filter_messages_(false) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 #if !defined(OS_ANDROID) | 210 #if !defined(OS_ANDROID) |
| 210 registry->AddService<net::interfaces::ProxyResolverFactory>( | 211 registry->AddService<net::interfaces::ProxyResolverFactory>( |
| 211 base::Bind(CreateProxyResolverFactory)); | 212 base::Bind(CreateProxyResolverFactory)); |
| 212 registry->AddService<ResourceUsageReporter>( | 213 registry->AddService<ResourceUsageReporter>( |
| 213 base::Bind(CreateResourceUsageReporter)); | 214 base::Bind(CreateResourceUsageReporter)); |
| 214 #endif | 215 #endif |
| 215 } | 216 } |
| 216 | 217 |
| 217 void ChromeContentUtilityClient::AddHandler( | 218 void ChromeContentUtilityClient::AddHandler( |
| 218 scoped_ptr<UtilityMessageHandler> handler) { | 219 scoped_ptr<UtilityMessageHandler> handler) { |
| 219 handlers_.push_back(handler.Pass()); | 220 handlers_.push_back(std::move(handler)); |
| 220 } | 221 } |
| 221 | 222 |
| 222 // static | 223 // static |
| 223 void ChromeContentUtilityClient::PreSandboxStartup() { | 224 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 224 #if defined(ENABLE_EXTENSIONS) | 225 #if defined(ENABLE_EXTENSIONS) |
| 225 extensions::ExtensionsHandler::PreSandboxStartup(); | 226 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 226 #endif | 227 #endif |
| 227 | 228 |
| 228 #if defined(ENABLE_MDNS) | 229 #if defined(ENABLE_MDNS) |
| 229 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 230 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 safe_browsing::zip_analyzer::Results results; | 402 safe_browsing::zip_analyzer::Results results; |
| 402 safe_browsing::dmg::AnalyzeDMGFile( | 403 safe_browsing::dmg::AnalyzeDMGFile( |
| 403 IPC::PlatformFileForTransitToFile(dmg_file), &results); | 404 IPC::PlatformFileForTransitToFile(dmg_file), &results); |
| 404 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( | 405 Send(new ChromeUtilityHostMsg_AnalyzeDmgFileForDownloadProtection_Finished( |
| 405 results)); | 406 results)); |
| 406 ReleaseProcessIfNeeded(); | 407 ReleaseProcessIfNeeded(); |
| 407 } | 408 } |
| 408 #endif // defined(OS_MACOSX) | 409 #endif // defined(OS_MACOSX) |
| 409 | 410 |
| 410 #endif // defined(FULL_SAFE_BROWSING) | 411 #endif // defined(FULL_SAFE_BROWSING) |
| OLD | NEW |