| 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(const MSG& msg) OVERRIDE { |
| 308 if (!helper_.MessageWillBeMeasured()) | 308 if (!helper_.MessageWillBeMeasured()) |
| 309 return; | 309 return base::EVENT_CONTINUE; |
| 310 // GetMessageTime returns a LONG (signed 32-bit) and GetTickCount returns | 310 // 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 | 311 // 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, | 312 // 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 | 313 // or if the original time comes from GetTickCount, it might wrap around |
| 314 // to -1. | 314 // to -1. |
| 315 // | 315 // |
| 316 // Therefore, I cast to DWORD so if it wraps to -1 we will correct it. If | 316 // 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 | 317 // 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. | 318 // to straddle the wraparound point, it will still be OK. |
| 319 DWORD cur_message_issue_time = static_cast<DWORD>(msg.time); | 319 DWORD cur_message_issue_time = static_cast<DWORD>(msg.time); |
| 320 DWORD cur_time = GetTickCount(); | 320 DWORD cur_time = GetTickCount(); |
| 321 base::TimeDelta queueing_time = | 321 base::TimeDelta queueing_time = |
| 322 base::TimeDelta::FromMilliseconds(cur_time - cur_message_issue_time); | 322 base::TimeDelta::FromMilliseconds(cur_time - cur_message_issue_time); |
| 323 | 323 |
| 324 helper_.StartProcessingTimers(queueing_time); | 324 helper_.StartProcessingTimers(queueing_time); |
| 325 return base::EVENT_CONTINUE; |
| 325 } | 326 } |
| 326 | 327 |
| 327 virtual void DidProcessMessage(const MSG& msg) { | 328 virtual void DidProcessEvent(const MSG& msg) OVERRIDE { |
| 328 helper_.EndProcessingTimers(); | 329 helper_.EndProcessingTimers(); |
| 329 } | 330 } |
| 331 #elif defined(TOUCH_UI) || defined(USE_AURA) |
| 332 virtual base::EventStatus WillProcessEvent( |
| 333 const base::NativeEvent& event) OVERRIDE { |
| 334 return base::EVENT_CONTINUE; |
| 335 } |
| 336 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { |
| 337 } |
| 330 #elif defined(TOOLKIT_USES_GTK) | 338 #elif defined(TOOLKIT_USES_GTK) |
| 331 virtual void WillProcessEvent(GdkEvent* event) { | 339 virtual void WillProcessEvent(GdkEvent* event) { |
| 332 if (!helper_.MessageWillBeMeasured()) | 340 if (!helper_.MessageWillBeMeasured()) |
| 333 return; | 341 return; |
| 334 // TODO(evanm): we want to set queueing_time_ using | 342 // TODO(evanm): we want to set queueing_time_ using |
| 335 // gdk_event_get_time, but how do you convert that info | 343 // gdk_event_get_time, but how do you convert that info |
| 336 // into a delta? | 344 // into a delta? |
| 337 // guint event_time = gdk_event_get_time(event); | 345 // guint event_time = gdk_event_get_time(event); |
| 338 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0); | 346 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0); |
| 339 helper_.StartProcessingTimers(queueing_time); | 347 helper_.StartProcessingTimers(queueing_time); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 delete ui_observer; | 416 delete ui_observer; |
| 409 ui_observer = NULL; | 417 ui_observer = NULL; |
| 410 } | 418 } |
| 411 if (io_observer) { | 419 if (io_observer) { |
| 412 // IO thread can't be running when we remove observers. | 420 // IO thread can't be running when we remove observers. |
| 413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); | 421 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); |
| 414 delete io_observer; | 422 delete io_observer; |
| 415 io_observer = NULL; | 423 io_observer = NULL; |
| 416 } | 424 } |
| 417 } | 425 } |
| OLD | NEW |