Index: net/ssl/channel_id_service.cc |
diff --git a/net/ssl/channel_id_service.cc b/net/ssl/channel_id_service.cc |
index 7cae014a2f09c547b2d8f1f33aa2bce7509399e1..163a56b2977c8f99f0a6cdbe1822aad450dfda9d 100644 |
--- a/net/ssl/channel_id_service.cc |
+++ b/net/ssl/channel_id_service.cc |
@@ -6,6 +6,7 @@ |
#include <algorithm> |
#include <limits> |
+#include <memory> |
#include <utility> |
#include "base/atomic_sequence_num.h" |
@@ -17,7 +18,6 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
-#include "base/memory/scoped_ptr.h" |
#include "base/metrics/histogram_macros.h" |
#include "base/rand_util.h" |
#include "base/single_thread_task_runner.h" |
@@ -86,14 +86,14 @@ void RecordGetChannelIDTime(base::TimeDelta request_time) { |
// Otherwise, returns NULL, and |*error| will be set to a net error code. |
// |serial_number| is passed in because base::RandInt cannot be called from an |
// unjoined thread, due to relying on a non-leaked LazyInstance |
-scoped_ptr<ChannelIDStore::ChannelID> GenerateChannelID( |
+std::unique_ptr<ChannelIDStore::ChannelID> GenerateChannelID( |
const std::string& server_identifier, |
int* error) { |
- scoped_ptr<ChannelIDStore::ChannelID> result; |
+ std::unique_ptr<ChannelIDStore::ChannelID> result; |
base::TimeTicks start = base::TimeTicks::Now(); |
base::Time creation_time = base::Time::Now(); |
- scoped_ptr<crypto::ECPrivateKey> key(crypto::ECPrivateKey::Create()); |
+ std::unique_ptr<crypto::ECPrivateKey> key(crypto::ECPrivateKey::Create()); |
if (!key) { |
DLOG(ERROR) << "Unable to create channel ID key pair"; |
@@ -119,10 +119,9 @@ scoped_ptr<ChannelIDStore::ChannelID> GenerateChannelID( |
// itself once Start() is called. |
class ChannelIDServiceWorker { |
public: |
- typedef base::Callback<void( |
- const std::string&, |
- int, |
- scoped_ptr<ChannelIDStore::ChannelID>)> WorkerDoneCallback; |
+ typedef base::Callback< |
+ void(const std::string&, int, std::unique_ptr<ChannelIDStore::ChannelID>)> |
+ WorkerDoneCallback; |
ChannelIDServiceWorker(const std::string& server_identifier, |
const WorkerDoneCallback& callback) |
@@ -145,7 +144,7 @@ class ChannelIDServiceWorker { |
void Run() { |
// Runs on a worker thread. |
int error = ERR_FAILED; |
- scoped_ptr<ChannelIDStore::ChannelID> channel_id = |
+ std::unique_ptr<ChannelIDStore::ChannelID> channel_id = |
GenerateChannelID(server_identifier_, &error); |
#if !defined(USE_OPENSSL) |
// Detach the thread from NSPR. |
@@ -186,7 +185,7 @@ class ChannelIDServiceJob { |
requests_.push_back(request); |
} |
- void HandleResult(int error, scoped_ptr<crypto::ECPrivateKey> key) { |
+ void HandleResult(int error, std::unique_ptr<crypto::ECPrivateKey> key) { |
PostAll(error, std::move(key)); |
} |
@@ -199,13 +198,13 @@ class ChannelIDServiceJob { |
} |
private: |
- void PostAll(int error, scoped_ptr<crypto::ECPrivateKey> key) { |
+ void PostAll(int error, std::unique_ptr<crypto::ECPrivateKey> key) { |
std::vector<ChannelIDService::Request*> requests; |
requests_.swap(requests); |
for (std::vector<ChannelIDService::Request*>::iterator i = requests.begin(); |
i != requests.end(); i++) { |
- scoped_ptr<crypto::ECPrivateKey> key_copy; |
+ std::unique_ptr<crypto::ECPrivateKey> key_copy; |
if (key) |
key_copy.reset(key->Copy()); |
(*i)->Post(error, std::move(key_copy)); |
@@ -240,7 +239,7 @@ void ChannelIDService::Request::RequestStarted( |
ChannelIDService* service, |
base::TimeTicks request_start, |
const CompletionCallback& callback, |
- scoped_ptr<crypto::ECPrivateKey>* key, |
+ std::unique_ptr<crypto::ECPrivateKey>* key, |
ChannelIDServiceJob* job) { |
DCHECK(service_ == NULL); |
service_ = service; |
@@ -250,8 +249,9 @@ void ChannelIDService::Request::RequestStarted( |
job_ = job; |
} |
-void ChannelIDService::Request::Post(int error, |
- scoped_ptr<crypto::ECPrivateKey> key) { |
+void ChannelIDService::Request::Post( |
+ int error, |
+ std::unique_ptr<crypto::ECPrivateKey> key) { |
switch (error) { |
case OK: { |
base::TimeDelta request_time = base::TimeTicks::Now() - request_start_; |
@@ -314,7 +314,7 @@ std::string ChannelIDService::GetDomainForHost(const std::string& host) { |
int ChannelIDService::GetOrCreateChannelID( |
const std::string& host, |
- scoped_ptr<crypto::ECPrivateKey>* key, |
+ std::unique_ptr<crypto::ECPrivateKey>* key, |
const CompletionCallback& callback, |
Request* out_req) { |
DVLOG(1) << __FUNCTION__ << " " << host; |
@@ -369,7 +369,7 @@ int ChannelIDService::GetOrCreateChannelID( |
} |
int ChannelIDService::GetChannelID(const std::string& host, |
- scoped_ptr<crypto::ECPrivateKey>* key, |
+ std::unique_ptr<crypto::ECPrivateKey>* key, |
const CompletionCallback& callback, |
Request* out_req) { |
DVLOG(1) << __FUNCTION__ << " " << host; |
@@ -403,7 +403,7 @@ int ChannelIDService::GetChannelID(const std::string& host, |
void ChannelIDService::GotChannelID(int err, |
const std::string& server_identifier, |
- scoped_ptr<crypto::ECPrivateKey> key) { |
+ std::unique_ptr<crypto::ECPrivateKey> key) { |
DCHECK(CalledOnValidThread()); |
std::map<std::string, ChannelIDServiceJob*>::iterator j; |
@@ -448,10 +448,10 @@ ChannelIDStore* ChannelIDService::GetChannelIDStore() { |
void ChannelIDService::GeneratedChannelID( |
const std::string& server_identifier, |
int error, |
- scoped_ptr<ChannelIDStore::ChannelID> channel_id) { |
+ std::unique_ptr<ChannelIDStore::ChannelID> channel_id) { |
DCHECK(CalledOnValidThread()); |
- scoped_ptr<crypto::ECPrivateKey> key; |
+ std::unique_ptr<crypto::ECPrivateKey> key; |
if (error == OK) { |
key.reset(channel_id->key()->Copy()); |
channel_id_store_->SetChannelID(std::move(channel_id)); |
@@ -461,7 +461,7 @@ void ChannelIDService::GeneratedChannelID( |
void ChannelIDService::HandleResult(int error, |
const std::string& server_identifier, |
- scoped_ptr<crypto::ECPrivateKey> key) { |
+ std::unique_ptr<crypto::ECPrivateKey> key) { |
DCHECK(CalledOnValidThread()); |
std::map<std::string, ChannelIDServiceJob*>::iterator j; |
@@ -480,7 +480,7 @@ void ChannelIDService::HandleResult(int error, |
bool ChannelIDService::JoinToInFlightRequest( |
const base::TimeTicks& request_start, |
const std::string& domain, |
- scoped_ptr<crypto::ECPrivateKey>* key, |
+ std::unique_ptr<crypto::ECPrivateKey>* key, |
bool create_if_missing, |
const CompletionCallback& callback, |
Request* out_req) { |
@@ -501,12 +501,13 @@ bool ChannelIDService::JoinToInFlightRequest( |
return false; |
} |
-int ChannelIDService::LookupChannelID(const base::TimeTicks& request_start, |
- const std::string& domain, |
- scoped_ptr<crypto::ECPrivateKey>* key, |
- bool create_if_missing, |
- const CompletionCallback& callback, |
- Request* out_req) { |
+int ChannelIDService::LookupChannelID( |
+ const base::TimeTicks& request_start, |
+ const std::string& domain, |
+ std::unique_ptr<crypto::ECPrivateKey>* key, |
+ bool create_if_missing, |
+ const CompletionCallback& callback, |
+ Request* out_req) { |
// Check if a channel ID key already exists for this domain. |
int err = channel_id_store_->GetChannelID( |
domain, key, base::Bind(&ChannelIDService::GotChannelID, |