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

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

Issue 12212048: Linux/ChromeOS Chromium style checker cleanup, chrome/browser edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/jankometer.h" 5 #include "chrome/browser/jankometer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 JankWatchdog(const TimeDelta& duration, 59 JankWatchdog(const TimeDelta& duration,
60 const std::string& thread_watched_name, 60 const std::string& thread_watched_name,
61 bool enabled) 61 bool enabled)
62 : Watchdog(duration, thread_watched_name, enabled), 62 : Watchdog(duration, thread_watched_name, enabled),
63 thread_name_watched_(thread_watched_name), 63 thread_name_watched_(thread_watched_name),
64 alarm_count_(0) { 64 alarm_count_(0) {
65 } 65 }
66 66
67 virtual ~JankWatchdog() {} 67 virtual ~JankWatchdog() {}
68 68
69 virtual void Alarm() { 69 virtual void Alarm() OVERRIDE {
70 // Put break point here if you want to stop threads and look at what caused 70 // Put break point here if you want to stop threads and look at what caused
71 // the jankiness. 71 // the jankiness.
72 alarm_count_++; 72 alarm_count_++;
73 Watchdog::Alarm(); 73 Watchdog::Alarm();
74 } 74 }
75 75
76 private: 76 private:
77 std::string thread_name_watched_; 77 std::string thread_name_watched_;
78 int alarm_count_; 78 int alarm_count_;
79 79
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 helper_.StartProcessingTimers(queueing_time); 250 helper_.StartProcessingTimers(queueing_time);
251 } 251 }
252 252
253 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE { 253 virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
254 helper_.EndProcessingTimers(); 254 helper_.EndProcessingTimers();
255 } 255 }
256 256
257 private: 257 private:
258 friend class base::RefCountedThreadSafe<IOJankObserver>; 258 friend class base::RefCountedThreadSafe<IOJankObserver>;
259 259
260 ~IOJankObserver() {} 260 virtual ~IOJankObserver() {}
261 261
262 JankObserverHelper helper_; 262 JankObserverHelper helper_;
263 263
264 DISALLOW_COPY_AND_ASSIGN(IOJankObserver); 264 DISALLOW_COPY_AND_ASSIGN(IOJankObserver);
265 }; 265 };
266 266
267 //------------------------------------------------------------------------------ 267 //------------------------------------------------------------------------------
268 class UIJankObserver : public base::RefCountedThreadSafe<UIJankObserver>, 268 class UIJankObserver : public base::RefCountedThreadSafe<UIJankObserver>,
269 public MessageLoop::TaskObserver, 269 public MessageLoop::TaskObserver,
270 public MessageLoopForUI::Observer { 270 public MessageLoopForUI::Observer {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 330 }
331 #elif defined(USE_AURA) 331 #elif defined(USE_AURA)
332 virtual base::EventStatus WillProcessEvent( 332 virtual base::EventStatus WillProcessEvent(
333 const base::NativeEvent& event) OVERRIDE { 333 const base::NativeEvent& event) OVERRIDE {
334 return base::EVENT_CONTINUE; 334 return base::EVENT_CONTINUE;
335 } 335 }
336 336
337 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { 337 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE {
338 } 338 }
339 #elif defined(TOOLKIT_GTK) 339 #elif defined(TOOLKIT_GTK)
340 virtual void WillProcessEvent(GdkEvent* event) { 340 virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
341 if (!helper_.MessageWillBeMeasured()) 341 if (!helper_.MessageWillBeMeasured())
342 return; 342 return;
343 // TODO(evanm): we want to set queueing_time_ using 343 // TODO(evanm): we want to set queueing_time_ using
344 // gdk_event_get_time, but how do you convert that info 344 // gdk_event_get_time, but how do you convert that info
345 // into a delta? 345 // into a delta?
346 // guint event_time = gdk_event_get_time(event); 346 // guint event_time = gdk_event_get_time(event);
347 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0); 347 base::TimeDelta queueing_time = base::TimeDelta::FromMilliseconds(0);
348 helper_.StartProcessingTimers(queueing_time); 348 helper_.StartProcessingTimers(queueing_time);
349 } 349 }
350 350
351 virtual void DidProcessEvent(GdkEvent* event) { 351 virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
352 helper_.EndProcessingTimers(); 352 helper_.EndProcessingTimers();
353 } 353 }
354 #endif 354 #endif
355 355
356 private: 356 private:
357 friend class base::RefCountedThreadSafe<UIJankObserver>; 357 friend class base::RefCountedThreadSafe<UIJankObserver>;
358 358
359 ~UIJankObserver() {} 359 virtual ~UIJankObserver() {}
360 360
361 JankObserverHelper helper_; 361 JankObserverHelper helper_;
362 362
363 DISALLOW_COPY_AND_ASSIGN(UIJankObserver); 363 DISALLOW_COPY_AND_ASSIGN(UIJankObserver);
364 }; 364 };
365 365
366 // These objects are created by InstallJankometer and leaked. 366 // These objects are created by InstallJankometer and leaked.
367 const scoped_refptr<UIJankObserver>* ui_observer = NULL; 367 const scoped_refptr<UIJankObserver>* ui_observer = NULL;
368 const scoped_refptr<IOJankObserver>* io_observer = NULL; 368 const scoped_refptr<IOJankObserver>* io_observer = NULL;
369 369
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 delete ui_observer; 416 delete ui_observer;
417 ui_observer = NULL; 417 ui_observer = NULL;
418 } 418 }
419 if (io_observer) { 419 if (io_observer) {
420 // IO thread can't be running when we remove observers. 420 // IO thread can't be running when we remove observers.
421 DCHECK((!g_browser_process) || !(g_browser_process->io_thread())); 421 DCHECK((!g_browser_process) || !(g_browser_process->io_thread()));
422 delete io_observer; 422 delete io_observer;
423 io_observer = NULL; 423 io_observer = NULL;
424 } 424 }
425 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698