Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/chrome_render_process_observer.h" | 5 #include "chrome/renderer/chrome_render_process_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/native_library.h" | 11 #include "base/native_library.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/extensions/extension_localization_peer.h" | 17 #include "chrome/common/extensions/extension_localization_peer.h" |
| 18 #include "chrome/common/net/net_resource_provider.h" | 18 #include "chrome/common/net/net_resource_provider.h" |
| 19 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
| 20 #include "chrome/renderer/chrome_content_renderer_client.h" | |
| 20 #include "chrome/renderer/content_settings_observer.h" | 21 #include "chrome/renderer/content_settings_observer.h" |
| 21 #include "chrome/renderer/security_filter_peer.h" | 22 #include "chrome/renderer/security_filter_peer.h" |
| 22 #include "content/common/resource_dispatcher.h" | 23 #include "content/common/resource_dispatcher.h" |
| 23 #include "content/common/resource_dispatcher_delegate.h" | 24 #include "content/common/resource_dispatcher_delegate.h" |
| 24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 25 #include "content/renderer/render_thread.h" | 26 #include "content/renderer/render_thread.h" |
| 26 #include "content/renderer/render_view.h" | 27 #include "content/renderer/render_view.h" |
| 27 #include "content/renderer/render_view_visitor.h" | 28 #include "content/renderer/render_view_visitor.h" |
| 28 #include "crypto/nss_util.h" | 29 #include "crypto/nss_util.h" |
| 29 #include "media/base/media.h" | 30 #include "media/base/media.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 const int shutdown_fd_; | 299 const int shutdown_fd_; |
| 299 | 300 |
| 300 DISALLOW_COPY_AND_ASSIGN(ShutdownDetector); | 301 DISALLOW_COPY_AND_ASSIGN(ShutdownDetector); |
| 301 }; | 302 }; |
| 302 #endif // OS_MACOSX | 303 #endif // OS_MACOSX |
| 303 | 304 |
| 304 } // namespace | 305 } // namespace |
| 305 | 306 |
| 306 bool ChromeRenderProcessObserver::is_incognito_process_ = false; | 307 bool ChromeRenderProcessObserver::is_incognito_process_ = false; |
| 307 | 308 |
| 308 ChromeRenderProcessObserver::ChromeRenderProcessObserver() { | 309 ChromeRenderProcessObserver::ChromeRenderProcessObserver( |
| 310 chrome::ChromeContentRendererClient* client) | |
| 311 : client_(client) { | |
| 309 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 312 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 310 if (command_line.HasSwitch(switches::kEnableWatchdog)) { | 313 if (command_line.HasSwitch(switches::kEnableWatchdog)) { |
| 311 // TODO(JAR): Need to implement renderer IO msgloop watchdog. | 314 // TODO(JAR): Need to implement renderer IO msgloop watchdog. |
| 312 } | 315 } |
| 313 | 316 |
| 314 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { | 317 if (command_line.HasSwitch(switches::kDumpHistogramsOnExit)) { |
| 315 base::StatisticsRecorder::set_dump_on_exit(true); | 318 base::StatisticsRecorder::set_dump_on_exit(true); |
| 316 } | 319 } |
| 317 | 320 |
| 318 RenderThread* thread = RenderThread::current(); | 321 RenderThread* thread = RenderThread::current(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 } | 478 } |
| 476 | 479 |
| 477 void ChromeRenderProcessObserver::OnGetV8HeapStats() { | 480 void ChromeRenderProcessObserver::OnGetV8HeapStats() { |
| 478 v8::HeapStatistics heap_stats; | 481 v8::HeapStatistics heap_stats; |
| 479 v8::V8::GetHeapStatistics(&heap_stats); | 482 v8::V8::GetHeapStatistics(&heap_stats); |
| 480 Send(new ViewHostMsg_V8HeapStats(heap_stats.total_heap_size(), | 483 Send(new ViewHostMsg_V8HeapStats(heap_stats.total_heap_size(), |
| 481 heap_stats.used_heap_size())); | 484 heap_stats.used_heap_size())); |
| 482 } | 485 } |
| 483 | 486 |
| 484 void ChromeRenderProcessObserver::OnPurgeMemory() { | 487 void ChromeRenderProcessObserver::OnPurgeMemory() { |
| 488 LOG(INFO) << "CRPO purging memory!"; | |
|
jam
2011/07/22 16:31:50
ditto
Greg Billock
2011/07/22 17:02:07
removed
On 2011/07/22 16:31:50, John Abd-El-Malek
| |
| 485 // Clear the object cache (as much as possible; some live objects cannot be | 489 // Clear the object cache (as much as possible; some live objects cannot be |
| 486 // freed). | 490 // freed). |
| 487 WebCache::clear(); | 491 WebCache::clear(); |
| 488 | 492 |
| 489 // Clear the font/glyph cache. | 493 // Clear the font/glyph cache. |
| 490 WebFontCache::clear(); | 494 WebFontCache::clear(); |
| 491 | 495 |
| 492 // Clear the Cross-Origin Preflight cache. | 496 // Clear the Cross-Origin Preflight cache. |
| 493 WebCrossOriginPreflightResultCache::clear(); | 497 WebCrossOriginPreflightResultCache::clear(); |
| 494 | 498 |
| 495 // Release all freeable memory from the SQLite process-global page cache (a | 499 // Release all freeable memory from the SQLite process-global page cache (a |
| 496 // low-level object which backs the Connection-specific page caches). | 500 // low-level object which backs the Connection-specific page caches). |
| 497 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { | 501 while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) { |
| 498 } | 502 } |
| 499 | 503 |
| 500 // Repeatedly call the V8 idle notification until it returns true ("nothing | 504 // Repeatedly call the V8 idle notification until it returns true ("nothing |
| 501 // more to free"). Note that it makes more sense to do this than to implement | 505 // more to free"). Note that it makes more sense to do this than to implement |
| 502 // a new "delete everything" pass because object references make it difficult | 506 // a new "delete everything" pass because object references make it difficult |
| 503 // to free everything possible in just one pass. | 507 // to free everything possible in just one pass. |
| 504 while (!v8::V8::IdleNotification()) { | 508 while (!v8::V8::IdleNotification()) { |
| 505 } | 509 } |
| 506 | 510 |
| 507 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 511 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
| 508 // Tell tcmalloc to release any free pages it's still holding. | 512 // Tell tcmalloc to release any free pages it's still holding. |
| 509 MallocExtension::instance()->ReleaseFreeMemory(); | 513 MallocExtension::instance()->ReleaseFreeMemory(); |
| 510 #endif | 514 #endif |
| 515 | |
| 516 if (client_) | |
|
jam
2011/07/22 16:31:50
nit: can client_ ever be NULL? if not then no need
Greg Billock
2011/07/22 17:02:07
For unit tests and such it can, so I thought this
| |
| 517 client_->OnPurgeMemory(); | |
| 511 } | 518 } |
| OLD | NEW |