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_HANDLER(ChromeViewMsg_ToggleWebKitSharedTimer, | 229 IPC_MESSAGE_HANDLER(ChromeViewMsg_ToggleWebKitSharedTimer, |
236 OnToggleWebKitSharedTimer) | 230 OnToggleWebKitSharedTimer) |
237 IPC_MESSAGE_UNHANDLED(handled = false) | 231 IPC_MESSAGE_UNHANDLED(handled = false) |
238 IPC_END_MESSAGE_MAP() | 232 IPC_END_MESSAGE_MAP() |
(...skipping 27 matching lines...) Expand all Loading... |
266 WebCache::clear(); | 260 WebCache::clear(); |
267 } | 261 } |
268 } | 262 } |
269 | 263 |
270 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { | 264 void ChromeRenderProcessObserver::OnGetCacheResourceStats() { |
271 WebCache::ResourceTypeStats stats; | 265 WebCache::ResourceTypeStats stats; |
272 WebCache::getResourceTypeStats(&stats); | 266 WebCache::getResourceTypeStats(&stats); |
273 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); | 267 RenderThread::Get()->Send(new ChromeViewHostMsg_ResourceTypeStats(stats)); |
274 } | 268 } |
275 | 269 |
276 #if defined(USE_TCMALLOC) | |
277 void ChromeRenderProcessObserver::OnSetTcmallocHeapProfiling( | |
278 bool profiling, const std::string& filename_prefix) { | |
279 #if !defined(OS_WIN) | |
280 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. | |
281 if (profiling) | |
282 HeapProfilerStart(filename_prefix.c_str()); | |
283 else | |
284 HeapProfilerStop(); | |
285 #endif | |
286 } | |
287 | |
288 void ChromeRenderProcessObserver::OnWriteTcmallocHeapProfile( | |
289 const FilePath::StringType& filename) { | |
290 #if !defined(OS_WIN) | |
291 // TODO(stevenjb): Create MallocExtension wrappers for HeapProfile functions. | |
292 if (!IsHeapProfilerRunning()) | |
293 return; | |
294 char* profile = GetHeapProfile(); | |
295 if (!profile) { | |
296 LOG(WARNING) << "Unable to get heap profile."; | |
297 return; | |
298 } | |
299 // The render process can not write to a file, so copy the result into | |
300 // a string and pass it to the handler (which runs on the browser host). | |
301 std::string result(profile); | |
302 delete profile; | |
303 RenderThread::Get()->Send( | |
304 new ChromeViewHostMsg_WriteTcmallocHeapProfile_ACK(filename, result)); | |
305 #endif | |
306 } | |
307 | |
308 #endif | |
309 | |
310 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( | 270 void ChromeRenderProcessObserver::OnSetFieldTrialGroup( |
311 const std::string& field_trial_name, | 271 const std::string& field_trial_name, |
312 const std::string& group_name) { | 272 const std::string& group_name) { |
313 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); | 273 base::FieldTrialList::CreateFieldTrial(field_trial_name, group_name); |
314 chrome_variations::SetChildProcessLoggingVariationList(); | 274 chrome_variations::SetChildProcessLoggingVariationList(); |
315 } | 275 } |
316 | 276 |
317 void ChromeRenderProcessObserver::OnGetV8HeapStats() { | 277 void ChromeRenderProcessObserver::OnGetV8HeapStats() { |
318 v8::HeapStatistics heap_stats; | 278 v8::HeapStatistics heap_stats; |
319 v8::V8::GetHeapStatistics(&heap_stats); | 279 v8::V8::GetHeapStatistics(&heap_stats); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 if (clear_cache_pending_) { | 316 if (clear_cache_pending_) { |
357 clear_cache_pending_ = false; | 317 clear_cache_pending_ = false; |
358 WebCache::clear(); | 318 WebCache::clear(); |
359 } | 319 } |
360 } | 320 } |
361 | 321 |
362 const RendererContentSettingRules* | 322 const RendererContentSettingRules* |
363 ChromeRenderProcessObserver::content_setting_rules() const { | 323 ChromeRenderProcessObserver::content_setting_rules() const { |
364 return &content_setting_rules_; | 324 return &content_setting_rules_; |
365 } | 325 } |
OLD | NEW |