Skip to content

Commit

Permalink
Revert of Move make_scoped_ptr into //base/memory/ptr_util.h. (patchset
Browse files Browse the repository at this point in the history
chromium#2 id:20001 of https://codereview.chromium.org/1838323002/ )

Reason for revert:
No longer needed given the updated migration plan.

Original issue's description:
> Move make_scoped_ptr into //base/memory/ptr_util.h.
>
> Preparatory CL for renaming scoped_ptr to std::unique_ptr. One of the
> changes is replacing all uses of make_scoped_ptr() with WrapUnique(),
> which lives in a separate header.
>
> In order to incrementally update files to use the new header, this CL
> moves make_scoped_ptr to ptr_util.h but still includes it in
> scoped_ptr.h to avoid breaking the build during the transition.
>
> BUG=554298
>
> Committed: https://crrev.com/e180e0b92e020144eb62530e561c9579cb0f35a7
> Cr-Commit-Position: refs/heads/master@{#383815}

TBR=danakj@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=554298

Review URL: https://codereview.chromium.org/1845243004 .

Cr-Commit-Position: refs/heads/master@{#384506}
  • Loading branch information
zetafunction committed Apr 1, 2016
1 parent 21866dd commit eee3dc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
25 changes: 0 additions & 25 deletions base/memory/ptr_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,6 @@

#include <memory>

// A function to convert T* into scoped_ptr<T>
// Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
// for scoped_ptr<FooBarBaz<type>>(new FooBarBaz<type>(arg))
//
// Why doesn't this just return a scoped_ptr?
//
// make_scoped_ptr is currently being migrated out of scoped_ptr.h, so we can
// globally rename make_scoped_ptr to WrapUnique without breaking the build.
// Doing so without breaking intermediate builds involves several steps:
//
// 1. Move make_scoped_ptr into ptr_util.h and include ptr_util.h from
// scoped_ptr.h.
// 2. Add an #include for ptr_util.h to every file that references
// make_scoped_ptr.
// 3. Remove ptr_util.h include from scoped_ptr.h.
// 4. Global rewrite everything.
//
// Unfortunately, step 1 introduces an awkward cycle of dependencies between
// ptr_util.h and scoped_ptr.h To break that cycle, we exploit the fact that
// scoped_ptr is really just a type alias for std::unique_ptr.
template <typename T>
std::unique_ptr<T> make_scoped_ptr(T* ptr) {
return std::unique_ptr<T>(ptr);
}

namespace base {

// Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.
Expand Down
11 changes: 8 additions & 3 deletions base/memory/scoped_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@

#include <memory>

// TODO(dcheng): Temporary, to facilitate transition off scoped_ptr.
#include "base/memory/ptr_util.h"

template <typename T, typename D = std::default_delete<T>>
using scoped_ptr = std::unique_ptr<T, D>;

// A function to convert T* into scoped_ptr<T>
// Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
// for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
template <typename T>
scoped_ptr<T> make_scoped_ptr(T* ptr) {
return scoped_ptr<T>(ptr);
}

#endif // BASE_MEMORY_SCOPED_PTR_H_

0 comments on commit eee3dc8

Please sign in to comment.