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

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

Issue 972083002: Report utility process JS memory in task manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-pac-oop
Patch Set: Try to fix build... again. 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"
(...skipping 10 matching lines...) Expand all
21 #include "courgette/courgette.h" 21 #include "courgette/courgette.h"
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/common/resource_usage_reporter.mojom.h"
31 #include "chrome/utility/profile_import_handler.h" 32 #include "chrome/utility/profile_import_handler.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
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 ResourceUsageReporter {
95 public:
96 explicit ResourceUsageReporterImpl(
97 mojo::InterfaceRequest<ResourceUsageReporter> req)
98 : binding_(this, req.Pass()) {}
99 ~ResourceUsageReporterImpl() override {}
100
101 private:
102 void GetUsageData(
103 const mojo::Callback<void(ResourceUsageDataPtr)>& callback) override {
104 ResourceUsageDataPtr data = ResourceUsageData::New();
105 size_t total_heap_size = net::ProxyResolverV8::GetTotalHeapSize();
jam 2015/05/12 16:12:23 so this looks like a general purpose interface to
Anand Mistry (off Chromium) 2015/05/13 00:42:11 Yes.
jam 2015/05/15 06:54:22 hmm, then perhaps this method should be called Get
Anand Mistry (off Chromium) 2015/05/15 07:25:41 Except that https://codereview.chromium.org/108132
Anand Mistry (off Chromium) 2015/05/19 04:30:50 I asked the V8 folks about this and the response i
jam 2015/05/19 16:11:46 I see, ok thanks for checking. I don't want to blo
jam 2015/05/19 16:11:46 My comment is about net::ProxyResolverV8::GetTotal
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<ResourceUsageReporter> binding_;
115 };
116
117 void CreateResourceUsageReporter(
118 mojo::InterfaceRequest<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
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<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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 const std::string& mime_type, int64 total_size, bool get_attached_images) { 435 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. 436 // Only one IPCDataSource may be created and added to the list of handlers.
404 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); 437 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
405 handlers_.push_back(source); 438 handlers_.push_back(source);
406 439
407 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 440 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
408 source, mime_type, get_attached_images); 441 source, mime_type, get_attached_images);
409 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); 442 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
410 } 443 }
411 #endif 444 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698