| 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "chrome/browser/jankometer.h" | 7 #include "chrome/browser/jankometer.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 base::TimeTicks now = base::TimeTicks::Now(); | 297 base::TimeTicks now = base::TimeTicks::Now(); |
| 298 const base::TimeDelta queueing_time = now - time_posted; | 298 const base::TimeDelta queueing_time = now - time_posted; |
| 299 helper_.StartProcessingTimers(queueing_time); | 299 helper_.StartProcessingTimers(queueing_time); |
| 300 } | 300 } |
| 301 | 301 |
| 302 virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE { | 302 virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE { |
| 303 helper_.EndProcessingTimers(); | 303 helper_.EndProcessingTimers(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 #if defined(OS_WIN) | 306 #if defined(OS_WIN) |
| 307 virtual void WillProcessMessage(const MSG& msg) { | 307 virtual base::EventStatus WillProcessEvent( |
| 308 const base::NativeEvent& event) OVERRIDE { |
| 308 if (!helper_.MessageWillBeMeasured()) | 309 if (!helper_.MessageWillBeMeasured()) |
| 309 return; | 310 return base::EVENT_CONTINUE; |
| 310 // GetMessageTime returns a LONG (signed 32-bit) and GetTickCount returns | 311 // GetMessageTime returns a LONG (signed 32-bit) and GetTickCount returns |
| 311 // a DWORD (unsigned 32-bit). They both wrap around when the time is longer | 312 // a DWORD (unsigned 32-bit). They both wrap around when the time is longer |
| 312 // than they can hold. I'm not sure if GetMessageTime wraps around to 0, | 313 // than they can hold. I'm not sure if GetMessageTime wraps around to 0, |
| 313 // or if the original time comes from GetTickCount, it might wrap around | 314 // or if the original time comes from GetTickCount, it might wrap around |
| 314 // to -1. | 315 // to -1. |
| 315 // | 316 // |
| 316 // Therefore, I cast to DWORD so if it wraps to -1 we will correct it. If | 317 // Therefore, I cast to DWORD so if it wraps to -1 we will correct it. If |
| 317 // it doesn't, then our time delta will be negative if a message happens | 318 // it doesn't, then our time delta will be negative if a message happens |
| 318 // to straddle the wraparound point, it will still be OK. | 319 // to straddle the wraparound point, it will still be OK. |
| 319 DWORD cur_message_issue_time = static_cast<DWORD>(msg.time); | 320 DWORD cur_message_issue_time = static_cast<DWORD>(event.time); |
| 320 DWORD cur_time = GetTickCount(); | 321 DWORD cur_time = GetTickCount(); |
| 321 base::TimeDelta queueing_time = | 322 base::TimeDelta queueing_time = |
| 322 base::TimeDelta::FromMilliseconds(cur_time - cur_message_issue_time); | 323 base::TimeDelta::FromMilliseconds(cur_time - cur_message_issue_time); |
| 323 | 324 |
| 324 helper_.StartProcessingTimers(queueing_time); | 325 helper_.StartProcessingTimers(queueing_time); |
| 326 return base::EVENT_CONTINUE; |
| 325 } | 327 } |
| 326 | 328 |
| 327 virtual void DidProcessMessage(const MSG& msg) { | 329 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
| 328 helper_.EndProcessingTimers(); | 330 helper_.EndProcessingTimers(); |
| 329 } | 331 } |
| 332 #elif defined(TOUCH_UI) || defined(USE_AURA) |
| 333 virtual base::EventStatus WillProcessEvent( |
| 334 const base::NativeEvent& event) OVERRIDE { |
| 335 return base::EVENT_CONTINUE; |
| 336 } |
| 337 |
| 338 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
| 339 } |
| 330 #elif defined(TOOLKIT_USES_GTK) | 340 #elif defined(TOOLKIT_USES_GTK) |
| 331 virtual void WillProcessEvent(GdkEvent* event) { | 341 virtual void WillProcessEvent(GdkEvent* event) { |
| 332 if (!helper_.MessageWillBeMeasured()) | 342 if (!helper_.MessageWillBeMeasured()) |
| 333 return; | 343 return; |
| 334 // TODO(evanm): we want to set queueing_time_ using | 344 // TODO(evanm): we want to set queueing_time_ using |
| 335 // gdk_event_get_time, but how do you convert that info | 345 // gdk_event_get_time, but how do you convert that info |
| 336 // into a delta? | 346 // into a delta? |
| 337 // guint event_time = gdk_event_get_time(event); | 347 // guint event_time = gdk_event_get_time(event); |
| 338 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0); | 348 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0); |
| 339 helper_.StartProcessingTimers(queueing_time); | 349 helper_.StartProcessingTimers(queueing_time); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 delete ui_observer; | 418 delete ui_observer; |
| 409 ui_observer = NULL; | 419 ui_observer = NULL; |
| 410 } | 420 } |
| 411 if (io_observer) { | 421 if (io_observer) { |
| 412 // IO thread can't be running when we remove observers. | 422 // IO thread can't be running when we remove observers. |
| 413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); | 423 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); |
| 414 delete io_observer; | 424 delete io_observer; |
| 415 io_observer = NULL; | 425 io_observer = NULL; |
| 416 } | 426 } |
| 417 } | 427 } |
| OLD | NEW |