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

Side by Side Diff: base/message_loop.cc

Issue 515033: Cleanup histogram classes mixing SetFlags into FactoryGet arguments... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 12 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/histogram_unittest.cc ('k') | chrome/browser/chrome_browser_application_mac.mm » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 const tracked_objects::Location& from_here, Task* task, int64 delay_ms, 258 const tracked_objects::Location& from_here, Task* task, int64 delay_ms,
259 bool nestable) { 259 bool nestable) {
260 task->SetBirthPlace(from_here); 260 task->SetBirthPlace(from_here);
261 261
262 PendingTask pending_task(task, nestable); 262 PendingTask pending_task(task, nestable);
263 263
264 if (delay_ms > 0) { 264 if (delay_ms > 0) {
265 pending_task.delayed_run_time = 265 pending_task.delayed_run_time =
266 Time::Now() + TimeDelta::FromMilliseconds(delay_ms); 266 Time::Now() + TimeDelta::FromMilliseconds(delay_ms);
267 } else { 267 } else {
268 DCHECK(delay_ms == 0) << "delay should not be negative"; 268 DCHECK_EQ(delay_ms, 0) << "delay should not be negative";
269 } 269 }
270 270
271 // Warning: Don't try to short-circuit, and handle this thread's tasks more 271 // Warning: Don't try to short-circuit, and handle this thread's tasks more
272 // directly, as it could starve handling of foreign threads. Put every task 272 // directly, as it could starve handling of foreign threads. Put every task
273 // into this queue. 273 // into this queue.
274 274
275 scoped_refptr<base::MessagePump> pump; 275 scoped_refptr<base::MessagePump> pump;
276 { 276 {
277 AutoLock locked(incoming_queue_lock_); 277 AutoLock locked(incoming_queue_lock_);
278 278
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 524
525 // static 525 // static
526 void MessageLoop::EnableHistogrammer(bool enable) { 526 void MessageLoop::EnableHistogrammer(bool enable) {
527 enable_histogrammer_ = enable; 527 enable_histogrammer_ = enable;
528 } 528 }
529 529
530 void MessageLoop::StartHistogrammer() { 530 void MessageLoop::StartHistogrammer() {
531 if (enable_histogrammer_ && !message_histogram_.get() 531 if (enable_histogrammer_ && !message_histogram_.get()
532 && StatisticsRecorder::WasStarted()) { 532 && StatisticsRecorder::WasStarted()) {
533 DCHECK(!thread_name_.empty()); 533 DCHECK(!thread_name_.empty());
534 message_histogram_ = 534 message_histogram_ = LinearHistogram::FactoryGet("MsgLoop:" + thread_name_,
535 LinearHistogram::LinearHistogramFactoryGet( 535 kLeastNonZeroMessageId, kMaxMessageId,
536 ("MsgLoop:" + thread_name_), 536 kNumberOfDistinctMessagesDisplayed,
537 kLeastNonZeroMessageId, 537 message_histogram_->kHexRangePrintingFlag);
538 kMaxMessageId,
539 kNumberOfDistinctMessagesDisplayed);
540 message_histogram_->SetFlags(message_histogram_->kHexRangePrintingFlag);
541 message_histogram_->SetRangeDescriptions(event_descriptions_); 538 message_histogram_->SetRangeDescriptions(event_descriptions_);
542 } 539 }
543 } 540 }
544 541
545 void MessageLoop::HistogramEvent(int event) { 542 void MessageLoop::HistogramEvent(int event) {
546 if (message_histogram_.get()) 543 if (message_histogram_.get())
547 message_histogram_->Add(event); 544 message_histogram_->Add(event);
548 } 545 }
549 546
550 // Provide a macro that takes an expression (such as a constant, or macro 547 // Provide a macro that takes an expression (such as a constant, or macro
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 Watcher *delegate) { 626 Watcher *delegate) {
630 return pump_libevent()->WatchFileDescriptor( 627 return pump_libevent()->WatchFileDescriptor(
631 fd, 628 fd,
632 persistent, 629 persistent,
633 static_cast<base::MessagePumpLibevent::Mode>(mode), 630 static_cast<base::MessagePumpLibevent::Mode>(mode),
634 controller, 631 controller,
635 delegate); 632 delegate);
636 } 633 }
637 634
638 #endif 635 #endif
OLDNEW
« no previous file with comments | « base/histogram_unittest.cc ('k') | chrome/browser/chrome_browser_application_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698