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

Side by Side Diff: base/bind_helpers.h

Issue 1074963003: Clean up potentially leaky use of base::DeletePointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed another probleb Created 5 years, 8 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 | chrome/browser/sync/profile_sync_service_typed_url_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 // This defines a set of argument wrappers and related factory methods that 5 // This defines a set of argument wrappers and related factory methods that
6 // can be used specify the refcounting and reference semantics of arguments 6 // can be used specify the refcounting and reference semantics of arguments
7 // that are bound by the Bind() function in base/bind.h. 7 // that are bound by the Bind() function in base/bind.h.
8 // 8 //
9 // It also defines a set of simple functions and utilities that people want 9 // It also defines a set of simple functions and utilities that people want
10 // when using Callback<> and Bind(). 10 // when using Callback<> and Bind().
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // DeletePointer<T>() - Useful for creating a Closure that will delete a 138 // DeletePointer<T>() - Useful for creating a Closure that will delete a
139 // pointer when invoked. Only use this when necessary. 139 // pointer when invoked. Only use this when necessary.
140 // In most cases MessageLoop::DeleteSoon() is a better 140 // In most cases MessageLoop::DeleteSoon() is a better
141 // fit. 141 // fit.
142 142
143 #ifndef BASE_BIND_HELPERS_H_ 143 #ifndef BASE_BIND_HELPERS_H_
144 #define BASE_BIND_HELPERS_H_ 144 #define BASE_BIND_HELPERS_H_
145 145
146 #include "base/basictypes.h" 146 #include "base/basictypes.h"
147 #include "base/callback.h" 147 #include "base/callback.h"
148 #include "base/memory/scoped_ptr.h"
148 #include "base/memory/weak_ptr.h" 149 #include "base/memory/weak_ptr.h"
149 #include "base/template_util.h" 150 #include "base/template_util.h"
150 151
151 namespace base { 152 namespace base {
152 namespace internal { 153 namespace internal {
153 154
154 // Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T 155 // Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T
155 // for the existence of AddRef() and Release() functions of the correct 156 // for the existence of AddRef() and Release() functions of the correct
156 // signature. 157 // signature.
157 // 158 //
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 587
587 template <typename T> 588 template <typename T>
588 static inline internal::IgnoreResultHelper<Callback<T> > 589 static inline internal::IgnoreResultHelper<Callback<T> >
589 IgnoreResult(const Callback<T>& data) { 590 IgnoreResult(const Callback<T>& data) {
590 return internal::IgnoreResultHelper<Callback<T> >(data); 591 return internal::IgnoreResultHelper<Callback<T> >(data);
591 } 592 }
592 593
593 BASE_EXPORT void DoNothing(); 594 BASE_EXPORT void DoNothing();
594 595
595 template<typename T> 596 template<typename T>
596 void DeletePointer(T* obj) { 597 void DeletePointer(scoped_ptr<T> obj) {
597 delete obj; 598 // No need to do anything, scoped_ptr<> will do it for us.
598 } 599 }
599 600
600 } // namespace base 601 } // namespace base
601 602
602 #endif // BASE_BIND_HELPERS_H_ 603 #endif // BASE_BIND_HELPERS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service_typed_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698