| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "content/renderer/render_thread.h" | 26 #include "content/renderer/render_thread.h" |
| 27 #include "content/renderer/render_view.h" | 27 #include "content/renderer/render_view.h" |
| 28 #include "content/renderer/render_view_visitor.h" | 28 #include "content/renderer/render_view_visitor.h" |
| 29 #include "crypto/nss_util.h" | 29 #include "crypto/nss_util.h" |
| 30 #include "media/base/media.h" | 30 #include "media/base/media.h" |
| 31 #include "media/base/media_switches.h" | 31 #include "media/base/media_switches.h" |
| 32 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
| 33 #include "net/base/net_module.h" | 33 #include "net/base/net_module.h" |
| 34 #include "third_party/sqlite/sqlite3.h" | 34 #include "third_party/sqlite/sqlite3.h" |
| 35 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 35 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
| 36 #include "third_party/tcmalloc/chromium/src/google/heap-profiler.h" | |
| 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" |
| 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCrossOriginPreflig
htResultCache.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCrossOriginPreflig
htResultCache.h" |
| 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFontCache.h" | 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFontCache.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 44 #include "v8/include/v8.h" | 43 #include "v8/include/v8.h" |
| 45 | 44 |
| 46 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 IPC_MESSAGE_HANDLER(ViewMsg_SetIsIncognitoProcess, OnSetIsIncognitoProcess) | 400 IPC_MESSAGE_HANDLER(ViewMsg_SetIsIncognitoProcess, OnSetIsIncognitoProcess) |
| 402 IPC_MESSAGE_HANDLER(ViewMsg_SetDefaultContentSettings, | 401 IPC_MESSAGE_HANDLER(ViewMsg_SetDefaultContentSettings, |
| 403 OnSetDefaultContentSettings) | 402 OnSetDefaultContentSettings) |
| 404 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL, | 403 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL, |
| 405 OnSetContentSettingsForCurrentURL) | 404 OnSetContentSettingsForCurrentURL) |
| 406 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 405 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
| 407 IPC_MESSAGE_HANDLER(ViewMsg_ClearCache, OnClearCache) | 406 IPC_MESSAGE_HANDLER(ViewMsg_ClearCache, OnClearCache) |
| 408 IPC_MESSAGE_HANDLER(ViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) | 407 IPC_MESSAGE_HANDLER(ViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) |
| 409 #if defined(USE_TCMALLOC) | 408 #if defined(USE_TCMALLOC) |
| 410 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, OnGetRendererTcmalloc) | 409 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, OnGetRendererTcmalloc) |
| 411 IPC_MESSAGE_HANDLER(ViewMsg_SetTcmallocHeapProfiling, | |
| 412 OnSetTcmallocHeapProfiling) | |
| 413 IPC_MESSAGE_HANDLER(ViewMsg_WriteTcmallocHeapProfile, | |
| 414 OnWriteTcmallocHeapProfile) | |
| 415 #endif | 410 #endif |
| 416 IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats) | 411 IPC_MESSAGE_HANDLER(ViewMsg_GetV8HeapStats, OnGetV8HeapStats) |
| 417 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) | 412 IPC_MESSAGE_HANDLER(ViewMsg_GetCacheResourceStats, OnGetCacheResourceStats) |
| 418 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory) | 413 IPC_MESSAGE_HANDLER(ViewMsg_PurgeMemory, OnPurgeMemory) |
| 419 IPC_MESSAGE_UNHANDLED(handled = false) | 414 IPC_MESSAGE_UNHANDLED(handled = false) |
| 420 IPC_END_MESSAGE_MAP() | 415 IPC_END_MESSAGE_MAP() |
| 421 return handled; | 416 return handled; |
| 422 } | 417 } |
| 423 | 418 |
| 424 void ChromeRenderProcessObserver::WebKitInitialized() { | 419 void ChromeRenderProcessObserver::WebKitInitialized() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { | 451 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { |
| 457 WebCache::ResourceTypeStats stats; | 452 WebCache::ResourceTypeStats stats; |
| 458 WebCache::getResourceTypeStats(&stats); | 453 WebCache::getResourceTypeStats(&stats); |
| 459 Send(new ViewHostMsg_ResourceTypeStats(stats)); | 454 Send(new ViewHostMsg_ResourceTypeStats(stats)); |
| 460 } | 455 } |
| 461 | 456 |
| 462 #if defined(USE_TCMALLOC) | 457 #if defined(USE_TCMALLOC) |
| 463 void ChromeRenderProcessObserver::OnGetRendererTcmalloc() { | 458 void ChromeRenderProcessObserver::OnGetRendererTcmalloc() { |
| 464 std::string result; | 459 std::string result; |
| 465 char buffer[1024 * 32]; | 460 char buffer[1024 * 32]; |
| 461 base::ProcessId pid = base::GetCurrentProcId(); |
| 466 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | 462 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); |
| 467 result.append(buffer); | 463 result.append(buffer); |
| 468 Send(new ViewHostMsg_RendererTcmalloc(result)); | 464 Send(new ViewHostMsg_RendererTcmalloc(pid, result)); |
| 469 } | 465 } |
| 470 | |
| 471 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( | |
| 472 bool profiling, const std::string& filename_prefix) { | |
| 473 if (profiling) | |
| 474 HeapProfilerStart(filename_prefix.c_str()); | |
| 475 else | |
| 476 HeapProfilerStop(); | |
| 477 } | |
| 478 | |
| 479 void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile( | |
| 480 const FilePath::StringType& filename) { | |
| 481 if (!IsHeapProfilerRunning()) | |
| 482 return; | |
| 483 char* profile = GetHeapProfile(); | |
| 484 if (!profile) { | |
| 485 LOG(WARNING) << "Unable to get heap profile."; | |
| 486 return; | |
| 487 } | |
| 488 // The render process can not write to a file, so copy the result into | |
| 489 // a string and pass it to the handler (which runs on the browser host). | |
| 490 std::string result(profile); | |
| 491 delete profile; | |
| 492 Send(new ViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result)); | |
| 493 } | |
| 494 | |
| 495 #endif | 466 #endif |
| 496 | 467 |
| 497 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( | 468 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( |
| 498 const std::string& field_trial_name, | 469 const std::string& field_trial_name, |
| 499 const std::string& group_name) { | 470 const std::string& group_name) { |
| 500 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); | 471 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); |
| 501 } | 472 } |
| 502 | 473 |
| 503 void ChromeRenderProcessObserver::OnGetV8HeapStats() { | 474 void ChromeRenderProcessObserver::OnGetV8HeapStats() { |
| 504 v8::HeapStatistics heap_stats; | 475 v8::HeapStatistics heap_stats; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 531 } | 502 } |
| 532 | 503 |
| 533 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 504 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
| 534 // Tell tcmalloc to release any free pages it's still holding. | 505 // Tell tcmalloc to release any free pages it's still holding. |
| 535 MallocExtension::instance()->ReleaseFreeMemory(); | 506 MallocExtension::instance()->ReleaseFreeMemory(); |
| 536 #endif | 507 #endif |
| 537 | 508 |
| 538 if (client_) | 509 if (client_) |
| 539 client_->OnPurgeMemory(); | 510 client_->OnPurgeMemory(); |
| 540 } | 511 } |
| OLD | NEW |