update_engine: Replace scoped_ptr with std::unique_ptr.
BUG=None
TEST=`FEATURES=test emerge-$BOARD update_engine`
TEST=`USE='clang asan' FEATURES=test emerge-$BOARD update_engine`
Change-Id: I55a2f7f53675faaac20ba25f72ed52cf938d7744
Reviewed-on: https://chromium-review.googlesource.com/224189
Tested-by: Ben Chan <benchan@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index 531986f..0e67ce9 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -7,12 +7,12 @@
#include <sys/socket.h>
#include <unistd.h>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <base/logging.h>
-#include <base/memory/scoped_ptr.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <base/time/time.h>
@@ -31,6 +31,7 @@
using std::make_pair;
using std::pair;
using std::string;
+using std::unique_ptr;
using std::vector;
using base::TimeDelta;
@@ -421,10 +422,10 @@
{
HttpFetcherTestDelegate delegate;
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
StartTransferArgs start_xfer_args = {
@@ -441,10 +442,10 @@
{
HttpFetcherTestDelegate delegate;
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
fetcher->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
StartTransferArgs start_xfer_args = {
@@ -469,10 +470,10 @@
// Delegate should expect an error response.
delegate.is_expect_error_ = true;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
StartTransferArgs start_xfer_args = {
@@ -533,13 +534,13 @@
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
{
PausingHttpFetcherTestDelegate delegate;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
delegate.paused_ = false;
delegate.loop_ = loop;
delegate.fetcher_ = fetcher.get();
fetcher->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
guint callback_id = g_timeout_add(kHttpResponseInternalServerError,
@@ -580,7 +581,7 @@
}
bool once_;
bool callback_once_;
- scoped_ptr<HttpFetcher> fetcher_;
+ unique_ptr<HttpFetcher> fetcher_;
GMainLoop* loop_;
};
@@ -607,7 +608,7 @@
delegate.loop_ = loop;
delegate.fetcher_->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
this->test_.IgnoreServerAborting(server.get());
ASSERT_TRUE(server->started_);
@@ -653,10 +654,10 @@
{
FlakyHttpFetcherTestDelegate delegate;
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
StartTransferArgs start_xfer_args = {
@@ -731,7 +732,7 @@
{
FailureHttpFetcherTestDelegate delegate(nullptr);
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
StartTransferArgs start_xfer_args = {
@@ -762,7 +763,7 @@
// Handles destruction and claims ownership.
FailureHttpFetcherTestDelegate delegate(server);
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewSmallFetcher());
fetcher->set_delegate(&delegate);
StartTransferArgs start_xfer_args = {
@@ -822,7 +823,7 @@
{
RedirectHttpFetcherTestDelegate delegate(expected_successful);
delegate.loop_ = loop;
- scoped_ptr<HttpFetcher> fetcher(http_fetcher);
+ unique_ptr<HttpFetcher> fetcher(http_fetcher);
fetcher->set_delegate(&delegate);
StartTransferArgs start_xfer_args =
@@ -847,7 +848,7 @@
if (this->test_.IsMock())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
for (size_t c = 0; c < arraysize(kRedirectCodes); ++c) {
@@ -862,7 +863,7 @@
if (this->test_.IsMock())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
string url;
@@ -878,7 +879,7 @@
if (this->test_.IsMock())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
string url;
@@ -916,7 +917,7 @@
ADD_FAILURE();
}
- scoped_ptr<HttpFetcher> fetcher_;
+ unique_ptr<HttpFetcher> fetcher_;
int expected_response_code_;
string data;
GMainLoop* loop_;
@@ -971,7 +972,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -989,7 +990,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -1006,7 +1007,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -1024,7 +1025,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -1050,7 +1051,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -1072,7 +1073,7 @@
if (!this->test_.IsMulti())
return;
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
vector<pair<off_t, off_t>> ranges;
@@ -1114,7 +1115,7 @@
return;
for (int i = 0; i < 2; i++) {
- scoped_ptr<HttpServer> server(this->test_.CreateServer());
+ unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
@@ -1123,7 +1124,7 @@
delegate.loop_ = loop;
bool is_allowed = (i != 0);
- scoped_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
+ unique_ptr<HttpFetcher> fetcher(this->test_.NewLargeFetcher());
bool is_official_build = (i == 1);
LOG(INFO) << "is_update_allowed_over_connection: " << is_allowed;