| 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 #if defined(OS_MACOSX) | 5 #if defined(OS_MACOSX) |
| 6 #include <signal.h> | 6 #include <signal.h> |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 #endif // OS_MACOSX | 8 #endif // OS_MACOSX |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 *bad_pointer = 0; | 171 *bad_pointer = 0; |
| 172 } | 172 } |
| 173 | 173 |
| 174 if (command_line.HasSwitch(switches::kRendererStartupDialog)) { | 174 if (command_line.HasSwitch(switches::kRendererStartupDialog)) { |
| 175 ChildProcess::WaitForDebugger("Renderer"); | 175 ChildProcess::WaitForDebugger("Renderer"); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 // This is a simplified version of the browser Jankometer, which measures | 179 // This is a simplified version of the browser Jankometer, which measures |
| 180 // the processing time of tasks on the render thread. | 180 // the processing time of tasks on the render thread. |
| 181 class RendererMessageLoopObserver : public MessageLoop::TaskObserver { | 181 class RendererMessageLoopObserver : public MessageLoop::ClosureObserver { |
| 182 public: | 182 public: |
| 183 RendererMessageLoopObserver() | 183 RendererMessageLoopObserver() |
| 184 : process_times_(base::Histogram::FactoryGet( | 184 : process_times_(base::Histogram::FactoryGet( |
| 185 "Chrome.ProcMsgL RenderThread", | 185 "Chrome.ProcMsgL RenderThread", |
| 186 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)) {} | 186 1, 3600000, 50, base::Histogram::kUmaTargetedHistogramFlag)) {} |
| 187 virtual ~RendererMessageLoopObserver() {} | 187 virtual ~RendererMessageLoopObserver() {} |
| 188 | 188 |
| 189 virtual void WillProcessTask(const Task* task) { | 189 virtual void WillProcessClosure(base::TimeTicks time_posted) { |
| 190 begin_process_message_ = base::TimeTicks::Now(); | 190 begin_process_message_ = base::TimeTicks::Now(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 virtual void DidProcessTask(const Task* task) { | 193 virtual void DidProcessClosure(base::TimeTicks time_posted) { |
| 194 if (begin_process_message_ != base::TimeTicks()) | 194 if (begin_process_message_ != base::TimeTicks()) |
| 195 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_); | 195 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_); |
| 196 } | 196 } |
| 197 | 197 |
| 198 private: | 198 private: |
| 199 base::TimeTicks begin_process_message_; | 199 base::TimeTicks begin_process_message_; |
| 200 base::Histogram* const process_times_; | 200 base::Histogram* const process_times_; |
| 201 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); | 201 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); |
| 202 }; | 202 }; |
| 203 | 203 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // flag allowing us to attach a debugger. | 252 // flag allowing us to attach a debugger. |
| 253 // Do not move this function down since that would mean we can't easily debug | 253 // Do not move this function down since that would mean we can't easily debug |
| 254 // whatever occurs before it. | 254 // whatever occurs before it. |
| 255 HandleRendererErrorTestParameters(parsed_command_line); | 255 HandleRendererErrorTestParameters(parsed_command_line); |
| 256 | 256 |
| 257 RendererMainPlatformDelegate platform(parameters); | 257 RendererMainPlatformDelegate platform(parameters); |
| 258 | 258 |
| 259 base::StatsScope<base::StatsCounterTimer> | 259 base::StatsScope<base::StatsCounterTimer> |
| 260 startup_timer(chrome::Counters::renderer_main()); | 260 startup_timer(chrome::Counters::renderer_main()); |
| 261 | 261 |
| 262 RendererMessageLoopObserver task_observer; | 262 RendererMessageLoopObserver closure_observer; |
| 263 #if defined(OS_MACOSX) | 263 #if defined(OS_MACOSX) |
| 264 // As long as we use Cocoa in the renderer (for the forseeable future as of | 264 // As long as we use Cocoa in the renderer (for the forseeable future as of |
| 265 // now; see http://crbug.com/13890 for info) we need to have a UI loop. | 265 // now; see http://crbug.com/13890 for info) we need to have a UI loop. |
| 266 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | 266 MessageLoop main_message_loop(MessageLoop::TYPE_UI); |
| 267 #else | 267 #else |
| 268 // The main message loop of the renderer services doesn't have IO or UI tasks, | 268 // The main message loop of the renderer services doesn't have IO or UI tasks, |
| 269 // unless in-process-plugins is used. | 269 // unless in-process-plugins is used. |
| 270 MessageLoop main_message_loop(RenderProcessImpl::InProcessPlugins() ? | 270 MessageLoop main_message_loop(RenderProcessImpl::InProcessPlugins() ? |
| 271 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT); | 271 MessageLoop::TYPE_UI : MessageLoop::TYPE_DEFAULT); |
| 272 #endif | 272 #endif |
| 273 main_message_loop.AddTaskObserver(&task_observer); | 273 main_message_loop.AddClosureObserver(&closure_observer); |
| 274 | 274 |
| 275 base::PlatformThread::SetName("CrRendererMain"); | 275 base::PlatformThread::SetName("CrRendererMain"); |
| 276 | 276 |
| 277 ui::SystemMonitor system_monitor; | 277 ui::SystemMonitor system_monitor; |
| 278 HighResolutionTimerManager hi_res_timer_manager; | 278 HighResolutionTimerManager hi_res_timer_manager; |
| 279 | 279 |
| 280 platform.PlatformInitialize(); | 280 platform.PlatformInitialize(); |
| 281 | 281 |
| 282 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 282 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
| 283 platform.InitSandboxTests(no_sandbox); | 283 platform.InitSandboxTests(no_sandbox); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 pool->Recycle(); | 329 pool->Recycle(); |
| 330 TRACE_EVENT_BEGIN("RendererMain.START_MSG_LOOP", 0, 0); | 330 TRACE_EVENT_BEGIN("RendererMain.START_MSG_LOOP", 0, 0); |
| 331 MessageLoop::current()->Run(); | 331 MessageLoop::current()->Run(); |
| 332 TRACE_EVENT_END("RendererMain.START_MSG_LOOP", 0, 0); | 332 TRACE_EVENT_END("RendererMain.START_MSG_LOOP", 0, 0); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 platform.PlatformUninitialize(); | 335 platform.PlatformUninitialize(); |
| 336 TRACE_EVENT_END("RendererMain", 0, ""); | 336 TRACE_EVENT_END("RendererMain", 0, ""); |
| 337 return 0; | 337 return 0; |
| 338 } | 338 } |
| OLD | NEW |