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

Unified Diff: google_apis/drive/base_requests.cc

Issue 1873663002: Convert //google_apis from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « google_apis/drive/base_requests.h ('k') | google_apis/drive/base_requests_server_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/drive/base_requests.cc
diff --git a/google_apis/drive/base_requests.cc b/google_apis/drive/base_requests.cc
index 8a4e38b42b00850e1720073b63a14a1dd2c7d037..cfa47b24d2ad20b8654f983bcfd74e4946a85679 100644
--- a/google_apis/drive/base_requests.cc
+++ b/google_apis/drive/base_requests.cc
@@ -5,6 +5,7 @@
#include "google_apis/drive/base_requests.h"
#include <stddef.h>
+
#include <utility>
#include "base/files/file_util.h"
@@ -12,6 +13,7 @@
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
@@ -82,7 +84,7 @@ const char kMultipartFooterFormat[] = "--%s--";
void ParseJsonOnBlockingPool(
base::TaskRunner* blocking_task_runner,
const std::string& json,
- const base::Callback<void(scoped_ptr<base::Value> value)>& callback) {
+ const base::Callback<void(std::unique_ptr<base::Value> value)>& callback) {
base::PostTaskAndReplyWithResult(
blocking_task_runner,
FROM_HERE,
@@ -151,7 +153,7 @@ google_apis::DriveApiErrorCode MapJsonError(
const char kErrorReasonQuotaExceeded[] = "quotaExceeded";
const char kErrorReasonResponseTooLarge[] = "responseTooLarge";
- scoped_ptr<const base::Value> value(google_apis::ParseJson(error_body));
+ std::unique_ptr<const base::Value> value(google_apis::ParseJson(error_body));
const base::DictionaryValue* dictionary = NULL;
const base::DictionaryValue* error = NULL;
if (value &&
@@ -187,10 +189,10 @@ google_apis::DriveApiErrorCode MapJsonError(
namespace google_apis {
-scoped_ptr<base::Value> ParseJson(const std::string& json) {
+std::unique_ptr<base::Value> ParseJson(const std::string& json) {
int error_code = -1;
std::string error_message;
- scoped_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
+ std::unique_ptr<base::Value> value = base::JSONReader::ReadAndReturnError(
json, base::JSON_PARSE_RFC, &error_code, &error_message);
if (!value.get()) {
@@ -291,9 +293,8 @@ int ResponseWriter::Write(net::IOBuffer* buffer,
int num_bytes,
const net::CompletionCallback& callback) {
if (!get_content_callback_.is_null()) {
- get_content_callback_.Run(
- HTTP_SUCCESS,
- make_scoped_ptr(new std::string(buffer->data(), num_bytes)));
+ get_content_callback_.Run(HTTP_SUCCESS, base::WrapUnique(new std::string(
+ buffer->data(), num_bytes)));
Roger Tawa OOO till Jul 10th 2016/04/08 15:03:33 Line formatting does not seem right here.
dcheng 2016/04/08 17:27:26 This is technically compliant to the style guide:
}
if (file_writer_) {
@@ -417,7 +418,7 @@ void UrlFetchRequestBase::StartAfterPrepare(
output_file_path,
get_content_callback);
url_fetcher_->SaveResponseWithWriter(
- scoped_ptr<net::URLFetcherResponseWriter>(response_writer_));
+ std::unique_ptr<net::URLFetcherResponseWriter>(response_writer_));
// Add request headers.
// Note that SetExtraRequestHeaders clears the current headers and sets it
@@ -703,10 +704,9 @@ void UploadRangeRequestBase::ProcessURLFetchResults(
// should be always 0.
DCHECK_EQ(start_position_received, 0);
- OnRangeRequestComplete(UploadRangeResponse(code,
- start_position_received,
+ OnRangeRequestComplete(UploadRangeResponse(code, start_position_received,
end_position_received),
- scoped_ptr<base::Value>());
+ std::unique_ptr<base::Value>());
OnProcessURLFetchResultsComplete();
} else if (code == HTTP_CREATED || code == HTTP_SUCCESS) {
@@ -719,14 +719,14 @@ void UploadRangeRequestBase::ProcessURLFetchResults(
code));
} else {
// Failed to upload. Run callbacks to notify the error.
- OnRangeRequestComplete(
- UploadRangeResponse(code, -1, -1), scoped_ptr<base::Value>());
+ OnRangeRequestComplete(UploadRangeResponse(code, -1, -1),
+ std::unique_ptr<base::Value>());
OnProcessURLFetchResultsComplete();
}
}
void UploadRangeRequestBase::OnDataParsed(DriveApiErrorCode code,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK(CalledOnValidThread());
DCHECK(code == HTTP_CREATED || code == HTTP_SUCCESS);
@@ -736,8 +736,8 @@ void UploadRangeRequestBase::OnDataParsed(DriveApiErrorCode code,
void UploadRangeRequestBase::RunCallbackOnPrematureFailure(
DriveApiErrorCode code) {
- OnRangeRequestComplete(
- UploadRangeResponse(code, 0, 0), scoped_ptr<base::Value>());
+ OnRangeRequestComplete(UploadRangeResponse(code, 0, 0),
+ std::unique_ptr<base::Value>());
}
//========================== ResumeUploadRequestBase =========================
@@ -923,7 +923,7 @@ void MultipartUploadRequestBase::NotifyResult(
}
void MultipartUploadRequestBase::NotifyError(DriveApiErrorCode code) {
- callback_.Run(code, scoped_ptr<FileResource>());
+ callback_.Run(code, std::unique_ptr<FileResource>());
}
void MultipartUploadRequestBase::NotifyUploadProgress(
@@ -937,7 +937,7 @@ void MultipartUploadRequestBase::NotifyUploadProgress(
void MultipartUploadRequestBase::OnDataParsed(
DriveApiErrorCode code,
const base::Closure& notify_complete_callback,
- scoped_ptr<base::Value> value) {
+ std::unique_ptr<base::Value> value) {
DCHECK(thread_checker_.CalledOnValidThread());
if (value)
callback_.Run(code, google_apis::FileResource::CreateFrom(*value));
« no previous file with comments | « google_apis/drive/base_requests.h ('k') | google_apis/drive/base_requests_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698