| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 bool ChromeRenderProcessObserver::OnControlMessageReceived( | 207 bool ChromeRenderProcessObserver::OnControlMessageReceived( |
| 208 const IPC::Message& message) { | 208 const IPC::Message& message) { |
| 209 bool handled = true; | 209 bool handled = true; |
| 210 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) | 210 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) |
| 211 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, | 211 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, |
| 212 OnSetIsIncognitoProcess) | 212 OnSetIsIncognitoProcess) |
| 213 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 213 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
| 214 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) | 214 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) |
| 215 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) | 215 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) |
| 216 #if defined(USE_TCMALLOC) | 216 #if defined(USE_TCMALLOC) |
| 217 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererTcmalloc, | |
| 218 OnGetRendererTcmalloc) | |
| 219 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, | 217 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, |
| 220 OnSetTcmallocHeapProfiling) | 218 OnSetTcmallocHeapProfiling) |
| 221 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, | 219 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, |
| 222 OnWriteTcmallocHeapProfile) | 220 OnWriteTcmallocHeapProfile) |
| 223 #endif | 221 #endif |
| 224 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats) | 222 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats) |
| 225 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats, | 223 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats, |
| 226 OnGetCacheResourceStats) | 224 OnGetCacheResourceStats) |
| 227 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory) | 225 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory) |
| 228 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, | 226 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 257 } | 255 } |
| 258 } | 256 } |
| 259 | 257 |
| 260 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { | 258 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { |
| 261 WebCache::ResourceTypeStats stats; | 259 WebCache::ResourceTypeStats stats; |
| 262 WebCache::getResourceTypeStats(&stats); | 260 WebCache::getResourceTypeStats(&stats); |
| 263 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); | 261 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); |
| 264 } | 262 } |
| 265 | 263 |
| 266 #if defined(USE_TCMALLOC) | 264 #if defined(USE_TCMALLOC) |
| 267 void ChromeRenderProcessObserver::OnGetRendererTcmalloc() { | |
| 268 std::string result; | |
| 269 char buffer[1024 * 32]; | |
| 270 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | |
| 271 result.append(buffer); | |
| 272 RenderThread::Get()->Send(new ChromeViewHostMsg_RendererTcmalloc(result)); | |
| 273 } | |
| 274 | |
| 275 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( | 265 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( |
| 276 bool profiling, const std::string& filename_prefix) { | 266 bool profiling, const std::string& filename_prefix) { |
| 277 #if !defined(OS_WIN) | 267 #if !defined(OS_WIN) |
| 278 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. | 268 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. |
| 279 if (profiling) | 269 if (profiling) |
| 280 HeapProfilerStart(filename_prefix.c_str()); | 270 HeapProfilerStart(filename_prefix.c_str()); |
| 281 else | 271 else |
| 282 HeapProfilerStop(); | 272 HeapProfilerStop(); |
| 283 #endif | 273 #endif |
| 284 } | 274 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 if (clear_cache_pending_) { | 342 if (clear_cache_pending_) { |
| 353 clear_cache_pending_ = false; | 343 clear_cache_pending_ = false; |
| 354 WebCache::clear(); | 344 WebCache::clear(); |
| 355 } | 345 } |
| 356 } | 346 } |
| 357 | 347 |
| 358 const RendererContentSettingRules* | 348 const RendererContentSettingRules* |
| 359 ChromeRenderProcessObserver::content_setting_rules() const { | 349 ChromeRenderProcessObserver::content_setting_rules() const { |
| 360 return &content_setting_rules_; | 350 return &content_setting_rules_; |
| 361 } | 351 } |
| OLD | NEW |