Replace base::MakeUnique() in pdf/
Also use base::ASCIIToUTF16() where appropriate instead of base: :UTF8ToUTF16(). Change-Id: Ia3f86d40bc5f22d1b80dc2fd59fdca8074fd1678 Reviewed-on: https://chromium-review.googlesource.com/706567 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Cr-Commit-Position: refs/heads/master@{#509438}
This commit is contained in:
@ -6,8 +6,8 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
@ -15,7 +15,7 @@ namespace {
|
||||
typedef ChunkStream<10> TestChunkStream;
|
||||
|
||||
std::unique_ptr<TestChunkStream::ChunkData> CreateChunkData() {
|
||||
return base::MakeUnique<TestChunkStream::ChunkData>();
|
||||
return std::make_unique<TestChunkStream::ChunkData>();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/numerics/safe_math.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "pdf/url_loader_wrapper.h"
|
||||
@ -328,7 +328,7 @@ bool DocumentLoader::SaveChunkData(char* input, uint32_t input_size) {
|
||||
bool loading_pending_request = pending_requests_.Contains(chunk_.chunk_index);
|
||||
while (input_size > 0) {
|
||||
if (chunk_.data_size == 0) {
|
||||
chunk_.chunk_data = base::MakeUnique<DataStream::ChunkData>();
|
||||
chunk_.chunk_data = std::make_unique<DataStream::ChunkData>();
|
||||
}
|
||||
const uint32_t new_chunk_data_len =
|
||||
std::min(DataStream::kChunkSize - chunk_.data_size, input_size);
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include <algorithm> // for min/max()
|
||||
#include <cmath> // for log() and pow()
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -404,7 +404,7 @@ bool OutOfProcessInstance::Init(uint32_t argc,
|
||||
// Allow the plugin to handle find requests.
|
||||
SetPluginToHandleFindRequests();
|
||||
|
||||
text_input_ = base::MakeUnique<pp::TextInput_Dev>(this);
|
||||
text_input_ = std::make_unique<pp::TextInput_Dev>(this);
|
||||
|
||||
const char* stream_url = nullptr;
|
||||
const char* original_url = nullptr;
|
||||
@ -1096,7 +1096,7 @@ void OutOfProcessInstance::DidOpen(int32_t result) {
|
||||
|
||||
void OutOfProcessInstance::DidOpenPreview(int32_t result) {
|
||||
if (result == PP_OK) {
|
||||
preview_client_ = base::MakeUnique<PreviewModeClient>(this);
|
||||
preview_client_ = std::make_unique<PreviewModeClient>(this);
|
||||
preview_engine_ = PDFEngine::Create(preview_client_.get());
|
||||
preview_engine_->HandleDocumentLoad(embed_preview_loader_);
|
||||
} else {
|
||||
@ -1294,7 +1294,7 @@ void OutOfProcessInstance::GetDocumentPassword(
|
||||
}
|
||||
|
||||
password_callback_ =
|
||||
base::MakeUnique<pp::CompletionCallbackWithOutput<pp::Var>>(callback);
|
||||
std::make_unique<pp::CompletionCallbackWithOutput<pp::Var>>(callback);
|
||||
pp::VarDictionary message;
|
||||
message.Set(pp::Var(kType), pp::Var(kJSGetPasswordType));
|
||||
PostMessage(message);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
@ -18,7 +19,6 @@
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
@ -679,7 +679,7 @@ void ShutdownSDK() {
|
||||
}
|
||||
|
||||
std::unique_ptr<PDFEngine> PDFEngine::Create(PDFEngine::Client* client) {
|
||||
return base::MakeUnique<PDFiumEngine>(client);
|
||||
return std::make_unique<PDFiumEngine>(client);
|
||||
}
|
||||
|
||||
PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
|
||||
@ -1121,10 +1121,10 @@ bool PDFiumEngine::HandleDocumentLoad(const pp::URLLoader& loader) {
|
||||
password_tries_remaining_ = kMaxPasswordTries;
|
||||
process_when_pending_request_complete_ = true;
|
||||
auto loader_wrapper =
|
||||
base::MakeUnique<URLLoaderWrapperImpl>(GetPluginInstance(), loader);
|
||||
std::make_unique<URLLoaderWrapperImpl>(GetPluginInstance(), loader);
|
||||
loader_wrapper->SetResponseHeaders(headers_);
|
||||
|
||||
doc_loader_ = base::MakeUnique<DocumentLoader>(this);
|
||||
doc_loader_ = std::make_unique<DocumentLoader>(this);
|
||||
if (doc_loader_->Init(std::move(loader_wrapper), url_)) {
|
||||
// request initial data.
|
||||
doc_loader_->RequestData(0, 1);
|
||||
@ -1138,7 +1138,7 @@ pp::Instance* PDFiumEngine::GetPluginInstance() {
|
||||
}
|
||||
|
||||
std::unique_ptr<URLLoaderWrapper> PDFiumEngine::CreateURLLoader() {
|
||||
return base::MakeUnique<URLLoaderWrapperImpl>(GetPluginInstance(),
|
||||
return std::make_unique<URLLoaderWrapperImpl>(GetPluginInstance(),
|
||||
client_->CreateURLLoader());
|
||||
}
|
||||
|
||||
@ -1777,7 +1777,7 @@ bool PDFiumEngine::OnLeftMouseDown(const pp::MouseInputEvent& event) {
|
||||
SetMouseLeftButtonDown(true);
|
||||
|
||||
auto selection_invalidator =
|
||||
base::MakeUnique<SelectionChangeInvalidator>(this);
|
||||
std::make_unique<SelectionChangeInvalidator>(this);
|
||||
selection_.clear();
|
||||
|
||||
int page_index = -1;
|
||||
@ -2494,7 +2494,7 @@ std::string PDFiumEngine::GetSelectedText() {
|
||||
return std::string();
|
||||
|
||||
base::string16 result;
|
||||
base::string16 new_line_char = base::UTF8ToUTF16("\n");
|
||||
base::string16 new_line_char = base::ASCIIToUTF16("\n");
|
||||
for (size_t i = 0; i < selection_.size(); ++i) {
|
||||
if (i > 0 && selection_[i - 1].page_index() > selection_[i].page_index()) {
|
||||
result = selection_[i].GetText() + new_line_char + result;
|
||||
@ -2839,7 +2839,7 @@ void PDFiumEngine::AppendBlankPages(int num_pages) {
|
||||
double height_in_points =
|
||||
ConvertUnitDouble(page_rect.height(), kPixelsPerInch, kPointsPerInch);
|
||||
FPDFPage_New(doc_, i, width_in_points, height_in_points);
|
||||
pages_.push_back(base::MakeUnique<PDFiumPage>(this, i, page_rect, true));
|
||||
pages_.push_back(std::make_unique<PDFiumPage>(this, i, page_rect, true));
|
||||
}
|
||||
|
||||
CalculateVisiblePages();
|
||||
@ -3010,7 +3010,7 @@ void PDFiumEngine::LoadPageInfo(bool reload) {
|
||||
// The page is marked as not being available even if |doc_complete| is
|
||||
// true because FPDFAvail_IsPageAvail() still has to be called for this
|
||||
// page, which will be done in FinishLoadingDocument().
|
||||
pages_.push_back(base::MakeUnique<PDFiumPage>(this, i, page_rect, false));
|
||||
pages_.push_back(std::make_unique<PDFiumPage>(this, i, page_rect, false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3792,7 +3792,7 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc,
|
||||
|
||||
// We need to check depth only to verify our copy of shadow matrix is correct.
|
||||
if (!page_shadow_.get() || page_shadow_->depth() != depth) {
|
||||
page_shadow_ = base::MakeUnique<ShadowMatrix>(
|
||||
page_shadow_ = std::make_unique<ShadowMatrix>(
|
||||
depth, factor, client_->GetBackgroundColor());
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
#include "pdf/url_loader_wrapper_impl.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "net/http/http_util.h"
|
||||
@ -195,7 +196,7 @@ void URLLoaderWrapperImpl::ReadResponseBody(char* buffer,
|
||||
did_read_callback_ = cc;
|
||||
buffer_ = buffer;
|
||||
buffer_size_ = buffer_size;
|
||||
read_starter_ = base::MakeUnique<ReadStarter>(this);
|
||||
read_starter_ = std::make_unique<ReadStarter>(this);
|
||||
}
|
||||
|
||||
void URLLoaderWrapperImpl::ReadResponseBodyImpl() {
|
||||
@ -309,7 +310,7 @@ void URLLoaderWrapperImpl::DidRead(int32_t result) {
|
||||
// Continue receiving.
|
||||
return ReadResponseBodyImpl();
|
||||
}
|
||||
DCHECK(result > 0);
|
||||
DCHECK_GT(result, 0);
|
||||
memmove(buffer_, start, result);
|
||||
|
||||
did_read_callback_.RunAndClear(result);
|
||||
|
Reference in New Issue
Block a user