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

Side by Side Diff: base/files/important_file_writer.cc

Issue 510563002: Remove implicit conversions from scoped_refptr to T* in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Propagate Created 6 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/debug/trace_event_impl.cc ('k') | base/metrics/field_trial_unittest.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 (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/files/important_file_writer.h" 5 #include "base/files/important_file_writer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 bool ImportantFileWriter::PostWriteTask(const std::string& data) { 164 bool ImportantFileWriter::PostWriteTask(const std::string& data) {
165 // TODO(gab): This code could always use PostTaskAndReplyWithResult and let 165 // TODO(gab): This code could always use PostTaskAndReplyWithResult and let
166 // ForwardSuccessfulWrite() no-op if |on_next_successful_write_| is null, but 166 // ForwardSuccessfulWrite() no-op if |on_next_successful_write_| is null, but
167 // PostTaskAndReply causes memory leaks in tests (crbug.com/371974) and 167 // PostTaskAndReply causes memory leaks in tests (crbug.com/371974) and
168 // suppressing all of those is unrealistic hence we avoid most of them by 168 // suppressing all of those is unrealistic hence we avoid most of them by
169 // using PostTask() in the typical scenario below. 169 // using PostTask() in the typical scenario below.
170 if (!on_next_successful_write_.is_null()) { 170 if (!on_next_successful_write_.is_null()) {
171 return base::PostTaskAndReplyWithResult( 171 return base::PostTaskAndReplyWithResult(
172 task_runner_, 172 task_runner_.get(),
173 FROM_HERE, 173 FROM_HERE,
174 MakeCriticalClosure( 174 MakeCriticalClosure(
175 Bind(&ImportantFileWriter::WriteFileAtomically, path_, data)), 175 Bind(&ImportantFileWriter::WriteFileAtomically, path_, data)),
176 Bind(&ImportantFileWriter::ForwardSuccessfulWrite, 176 Bind(&ImportantFileWriter::ForwardSuccessfulWrite,
177 weak_factory_.GetWeakPtr())); 177 weak_factory_.GetWeakPtr()));
178 } 178 }
179 return task_runner_->PostTask( 179 return task_runner_->PostTask(
180 FROM_HERE, 180 FROM_HERE,
181 MakeCriticalClosure( 181 MakeCriticalClosure(
182 Bind(IgnoreResult(&ImportantFileWriter::WriteFileAtomically), 182 Bind(IgnoreResult(&ImportantFileWriter::WriteFileAtomically),
183 path_, data))); 183 path_, data)));
184 } 184 }
185 185
186 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { 186 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) {
187 DCHECK(CalledOnValidThread()); 187 DCHECK(CalledOnValidThread());
188 if (result && !on_next_successful_write_.is_null()) { 188 if (result && !on_next_successful_write_.is_null()) {
189 on_next_successful_write_.Run(); 189 on_next_successful_write_.Run();
190 on_next_successful_write_.Reset(); 190 on_next_successful_write_.Reset();
191 } 191 }
192 } 192 }
193 193
194 } // namespace base 194 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698