Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: chrome/browser/jankometer.cc

Issue 6463013: Add support for base::Closure in the MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: rebased Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/message_loop_unittest.cc ('k') | content/gpu/gpu_watchdog_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 MessageLoop::current()->AddTaskObserver(this); 228 MessageLoop::current()->AddTaskObserver(this);
229 MessageLoopForIO::current()->AddIOObserver(this); 229 MessageLoopForIO::current()->AddIOObserver(this);
230 } 230 }
231 231
232 // Detaches the observer to the current thread's message loop. 232 // Detaches the observer to the current thread's message loop.
233 void DetachFromCurrentThread() { 233 void DetachFromCurrentThread() {
234 MessageLoopForIO::current()->RemoveIOObserver(this); 234 MessageLoopForIO::current()->RemoveIOObserver(this);
235 MessageLoop::current()->RemoveTaskObserver(this); 235 MessageLoop::current()->RemoveTaskObserver(this);
236 } 236 }
237 237
238 virtual void WillProcessIOEvent() { 238 virtual void WillProcessIOEvent() OVERRIDE {
239 if (!helper_.MessageWillBeMeasured()) 239 if (!helper_.MessageWillBeMeasured())
240 return; 240 return;
241 helper_.StartProcessingTimers(base::TimeDelta()); 241 helper_.StartProcessingTimers(base::TimeDelta());
242 } 242 }
243 243
244 virtual void DidProcessIOEvent() { 244 virtual void DidProcessIOEvent() OVERRIDE {
245 helper_.EndProcessingTimers(); 245 helper_.EndProcessingTimers();
246 } 246 }
247 247
248 virtual void WillProcessTask(const Task* task) { 248 virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {
249 if (!helper_.MessageWillBeMeasured()) 249 if (!helper_.MessageWillBeMeasured())
250 return; 250 return;
251 base::TimeTicks now = base::TimeTicks::Now(); 251 base::TimeTicks now = base::TimeTicks::Now();
252 const base::TimeDelta queueing_time = now - task->tracked_birth_time(); 252 const base::TimeDelta queueing_time = now - time_posted;
253 helper_.StartProcessingTimers(queueing_time); 253 helper_.StartProcessingTimers(queueing_time);
254 } 254 }
255 255
256 virtual void DidProcessTask(const Task* task) { 256 virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE {
257 helper_.EndProcessingTimers(); 257 helper_.EndProcessingTimers();
258 } 258 }
259 259
260 private: 260 private:
261 friend class base::RefCountedThreadSafe<IOJankObserver>; 261 friend class base::RefCountedThreadSafe<IOJankObserver>;
262 262
263 JankObserverHelper helper_; 263 JankObserverHelper helper_;
264 264
265 DISALLOW_COPY_AND_ASSIGN(IOJankObserver); 265 DISALLOW_COPY_AND_ASSIGN(IOJankObserver);
266 }; 266 };
(...skipping 17 matching lines...) Expand all
284 MessageLoop::current()->AddTaskObserver(this); 284 MessageLoop::current()->AddTaskObserver(this);
285 } 285 }
286 286
287 // Detaches the observer to the current thread's message loop. 287 // Detaches the observer to the current thread's message loop.
288 void DetachFromCurrentThread() { 288 void DetachFromCurrentThread() {
289 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); 289 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
290 MessageLoop::current()->RemoveTaskObserver(this); 290 MessageLoop::current()->RemoveTaskObserver(this);
291 MessageLoopForUI::current()->RemoveObserver(this); 291 MessageLoopForUI::current()->RemoveObserver(this);
292 } 292 }
293 293
294 virtual void WillProcessTask(const Task* task) { 294 virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {
295 if (!helper_.MessageWillBeMeasured()) 295 if (!helper_.MessageWillBeMeasured())
296 return; 296 return;
297 base::TimeTicks now = base::TimeTicks::Now(); 297 base::TimeTicks now = base::TimeTicks::Now();
298 const base::TimeDelta queueing_time = now - task->tracked_birth_time(); 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(const Task* task) { 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 void WillProcessMessage(const MSG& msg) {
308 if (!helper_.MessageWillBeMeasured()) 308 if (!helper_.MessageWillBeMeasured())
309 return; 309 return;
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,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 delete ui_observer; 408 delete ui_observer;
409 ui_observer = NULL; 409 ui_observer = NULL;
410 } 410 }
411 if (io_observer) { 411 if (io_observer) {
412 // IO thread can't be running when we remove observers. 412 // IO thread can't be running when we remove observers.
413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); 413 DCHECK((!g_browser_process) || !(g_browser_process->io_thread()));
414 delete io_observer; 414 delete io_observer;
415 io_observer = NULL; 415 io_observer = NULL;
416 } 416 }
417 } 417 }
OLDNEW
« no previous file with comments | « base/message_loop_unittest.cc ('k') | content/gpu/gpu_watchdog_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698