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

Unified Diff: net/http/http_basic_state_unittest.cc

Issue 2255883002: Pass ClientSocketHandle ownership around in unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_basic_state.cc ('k') | net/http/http_basic_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_basic_state_unittest.cc
diff --git a/net/http/http_basic_state_unittest.cc b/net/http/http_basic_state_unittest.cc
index 98540e0e2326ad0ca6f4fc9084dcdcc97bc8b2fa..1d9476da23cafa1e1b114f0373032e5bbd98c1eb 100644
--- a/net/http/http_basic_state_unittest.cc
+++ b/net/http/http_basic_state_unittest.cc
@@ -4,6 +4,7 @@
#include "net/http/http_basic_state.h"
+#include "base/memory/ptr_util.h"
#include "net/base/completion_callback.h"
#include "net/base/request_priority.h"
#include "net/http/http_request_info.h"
@@ -15,20 +16,21 @@ namespace {
TEST(HttpBasicStateTest, ConstructsProperly) {
ClientSocketHandle* const handle = new ClientSocketHandle;
- // Ownership of handle is passed to |state|.
- const HttpBasicState state(handle, true);
+ // Ownership of |handle| is passed to |state|.
+ const HttpBasicState state(base::WrapUnique(handle), true);
EXPECT_EQ(handle, state.connection());
EXPECT_TRUE(state.using_proxy());
}
TEST(HttpBasicStateTest, UsingProxyCanBeFalse) {
- const HttpBasicState state(new ClientSocketHandle(), false);
+ const HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
EXPECT_FALSE(state.using_proxy());
}
TEST(HttpBasicStateTest, ReleaseConnectionWorks) {
ClientSocketHandle* const handle = new ClientSocketHandle;
- HttpBasicState state(handle, false);
+ // Ownership of |handle| is passed to |state|.
+ HttpBasicState state(base::WrapUnique(handle), false);
const std::unique_ptr<ClientSocketHandle> released_connection(
state.ReleaseConnection());
EXPECT_EQ(NULL, state.connection());
@@ -36,7 +38,7 @@ TEST(HttpBasicStateTest, ReleaseConnectionWorks) {
}
TEST(HttpBasicStateTest, InitializeWorks) {
- HttpBasicState state(new ClientSocketHandle(), false);
+ HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
const HttpRequestInfo request_info;
EXPECT_EQ(OK,
state.Initialize(
@@ -45,7 +47,7 @@ TEST(HttpBasicStateTest, InitializeWorks) {
}
TEST(HttpBasicStateTest, DeleteParser) {
- HttpBasicState state(new ClientSocketHandle(), false);
+ HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), false);
const HttpRequestInfo request_info;
state.Initialize(&request_info, LOW, BoundNetLog(), CompletionCallback());
EXPECT_TRUE(state.parser());
@@ -55,7 +57,7 @@ TEST(HttpBasicStateTest, DeleteParser) {
TEST(HttpBasicStateTest, GenerateRequestLineNoProxy) {
const bool use_proxy = false;
- HttpBasicState state(new ClientSocketHandle(), use_proxy);
+ HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy);
HttpRequestInfo request_info;
request_info.url = GURL("http://www.example.com/path?foo=bar#hoge");
request_info.method = "PUT";
@@ -65,7 +67,7 @@ TEST(HttpBasicStateTest, GenerateRequestLineNoProxy) {
TEST(HttpBasicStateTest, GenerateRequestLineWithProxy) {
const bool use_proxy = true;
- HttpBasicState state(new ClientSocketHandle(), use_proxy);
+ HttpBasicState state(base::MakeUnique<ClientSocketHandle>(), use_proxy);
HttpRequestInfo request_info;
request_info.url = GURL("http://www.example.com/path?foo=bar#hoge");
request_info.method = "PUT";
« no previous file with comments | « net/http/http_basic_state.cc ('k') | net/http/http_basic_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698