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

Side by Side Diff: base/message_loop/message_loop.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_pump_perftest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 VALUE_TO_NUMBER_AND_NAME(kTimerEvent) 79 VALUE_TO_NUMBER_AND_NAME(kTimerEvent)
80 80
81 {-1, NULL} // The list must be null terminated, per API to histogram. 81 {-1, NULL} // The list must be null terminated, per API to histogram.
82 }; 82 };
83 #endif // !defined(OS_NACL) 83 #endif // !defined(OS_NACL)
84 84
85 bool enable_histogrammer_ = false; 85 bool enable_histogrammer_ = false;
86 86
87 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL; 87 MessageLoop::MessagePumpFactory* message_pump_for_ui_factory_ = NULL;
88 88
89 // Returns true if MessagePump::ScheduleWork() must be called one
90 // time for every task that is added to the MessageLoop incoming queue.
91 bool AlwaysNotifyPump(MessageLoop::Type type) {
92 #if defined(OS_ANDROID)
93 // The Android UI message loop needs to get notified each time a task is added
94 // to the incoming queue.
95 return type == MessageLoop::TYPE_UI || type == MessageLoop::TYPE_JAVA;
96 #else
97 return false;
98 #endif
99 }
100
101 #if defined(OS_IOS) 89 #if defined(OS_IOS)
102 typedef MessagePumpIOSForIO MessagePumpForIO; 90 typedef MessagePumpIOSForIO MessagePumpForIO;
103 #elif defined(OS_NACL_SFI) 91 #elif defined(OS_NACL_SFI)
104 typedef MessagePumpDefault MessagePumpForIO; 92 typedef MessagePumpDefault MessagePumpForIO;
105 #elif defined(OS_POSIX) 93 #elif defined(OS_POSIX)
106 typedef MessagePumpLibevent MessagePumpForIO; 94 typedef MessagePumpLibevent MessagePumpForIO;
107 #endif 95 #endif
108 96
109 #if !defined(OS_NACL_SFI) 97 #if !defined(OS_NACL_SFI)
110 MessagePumpForIO* ToPumpIO(MessagePump* pump) { 98 MessagePumpForIO* ToPumpIO(MessagePump* pump) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // We can improve performance of our loading tasks from the incoming queue to 493 // We can improve performance of our loading tasks from the incoming queue to
506 // |*work_queue| by waiting until the last minute (|*work_queue| is empty) to 494 // |*work_queue| by waiting until the last minute (|*work_queue| is empty) to
507 // load. That reduces the number of locks-per-task significantly when our 495 // load. That reduces the number of locks-per-task significantly when our
508 // queues get large. 496 // queues get large.
509 if (work_queue_.empty()) { 497 if (work_queue_.empty()) {
510 pending_high_res_tasks_ += 498 pending_high_res_tasks_ +=
511 incoming_task_queue_->ReloadWorkQueue(&work_queue_); 499 incoming_task_queue_->ReloadWorkQueue(&work_queue_);
512 } 500 }
513 } 501 }
514 502
515 void MessageLoop::ScheduleWork(bool was_empty) { 503 void MessageLoop::ScheduleWork() {
516 if (was_empty || AlwaysNotifyPump(type_)) 504 pump_->ScheduleWork();
517 pump_->ScheduleWork();
518 } 505 }
519 506
520 //------------------------------------------------------------------------------ 507 //------------------------------------------------------------------------------
521 // Method and data for histogramming events and actions taken by each instance 508 // Method and data for histogramming events and actions taken by each instance
522 // on each thread. 509 // on each thread.
523 510
524 void MessageLoop::StartHistogrammer() { 511 void MessageLoop::StartHistogrammer() {
525 #if !defined(OS_NACL) // NaCl build has no metrics code. 512 #if !defined(OS_NACL) // NaCl build has no metrics code.
526 if (enable_histogrammer_ && !message_histogram_ 513 if (enable_histogrammer_ && !message_histogram_
527 && StatisticsRecorder::IsActive()) { 514 && StatisticsRecorder::IsActive()) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 persistent, 699 persistent,
713 mode, 700 mode,
714 controller, 701 controller,
715 delegate); 702 delegate);
716 } 703 }
717 #endif 704 #endif
718 705
719 #endif // !defined(OS_NACL_SFI) 706 #endif // !defined(OS_NACL_SFI)
720 707
721 } // namespace base 708 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/message_loop/message_pump_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698