| 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/renderer/chrome_render_process_observer.h" | 5 #include "chrome/renderer/chrome_render_process_observer.h" |
| 6 | 6 |
| 7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 bool ChromeRenderProcessObserver::OnControlMessageReceived( | 214 bool ChromeRenderProcessObserver::OnControlMessageReceived( |
| 215 const IPC::Message& message) { | 215 const IPC::Message& message) { |
| 216 bool handled = true; | 216 bool handled = true; |
| 217 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) | 217 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) |
| 218 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, | 218 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, |
| 219 OnSetIsIncognitoProcess) | 219 OnSetIsIncognitoProcess) |
| 220 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 220 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
| 221 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) | 221 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) |
| 222 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) | 222 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) |
| 223 #if defined(USE_TCMALLOC) | |
| 224 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, | |
| 225 OnSetTcmallocHeapProfiling) | |
| 226 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, | |
| 227 OnWriteTcmallocHeapProfile) | |
| 228 #endif | |
| 229 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats) | 223 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats) |
| 230 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats, | 224 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats, |
| 231 OnGetCacheResourceStats) | 225 OnGetCacheResourceStats) |
| 232 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory) | 226 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory) |
| 233 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, | 227 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, |
| 234 OnSetContentSettingRules) | 228 OnSetContentSettingRules) |
| 235 IPC_MESSAGE_UNHANDLED(handled = false) | 229 IPC_MESSAGE_UNHANDLED(handled = false) |
| 236 IPC_END_MESSAGE_MAP() | 230 IPC_END_MESSAGE_MAP() |
| 237 return handled; | 231 return handled; |
| 238 } | 232 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 264 WebCache::clear(); | 258 WebCache::clear(); |
| 265 } | 259 } |
| 266 } | 260 } |
| 267 | 261 |
| 268 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { | 262 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { |
| 269 WebCache::ResourceTypeStats stats; | 263 WebCache::ResourceTypeStats stats; |
| 270 WebCache::getResourceTypeStats(&stats); | 264 WebCache::getResourceTypeStats(&stats); |
| 271 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); | 265 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); |
| 272 } | 266 } |
| 273 | 267 |
| 274 #if defined(USE_TCMALLOC) | |
| 275 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( | |
| 276 bool profiling, const std::string& filename_prefix) { | |
| 277 #if !defined(OS_WIN) | |
| 278 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. | |
| 279 if (profiling) | |
| 280 HeapProfilerStart(filename_prefix.c_str()); | |
| 281 else | |
| 282 HeapProfilerStop(); | |
| 283 #endif | |
| 284 } | |
| 285 | |
| 286 void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile( | |
| 287 const FilePath::StringType& filename) { | |
| 288 #if !defined(OS_WIN) | |
| 289 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. | |
| 290 if (!IsHeapProfilerRunning()) | |
| 291 return; | |
| 292 char* profile = GetHeapProfile(); | |
| 293 if (!profile) { | |
| 294 LOG(WARNING) << "Unable to get heap profile."; | |
| 295 return; | |
| 296 } | |
| 297 // The render process can not write to a file, so copy the result into | |
| 298 // a string and pass it to the handler (which runs on the browser host). | |
| 299 std::string result(profile); | |
| 300 delete profile; | |
| 301 RenderThread::Get()->Send( | |
| 302 new ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result)); | |
| 303 #endif | |
| 304 } | |
| 305 | |
| 306 #endif | |
| 307 | |
| 308 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( | 268 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( |
| 309 const std::string& field_trial_name, | 269 const std::string& field_trial_name, |
| 310 const std::string& group_name) { | 270 const std::string& group_name) { |
| 311 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); | 271 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); |
| 312 experiments_helper::SetChildProcessLoggingExperimentList(); | 272 experiments_helper::SetChildProcessLoggingExperimentList(); |
| 313 } | 273 } |
| 314 | 274 |
| 315 void ChromeRenderProcessObserver::OnGetV8HeapStats() { | 275 void ChromeRenderProcessObserver::OnGetV8HeapStats() { |
| 316 v8::HeapStatistics heap_stats; | 276 v8::HeapStatistics heap_stats; |
| 317 v8::V8::GetHeapStatistics(&heap_stats); | 277 v8::V8::GetHeapStatistics(&heap_stats); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 if (clear_cache_pending_) { | 310 if (clear_cache_pending_) { |
| 351 clear_cache_pending_ = false; | 311 clear_cache_pending_ = false; |
| 352 WebCache::clear(); | 312 WebCache::clear(); |
| 353 } | 313 } |
| 354 } | 314 } |
| 355 | 315 |
| 356 const RendererContentSettingRules* | 316 const RendererContentSettingRules* |
| 357 ChromeRenderProcessObserver::content_setting_rules() const { | 317 ChromeRenderProcessObserver::content_setting_rules() const { |
| 358 return &content_setting_rules_; | 318 return &content_setting_rules_; |
| 359 } | 319 } |
| OLD | NEW |