Skip to content

Commit

Permalink
[AW] Fix presubmit errors: use nullptr and make_unique.
Browse files Browse the repository at this point in the history
This patch addresses the following issues:
 - presubmit prefers to have a nullptr instead of "std::unique_ptr<T>()".
 - also use make_unique instead of creating unique_ptr directly (via a
   pointer created with new), which is also preferred by presubmit.

BUG=993812

Change-Id: I930f235dad3d6b9f93670b9ec957d0bc71889ea4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1754163
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686854}
  • Loading branch information
Tim Volodine authored and Commit Bot committed Aug 14, 2019
1 parent b4bb5b9 commit 60ec12d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions android_webview/browser/aw_contents_io_thread_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,20 +436,21 @@ std::unique_ptr<AwWebResourceResponse> RunShouldInterceptRequest(
RecordInterceptedScheme(ret.is_null(), request.url);

if (ret.is_null())
return std::unique_ptr<AwWebResourceResponse>(nullptr);
return nullptr;

AwWebResourceResponse* response = new AwWebResourceResponse(ret);
std::unique_ptr<AwWebResourceResponse> response =
std::make_unique<AwWebResourceResponse>(ret);
if (!response->HasInputStream(env)) {
// Only record UMA for cases where the input stream is null (see
// crbug.com/974273).
RecordResponseStatusCode(env, response);
RecordResponseStatusCode(env, response.get());
}

return std::unique_ptr<AwWebResourceResponse>(response);
return response;
}

std::unique_ptr<AwWebResourceResponse> ReturnNull() {
return std::unique_ptr<AwWebResourceResponse>();
return nullptr;
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ std::unique_ptr<InputStream> AwWebResourceResponse::GetInputStream(
DCHECK(!input_stream_transferred_);

if (input_stream_transferred_)
return std::unique_ptr<InputStream>();
return nullptr;

input_stream_transferred_ = true;
ScopedJavaLocalRef<jobject> jstream =
Java_AwWebResourceResponse_getData(env, java_object_);
if (jstream.is_null())
return std::unique_ptr<InputStream>();
return nullptr;
return std::make_unique<InputStream>(jstream);
}

Expand Down

0 comments on commit 60ec12d

Please sign in to comment.