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

Side by Side Diff: base/threading/post_task_and_reply_impl.cc

Issue 2236993004: Annotate PostTaskAndReplyRelay as being self-managed and potentially leaked in PostTaskAndReplyImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b1_afterstartup_runner
Patch Set: Created 4 years, 4 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 | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/post_task_and_reply_impl.h" 5 #include "base/threading/post_task_and_reply_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/debug/leak_annotations.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "base/sequence_checker.h" 12 #include "base/sequence_checker.h"
12 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
13 #include "base/threading/sequenced_task_runner_handle.h" 14 #include "base/threading/sequenced_task_runner_handle.h"
14 15
15 namespace base { 16 namespace base {
16 17
17 namespace { 18 namespace {
18 19
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 namespace internal { 76 namespace internal {
76 77
77 bool PostTaskAndReplyImpl::PostTaskAndReply( 78 bool PostTaskAndReplyImpl::PostTaskAndReply(
78 const tracked_objects::Location& from_here, 79 const tracked_objects::Location& from_here,
79 const Closure& task, 80 const Closure& task,
80 const Closure& reply) { 81 const Closure& reply) {
81 DCHECK(!task.is_null()) << from_here.ToString(); 82 DCHECK(!task.is_null()) << from_here.ToString();
82 DCHECK(!reply.is_null()) << from_here.ToString(); 83 DCHECK(!reply.is_null()) << from_here.ToString();
83 PostTaskAndReplyRelay* relay = 84 PostTaskAndReplyRelay* relay =
84 new PostTaskAndReplyRelay(from_here, task, reply); 85 new PostTaskAndReplyRelay(from_here, task, reply);
86 // PostTaskAndReplyRelay self-destructs after executing |reply|. On the flip
87 // side though, it is intentionally leaked if the |task| doesn't complete
88 // before the origin sequence stops executing tasks. Annotate |relay| as leaky
89 // to avoid having to suppress every callsite which happens to flakily trigger
90 // this race.
91 ANNOTATE_LEAKING_OBJECT_PTR(relay);
85 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::RunTaskAndPostReply, 92 if (!PostTask(from_here, Bind(&PostTaskAndReplyRelay::RunTaskAndPostReply,
86 Unretained(relay)))) { 93 Unretained(relay)))) {
87 delete relay; 94 delete relay;
88 return false; 95 return false;
89 } 96 }
90 97
91 return true; 98 return true;
92 } 99 }
93 100
94 } // namespace internal 101 } // namespace internal
95 102
96 } // namespace base 103 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698