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

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

Issue 1044413002: Record async "task backtraces" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More wording fixes. Created 3 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
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/pending_task.h » ('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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 314
315 MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory) 315 MessageLoop::MessageLoop(Type type, MessagePumpFactoryCallback pump_factory)
316 : type_(type), 316 : type_(type),
317 #if defined(OS_WIN) 317 #if defined(OS_WIN)
318 pending_high_res_tasks_(0), 318 pending_high_res_tasks_(0),
319 in_high_res_mode_(false), 319 in_high_res_mode_(false),
320 #endif 320 #endif
321 nestable_tasks_allowed_(true), 321 nestable_tasks_allowed_(true),
322 pump_factory_(pump_factory), 322 pump_factory_(pump_factory),
323 run_loop_(NULL), 323 run_loop_(nullptr),
324 current_pending_task_(nullptr),
324 incoming_task_queue_(new internal::IncomingTaskQueue(this)), 325 incoming_task_queue_(new internal::IncomingTaskQueue(this)),
325 unbound_task_runner_( 326 unbound_task_runner_(
326 new internal::MessageLoopTaskRunner(incoming_task_queue_)), 327 new internal::MessageLoopTaskRunner(incoming_task_queue_)),
327 task_runner_(unbound_task_runner_), 328 task_runner_(unbound_task_runner_),
328 thread_id_(kInvalidThreadId) { 329 thread_id_(kInvalidThreadId) {
329 // If type is TYPE_CUSTOM non-null pump_factory must be given. 330 // If type is TYPE_CUSTOM non-null pump_factory must be given.
330 DCHECK(type_ != TYPE_CUSTOM || !pump_factory_.is_null()); 331 DCHECK(type_ != TYPE_CUSTOM || !pump_factory_.is_null());
331 } 332 }
332 333
333 void MessageLoop::BindToCurrentThread() { 334 void MessageLoop::BindToCurrentThread() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 PendingTask pending_task = 397 PendingTask pending_task =
397 std::move(deferred_non_nestable_work_queue_.front()); 398 std::move(deferred_non_nestable_work_queue_.front());
398 deferred_non_nestable_work_queue_.pop(); 399 deferred_non_nestable_work_queue_.pop();
399 400
400 RunTask(&pending_task); 401 RunTask(&pending_task);
401 return true; 402 return true;
402 } 403 }
403 404
404 void MessageLoop::RunTask(PendingTask* pending_task) { 405 void MessageLoop::RunTask(PendingTask* pending_task) {
405 DCHECK(nestable_tasks_allowed_); 406 DCHECK(nestable_tasks_allowed_);
407 current_pending_task_ = pending_task;
406 408
407 #if defined(OS_WIN) 409 #if defined(OS_WIN)
408 if (pending_task->is_high_res) { 410 if (pending_task->is_high_res) {
409 pending_high_res_tasks_--; 411 pending_high_res_tasks_--;
410 CHECK_GE(pending_high_res_tasks_, 0); 412 CHECK_GE(pending_high_res_tasks_, 0);
411 } 413 }
412 #endif 414 #endif
413 415
414 // Execute the task and assume the worst: It is probably not reentrant. 416 // Execute the task and assume the worst: It is probably not reentrant.
415 nestable_tasks_allowed_ = false; 417 nestable_tasks_allowed_ = false;
416 418
417 TRACE_TASK_EXECUTION("MessageLoop::RunTask", *pending_task); 419 TRACE_TASK_EXECUTION("MessageLoop::RunTask", *pending_task);
418 420
419 for (auto& observer : task_observers_) 421 for (auto& observer : task_observers_)
420 observer.WillProcessTask(*pending_task); 422 observer.WillProcessTask(*pending_task);
421 task_annotator_.RunTask("MessageLoop::PostTask", pending_task); 423 task_annotator_.RunTask("MessageLoop::PostTask", pending_task);
422 for (auto& observer : task_observers_) 424 for (auto& observer : task_observers_)
423 observer.DidProcessTask(*pending_task); 425 observer.DidProcessTask(*pending_task);
424 426
425 nestable_tasks_allowed_ = true; 427 nestable_tasks_allowed_ = true;
428
429 current_pending_task_ = nullptr;
426 } 430 }
427 431
428 bool MessageLoop::DeferOrRunPendingTask(PendingTask pending_task) { 432 bool MessageLoop::DeferOrRunPendingTask(PendingTask pending_task) {
429 if (pending_task.nestable || run_loop_->run_depth_ == 1) { 433 if (pending_task.nestable || run_loop_->run_depth_ == 1) {
430 RunTask(&pending_task); 434 RunTask(&pending_task);
431 // Show that we ran a task (Note: a new one might arrive as a 435 // Show that we ran a task (Note: a new one might arrive as a
432 // consequence!). 436 // consequence!).
433 return true; 437 return true;
434 } 438 }
435 439
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 persistent, 666 persistent,
663 mode, 667 mode,
664 controller, 668 controller,
665 delegate); 669 delegate);
666 } 670 }
667 #endif 671 #endif
668 672
669 #endif // !defined(OS_NACL_SFI) 673 #endif // !defined(OS_NACL_SFI)
670 674
671 } // namespace base 675 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop.h ('k') | base/pending_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698