summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcheng <dcheng@chromium.org>2014-10-21 13:29:55 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-21 20:30:24 +0000
commit19b6b65f39712670a4bf8289cdeb4992c62ef27c (patch)
treead248c4106ec5a53f1dd60f59809da140d9b1a48
parentccbfe27c8d2b4fcb7ddc98064ec6aa5820fcfe9a (diff)
downloadchromium_src-19b6b65f39712670a4bf8289cdeb4992c62ef27c.zip
chromium_src-19b6b65f39712670a4bf8289cdeb4992c62ef27c.tar.gz
chromium_src-19b6b65f39712670a4bf8289cdeb4992c62ef27c.tar.bz2
Clean up final uses of scoped_ptr<T>::PassAs() and remove it.
This helper to upcast in return statements is no longer needed. BUG=423621 Review URL: https://codereview.chromium.org/663243003 Cr-Commit-Position: refs/heads/master@{#300548}
-rw-r--r--base/memory/scoped_ptr.h21
-rw-r--r--base/memory/scoped_ptr_unittest.cc21
-rw-r--r--cc/PRESUBMIT.py6
-rw-r--r--net/socket/ssl_client_socket_unittest.cc4
4 files changed, 2 insertions, 50 deletions
diff --git a/base/memory/scoped_ptr.h b/base/memory/scoped_ptr.h
index f3bbd12..ae9eb0f 100644
--- a/base/memory/scoped_ptr.h
+++ b/base/memory/scoped_ptr.h
@@ -73,16 +73,6 @@
//
// scoped_ptr<Foo> foo(new Foo());
// scoped_ptr<FooParent> parent(foo.Pass());
-//
-// PassAs<>() should be used to upcast return value in return statement:
-//
-// scoped_ptr<Foo> CreateFoo() {
-// scoped_ptr<FooChild> result(new FooChild());
-// return result.PassAs<Foo>();
-// }
-//
-// Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
-// scoped_ptr<T[]>. This is because casting array pointers may not be safe.
#ifndef BASE_MEMORY_SCOPED_PTR_H_
#define BASE_MEMORY_SCOPED_PTR_H_
@@ -436,17 +426,6 @@ class scoped_ptr {
return impl_.release();
}
- // C++98 doesn't support functions templates with default parameters which
- // makes it hard to write a PassAs() that understands converting the deleter
- // while preserving simple calling semantics.
- //
- // Until there is a use case for PassAs() with custom deleters, just ignore
- // the custom deleter.
- template <typename PassAsType>
- scoped_ptr<PassAsType> PassAs() {
- return scoped_ptr<PassAsType>(Pass());
- }
-
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class scoped_ptr;
diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
index 6af19b6..3f169a7 100644
--- a/base/memory/scoped_ptr_unittest.cc
+++ b/base/memory/scoped_ptr_unittest.cc
@@ -94,11 +94,6 @@ scoped_ptr<ConDecLogger> TestReturnOfType(int* constructed) {
return scoped_ptr<ConDecLogger>(new ConDecLogger(constructed));
}
-scoped_ptr<ConDecLoggerParent> UpcastUsingPassAs(
- scoped_ptr<ConDecLogger> object) {
- return object.PassAs<ConDecLoggerParent>();
-}
-
} // namespace
TEST(ScopedPtrTest, ScopedPtr) {
@@ -462,22 +457,6 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) {
EXPECT_EQ(0, constructed);
}
-TEST(ScopedPtrTest, PassAs) {
- int constructed = 0;
- {
- scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed));
- EXPECT_EQ(1, constructed);
- EXPECT_TRUE(scoper.get());
-
- scoped_ptr<ConDecLoggerParent> scoper_parent;
- scoper_parent = UpcastUsingPassAs(scoper.Pass());
- EXPECT_EQ(1, constructed);
- EXPECT_TRUE(scoper_parent.get());
- EXPECT_FALSE(scoper.get());
- }
- EXPECT_EQ(0, constructed);
-}
-
TEST(ScopedPtrTest, CustomDeleter) {
double dummy_value; // Custom deleter never touches this value.
int deletes = 0;
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
index 1aa48f3..0393161 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -191,12 +191,6 @@ def CheckScopedPtr(input_api, output_api,
errors.append(output_api.PresubmitError(
'%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
(f.LocalPath(), line_number)))
- # Disallow:
- # foo.PassAs<T>();
- if re.search(r'\bPassAs<.*?>\(\)', line):
- errors.append(output_api.PresubmitError(
- '%s:%d uses PassAs<T>(). Use Pass() instead.' %
- (f.LocalPath(), line_number)))
return errors
def FindUnquotedQuote(contents, pos):
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index 13a3863..1dd9fb4 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -1822,7 +1822,7 @@ TEST_F(SSLClientSocketTest, Connect_WithZeroReturn) {
SynchronousErrorStreamSocket* raw_transport = transport.get();
scoped_ptr<SSLClientSocket> sock(
- CreateSSLClientSocket(transport.PassAs<StreamSocket>(),
+ CreateSSLClientSocket(transport.Pass(),
test_server.host_port_pair(),
kDefaultSSLConfig));
@@ -1859,7 +1859,7 @@ TEST_F(SSLClientSocketTest, Read_WithZeroReturn) {
SynchronousErrorStreamSocket* raw_transport = transport.get();
scoped_ptr<SSLClientSocket> sock(
- CreateSSLClientSocket(transport.PassAs<StreamSocket>(),
+ CreateSSLClientSocket(transport.Pass(),
test_server.host_port_pair(),
ssl_config));