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

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

Issue 2354053002: Delete MessageLoop::PostTask/PostDelayedTask/DeleteSoon/ReleaseSoon. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « base/message_loop/message_loop.h ('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 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 #include <memory>
9 #include <utility> 8 #include <utility>
10 9
11 #include "base/bind.h" 10 #include "base/bind.h"
12 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
13 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
14 #include "base/logging.h" 13 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
16 #include "base/message_loop/message_pump_default.h" 15 #include "base/message_loop/message_pump_default.h"
17 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
18 #include "base/metrics/statistics_recorder.h" 17 #include "base/metrics/statistics_recorder.h"
19 #include "base/run_loop.h" 18 #include "base/run_loop.h"
20 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
21 #include "base/threading/thread_id_name_manager.h" 20 #include "base/threading/thread_id_name_manager.h"
22 #include "base/threading/thread_local.h" 21 #include "base/threading/thread_local.h"
23 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
24 #include "base/time/time.h"
25 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
26 #include "base/tracked_objects.h"
27 #include "build/build_config.h"
28 24
29 #if defined(OS_MACOSX) 25 #if defined(OS_MACOSX)
30 #include "base/message_loop/message_pump_mac.h" 26 #include "base/message_loop/message_pump_mac.h"
31 #endif 27 #endif
32 #if defined(OS_POSIX) && !defined(OS_IOS) 28 #if defined(OS_POSIX) && !defined(OS_IOS)
33 #include "base/message_loop/message_pump_libevent.h" 29 #include "base/message_loop/message_pump_libevent.h"
34 #endif 30 #endif
35 #if defined(OS_ANDROID) 31 #if defined(OS_ANDROID)
36 #include "base/message_loop/message_pump_android.h" 32 #include "base/message_loop/message_pump_android.h"
37 #endif 33 #endif
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 void MessageLoop::AddNestingObserver(NestingObserver* observer) { 265 void MessageLoop::AddNestingObserver(NestingObserver* observer) {
270 DCHECK_EQ(this, current()); 266 DCHECK_EQ(this, current());
271 nesting_observers_.AddObserver(observer); 267 nesting_observers_.AddObserver(observer);
272 } 268 }
273 269
274 void MessageLoop::RemoveNestingObserver(NestingObserver* observer) { 270 void MessageLoop::RemoveNestingObserver(NestingObserver* observer) {
275 DCHECK_EQ(this, current()); 271 DCHECK_EQ(this, current());
276 nesting_observers_.RemoveObserver(observer); 272 nesting_observers_.RemoveObserver(observer);
277 } 273 }
278 274
279 #if !(defined(OS_MACOSX) && !defined(OS_IOS))
280 void MessageLoop::PostTask(
281 const tracked_objects::Location& from_here,
282 const Closure& task) {
283 task_runner_->PostTask(from_here, task);
284 }
285
286 void MessageLoop::PostDelayedTask(
287 const tracked_objects::Location& from_here,
288 const Closure& task,
289 TimeDelta delay) {
290 task_runner_->PostDelayedTask(from_here, task, delay);
291 }
292 #endif // !(defined(OS_MACOSX) && !defined(OS_IOS))
293
294 void MessageLoop::Run() { 275 void MessageLoop::Run() {
295 DCHECK(pump_); 276 DCHECK(pump_);
296 RunLoop run_loop; 277 RunLoop run_loop;
297 run_loop.Run(); 278 run_loop.Run();
298 } 279 }
299 280
300 void MessageLoop::RunUntilIdle() { 281 void MessageLoop::RunUntilIdle() {
301 DCHECK(pump_); 282 DCHECK(pump_);
302 RunLoop run_loop; 283 RunLoop run_loop;
303 run_loop.RunUntilIdle(); 284 run_loop.RunUntilIdle();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // for some tasks. 656 // for some tasks.
676 bool high_res = pending_high_res_tasks_ > 0; 657 bool high_res = pending_high_res_tasks_ > 0;
677 if (high_res != in_high_res_mode_) { 658 if (high_res != in_high_res_mode_) {
678 in_high_res_mode_ = high_res; 659 in_high_res_mode_ = high_res;
679 Time::ActivateHighResolutionTimer(in_high_res_mode_); 660 Time::ActivateHighResolutionTimer(in_high_res_mode_);
680 } 661 }
681 #endif 662 #endif
682 return false; 663 return false;
683 } 664 }
684 665
685 #if !(defined(OS_MACOSX) && !defined(OS_IOS))
686 void MessageLoop::DeleteSoonInternal(const tracked_objects::Location& from_here,
687 void(*deleter)(const void*),
688 const void* object) {
689 task_runner()->PostNonNestableTask(from_here, Bind(deleter, object));
690 }
691
692 void MessageLoop::ReleaseSoonInternal(
693 const tracked_objects::Location& from_here,
694 void(*releaser)(const void*),
695 const void* object) {
696 task_runner()->PostNonNestableTask(from_here, Bind(releaser, object));
697 }
698 #endif // !(defined(OS_MACOSX) && !defined(OS_IOS))
699
700 #if !defined(OS_NACL) 666 #if !defined(OS_NACL)
701 //------------------------------------------------------------------------------ 667 //------------------------------------------------------------------------------
702 // MessageLoopForUI 668 // MessageLoopForUI
703 669
704 MessageLoopForUI::MessageLoopForUI(std::unique_ptr<MessagePump> pump) 670 MessageLoopForUI::MessageLoopForUI(std::unique_ptr<MessagePump> pump)
705 : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {} 671 : MessageLoop(TYPE_UI, Bind(&ReturnPump, Passed(&pump))) {}
706 672
707 #if defined(OS_ANDROID) 673 #if defined(OS_ANDROID)
708 void MessageLoopForUI::Start() { 674 void MessageLoopForUI::Start() {
709 // No Histogram support for UI message loop as it is managed by Java side 675 // No Histogram support for UI message loop as it is managed by Java side
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 persistent, 741 persistent,
776 mode, 742 mode,
777 controller, 743 controller,
778 delegate); 744 delegate);
779 } 745 }
780 #endif 746 #endif
781 747
782 #endif // !defined(OS_NACL_SFI) 748 #endif // !defined(OS_NACL_SFI)
783 749
784 } // namespace base 750 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698