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

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

Issue 4081003: Added task to Observer methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made default birthplace a local static Created 10 years, 1 month 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/tracked.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 virtual void WillProcessIOEvent() { 201 virtual void WillProcessIOEvent() {
202 helper_.StartProcessingTimers(base::TimeDelta()); 202 helper_.StartProcessingTimers(base::TimeDelta());
203 } 203 }
204 204
205 virtual void DidProcessIOEvent() { 205 virtual void DidProcessIOEvent() {
206 helper_.EndProcessingTimers(); 206 helper_.EndProcessingTimers();
207 } 207 }
208 208
209 virtual void WillProcessTask(base::TimeTicks birth_time) { 209 virtual void WillProcessTask(const Task* task) {
210 base::TimeTicks now = base::TimeTicks::Now(); 210 base::TimeTicks now = base::TimeTicks::Now();
211 const base::TimeDelta queueing_time = now - birth_time; 211 const base::TimeDelta queueing_time = now - task->tracked_birth_time();
212 helper_.StartProcessingTimers(queueing_time); 212 helper_.StartProcessingTimers(queueing_time);
213 } 213 }
214 214
215 virtual void DidProcessTask() { 215 virtual void DidProcessTask(const Task* task) {
216 helper_.EndProcessingTimers(); 216 helper_.EndProcessingTimers();
217 } 217 }
218 218
219 private: 219 private:
220 friend class base::RefCountedThreadSafe<IOJankObserver>; 220 friend class base::RefCountedThreadSafe<IOJankObserver>;
221 221
222 JankObserverHelper helper_; 222 JankObserverHelper helper_;
223 223
224 DISALLOW_COPY_AND_ASSIGN(IOJankObserver); 224 DISALLOW_COPY_AND_ASSIGN(IOJankObserver);
225 }; 225 };
(...skipping 17 matching lines...) Expand all
243 MessageLoop::current()->AddTaskObserver(this); 243 MessageLoop::current()->AddTaskObserver(this);
244 } 244 }
245 245
246 // Detaches the observer to the current thread's message loop. 246 // Detaches the observer to the current thread's message loop.
247 void DetachFromCurrentThread() { 247 void DetachFromCurrentThread() {
248 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); 248 DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
249 MessageLoop::current()->RemoveTaskObserver(this); 249 MessageLoop::current()->RemoveTaskObserver(this);
250 MessageLoopForUI::current()->RemoveObserver(this); 250 MessageLoopForUI::current()->RemoveObserver(this);
251 } 251 }
252 252
253 virtual void WillProcessTask(base::TimeTicks birth_time) { 253 virtual void WillProcessTask(const Task* task) {
254 base::TimeTicks now = base::TimeTicks::Now(); 254 base::TimeTicks now = base::TimeTicks::Now();
255 const base::TimeDelta queueing_time = now - birth_time; 255 const base::TimeDelta queueing_time = now - task->tracked_birth_time();
256 helper_.StartProcessingTimers(queueing_time); 256 helper_.StartProcessingTimers(queueing_time);
257 } 257 }
258 258
259 virtual void DidProcessTask() { 259 virtual void DidProcessTask(const Task* task) {
260 helper_.EndProcessingTimers(); 260 helper_.EndProcessingTimers();
261 } 261 }
262 262
263 #if defined(OS_WIN) 263 #if defined(OS_WIN)
264 virtual void WillProcessMessage(const MSG& msg) { 264 virtual void WillProcessMessage(const MSG& msg) {
265 // GetMessageTime returns a LONG (signed 32-bit) and GetTickCount returns 265 // GetMessageTime returns a LONG (signed 32-bit) and GetTickCount returns
266 // a DWORD (unsigned 32-bit). They both wrap around when the time is longer 266 // a DWORD (unsigned 32-bit). They both wrap around when the time is longer
267 // than they can hold. I'm not sure if GetMessageTime wraps around to 0, 267 // than they can hold. I'm not sure if GetMessageTime wraps around to 0,
268 // or if the original time comes from GetTickCount, it might wrap around 268 // or if the original time comes from GetTickCount, it might wrap around
269 // to -1. 269 // to -1.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 delete ui_observer; 358 delete ui_observer;
359 ui_observer = NULL; 359 ui_observer = NULL;
360 } 360 }
361 if (io_observer) { 361 if (io_observer) {
362 // IO thread can't be running when we remove observers. 362 // IO thread can't be running when we remove observers.
363 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); 363 DCHECK((!g_browser_process) || !(g_browser_process->io_thread()));
364 delete io_observer; 364 delete io_observer;
365 io_observer = NULL; 365 io_observer = NULL;
366 } 366 }
367 } 367 }
OLDNEW
« no previous file with comments | « base/tracked.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698