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

Unified Diff: net/ssl/channel_id_service_unittest.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ssl/channel_id_service.cc ('k') | net/ssl/channel_id_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/channel_id_service_unittest.cc
diff --git a/net/ssl/channel_id_service_unittest.cc b/net/ssl/channel_id_service_unittest.cc
index 1e98b61a674e1d04341cd29473585aa30edb7e8d..578ce568f1aaff66a51e1aff14a9b77dab266657 100644
--- a/net/ssl/channel_id_service_unittest.cc
+++ b/net/ssl/channel_id_service_unittest.cc
@@ -4,13 +4,14 @@
#include "net/ssl/channel_id_service.h"
+#include <memory>
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
@@ -62,10 +63,10 @@ class MockChannelIDStoreWithAsyncGet
: DefaultChannelIDStore(NULL), channel_id_count_(0) {}
int GetChannelID(const std::string& server_identifier,
- scoped_ptr<crypto::ECPrivateKey>* key_result,
+ std::unique_ptr<crypto::ECPrivateKey>* key_result,
const GetChannelIDCallback& callback) override;
- void SetChannelID(scoped_ptr<ChannelID> channel_id) override {
+ void SetChannelID(std::unique_ptr<ChannelID> channel_id) override {
channel_id_count_ = 1;
}
@@ -81,7 +82,7 @@ class MockChannelIDStoreWithAsyncGet
int MockChannelIDStoreWithAsyncGet::GetChannelID(
const std::string& server_identifier,
- scoped_ptr<crypto::ECPrivateKey>* key_result,
+ std::unique_ptr<crypto::ECPrivateKey>* key_result,
const GetChannelIDCallback& callback) {
server_identifier_ = server_identifier;
callback_ = callback;
@@ -101,7 +102,7 @@ void MockChannelIDStoreWithAsyncGet::CallGetChannelIDCallbackWithResult(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(callback_, err, server_identifier_,
- base::Passed(make_scoped_ptr(key ? key->Copy() : nullptr))));
+ base::Passed(base::WrapUnique(key ? key->Copy() : nullptr))));
}
class ChannelIDServiceTest : public testing::Test {
@@ -111,7 +112,7 @@ class ChannelIDServiceTest : public testing::Test {
base::ThreadTaskRunnerHandle::Get())) {}
protected:
- scoped_ptr<ChannelIDService> service_;
+ std::unique_ptr<ChannelIDService> service_;
};
TEST_F(ChannelIDServiceTest, GetDomainForHost) {
@@ -141,7 +142,7 @@ TEST_F(ChannelIDServiceTest, GetCacheMiss) {
ChannelIDService::Request request;
// Synchronous completion, because the store is initialized.
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetChannelID(host, &key, callback.callback(), &request);
EXPECT_EQ(ERR_FILE_NOT_FOUND, error);
@@ -158,7 +159,7 @@ TEST_F(ChannelIDServiceTest, CacheHit) {
ChannelIDService::Request request;
// Asynchronous completion.
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetOrCreateChannelID(host, &key1, callback.callback(),
&request);
@@ -171,7 +172,7 @@ TEST_F(ChannelIDServiceTest, CacheHit) {
EXPECT_FALSE(request.is_active());
// Synchronous completion.
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
error = service_->GetOrCreateChannelID(host, &key2, callback.callback(),
&request);
EXPECT_FALSE(request.is_active());
@@ -180,7 +181,7 @@ TEST_F(ChannelIDServiceTest, CacheHit) {
EXPECT_TRUE(KeysEqual(key1.get(), key2.get()));
// Synchronous get.
- scoped_ptr<crypto::ECPrivateKey> key3;
+ std::unique_ptr<crypto::ECPrivateKey> key3;
error = service_->GetChannelID(host, &key3, callback.callback(), &request);
EXPECT_FALSE(request.is_active());
EXPECT_EQ(OK, error);
@@ -198,7 +199,7 @@ TEST_F(ChannelIDServiceTest, StoreChannelIDs) {
ChannelIDService::Request request;
std::string host1("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetOrCreateChannelID(host1, &key1, callback.callback(),
&request);
@@ -209,7 +210,7 @@ TEST_F(ChannelIDServiceTest, StoreChannelIDs) {
EXPECT_EQ(1, service_->channel_id_count());
std::string host2("www.verisign.com");
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
error = service_->GetOrCreateChannelID(host2, &key2, callback.callback(),
&request);
EXPECT_EQ(ERR_IO_PENDING, error);
@@ -219,7 +220,7 @@ TEST_F(ChannelIDServiceTest, StoreChannelIDs) {
EXPECT_EQ(2, service_->channel_id_count());
std::string host3("www.twitter.com");
- scoped_ptr<crypto::ECPrivateKey> key3;
+ std::unique_ptr<crypto::ECPrivateKey> key3;
error = service_->GetOrCreateChannelID(host3, &key3, callback.callback(),
&request);
EXPECT_EQ(ERR_IO_PENDING, error);
@@ -238,11 +239,11 @@ TEST_F(ChannelIDServiceTest, InflightJoin) {
std::string host("encrypted.google.com");
int error;
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
TestCompletionCallback callback1;
ChannelIDService::Request request1;
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
TestCompletionCallback callback2;
ChannelIDService::Request request2;
@@ -272,11 +273,11 @@ TEST_F(ChannelIDServiceTest, InflightJoinGetOrCreateAndGet) {
std::string host("encrypted.google.com");
int error;
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
TestCompletionCallback callback1;
ChannelIDService::Request request1;
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
TestCompletionCallback callback2;
ChannelIDService::Request request2;
@@ -304,7 +305,7 @@ TEST_F(ChannelIDServiceTest, InflightJoinGetOrCreateAndGet) {
// Tests that the callback of a canceled request is never made.
TEST_F(ChannelIDServiceTest, CancelRequest) {
std::string host("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
int error;
ChannelIDService::Request request;
@@ -327,9 +328,9 @@ TEST_F(ChannelIDServiceTest, CancelRequest) {
// Tests that destructing the Request cancels the request.
TEST_F(ChannelIDServiceTest, CancelRequestByHandleDestruction) {
std::string host("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
int error;
- scoped_ptr<ChannelIDService::Request> request(
+ std::unique_ptr<ChannelIDService::Request> request(
new ChannelIDService::Request());
error = service_->GetOrCreateChannelID(host, &key, base::Bind(&FailTest),
@@ -351,7 +352,7 @@ TEST_F(ChannelIDServiceTest, CancelRequestByHandleDestruction) {
TEST_F(ChannelIDServiceTest, DestructionWithPendingRequest) {
std::string host("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
int error;
ChannelIDService::Request request;
@@ -382,7 +383,7 @@ TEST_F(ChannelIDServiceTest, RequestAfterPoolShutdown) {
// Make a request that will force synchronous completion.
std::string host("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
int error;
ChannelIDService::Request request;
@@ -398,17 +399,17 @@ TEST_F(ChannelIDServiceTest, SimultaneousCreation) {
int error;
std::string host1("encrypted.google.com");
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
TestCompletionCallback callback1;
ChannelIDService::Request request1;
std::string host2("foo.com");
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
TestCompletionCallback callback2;
ChannelIDService::Request request2;
std::string host3("bar.com");
- scoped_ptr<crypto::ECPrivateKey> key3;
+ std::unique_ptr<crypto::ECPrivateKey> key3;
TestCompletionCallback callback3;
ChannelIDService::Request request3;
@@ -449,7 +450,7 @@ TEST_F(ChannelIDServiceTest, SimultaneousCreation) {
TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateNoChannelIDsInStore) {
MockChannelIDStoreWithAsyncGet* mock_store =
new MockChannelIDStoreWithAsyncGet();
- service_ = scoped_ptr<ChannelIDService>(
+ service_ = std::unique_ptr<ChannelIDService>(
new ChannelIDService(mock_store, base::ThreadTaskRunnerHandle::Get()));
std::string host("encrypted.google.com");
@@ -459,7 +460,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateNoChannelIDsInStore) {
ChannelIDService::Request request;
// Asynchronous completion with no certs in the store.
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
EXPECT_EQ(0, service_->channel_id_count());
error =
service_->GetOrCreateChannelID(host, &key, callback.callback(), &request);
@@ -478,7 +479,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateNoChannelIDsInStore) {
TEST_F(ChannelIDServiceTest, AsyncStoreGetNoChannelIDsInStore) {
MockChannelIDStoreWithAsyncGet* mock_store =
new MockChannelIDStoreWithAsyncGet();
- service_ = scoped_ptr<ChannelIDService>(
+ service_ = std::unique_ptr<ChannelIDService>(
new ChannelIDService(mock_store, base::ThreadTaskRunnerHandle::Get()));
std::string host("encrypted.google.com");
@@ -488,7 +489,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetNoChannelIDsInStore) {
ChannelIDService::Request request;
// Asynchronous completion with no certs in the store.
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetChannelID(host, &key, callback.callback(), &request);
EXPECT_EQ(ERR_IO_PENDING, error);
@@ -507,7 +508,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetNoChannelIDsInStore) {
TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateOneCertInStore) {
MockChannelIDStoreWithAsyncGet* mock_store =
new MockChannelIDStoreWithAsyncGet();
- service_ = scoped_ptr<ChannelIDService>(
+ service_ = std::unique_ptr<ChannelIDService>(
new ChannelIDService(mock_store, base::ThreadTaskRunnerHandle::Get()));
std::string host("encrypted.google.com");
@@ -517,14 +518,15 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateOneCertInStore) {
ChannelIDService::Request request;
// Asynchronous completion with a cert in the store.
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
EXPECT_EQ(0, service_->channel_id_count());
error =
service_->GetOrCreateChannelID(host, &key, callback.callback(), &request);
EXPECT_EQ(ERR_IO_PENDING, error);
EXPECT_TRUE(request.is_active());
- scoped_ptr<crypto::ECPrivateKey> expected_key(crypto::ECPrivateKey::Create());
+ std::unique_ptr<crypto::ECPrivateKey> expected_key(
+ crypto::ECPrivateKey::Create());
mock_store->CallGetChannelIDCallbackWithResult(OK, expected_key.get());
error = callback.WaitForResult();
@@ -543,7 +545,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOrCreateOneCertInStore) {
TEST_F(ChannelIDServiceTest, AsyncStoreGetOneCertInStore) {
MockChannelIDStoreWithAsyncGet* mock_store =
new MockChannelIDStoreWithAsyncGet();
- service_ = scoped_ptr<ChannelIDService>(
+ service_ = std::unique_ptr<ChannelIDService>(
new ChannelIDService(mock_store, base::ThreadTaskRunnerHandle::Get()));
std::string host("encrypted.google.com");
@@ -553,14 +555,15 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOneCertInStore) {
ChannelIDService::Request request;
// Asynchronous completion with a cert in the store.
- scoped_ptr<crypto::ECPrivateKey> key;
+ std::unique_ptr<crypto::ECPrivateKey> key;
std::string private_key, spki;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetChannelID(host, &key, callback.callback(), &request);
EXPECT_EQ(ERR_IO_PENDING, error);
EXPECT_TRUE(request.is_active());
- scoped_ptr<crypto::ECPrivateKey> expected_key(crypto::ECPrivateKey::Create());
+ std::unique_ptr<crypto::ECPrivateKey> expected_key(
+ crypto::ECPrivateKey::Create());
mock_store->CallGetChannelIDCallbackWithResult(OK, expected_key.get());
error = callback.WaitForResult();
@@ -578,7 +581,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetOneCertInStore) {
TEST_F(ChannelIDServiceTest, AsyncStoreGetThenCreateNoCertsInStore) {
MockChannelIDStoreWithAsyncGet* mock_store =
new MockChannelIDStoreWithAsyncGet();
- service_ = scoped_ptr<ChannelIDService>(
+ service_ = std::unique_ptr<ChannelIDService>(
new ChannelIDService(mock_store, base::ThreadTaskRunnerHandle::Get()));
std::string host("encrypted.google.com");
@@ -588,7 +591,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetThenCreateNoCertsInStore) {
// Asynchronous get with no certs in the store.
TestCompletionCallback callback1;
ChannelIDService::Request request1;
- scoped_ptr<crypto::ECPrivateKey> key1;
+ std::unique_ptr<crypto::ECPrivateKey> key1;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetChannelID(host, &key1, callback1.callback(), &request1);
EXPECT_EQ(ERR_IO_PENDING, error);
@@ -597,7 +600,7 @@ TEST_F(ChannelIDServiceTest, AsyncStoreGetThenCreateNoCertsInStore) {
// Asynchronous get/create with no certs in the store.
TestCompletionCallback callback2;
ChannelIDService::Request request2;
- scoped_ptr<crypto::ECPrivateKey> key2;
+ std::unique_ptr<crypto::ECPrivateKey> key2;
EXPECT_EQ(0, service_->channel_id_count());
error = service_->GetOrCreateChannelID(host, &key2, callback2.callback(),
&request2);
« no previous file with comments | « net/ssl/channel_id_service.cc ('k') | net/ssl/channel_id_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698