Skip to content

Commit

Permalink
Convert Pass()→std::move() in //storage
Browse files Browse the repository at this point in the history
❆(੭ु ◜◡‾)੭ु⁾☃❆

BUG=557422
[email protected]
[email protected]

Review URL: https://codereview.chromium.org/1546243002

Cr-Commit-Position: refs/heads/master@{#366944}
  • Loading branch information
zetafunction authored and Commit bot committed Dec 27, 2015
1 parent 424dfa5 commit dae4925
Show file tree
Hide file tree
Showing 24 changed files with 143 additions and 151 deletions.
24 changes: 12 additions & 12 deletions storage/browser/blob/blob_data_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <stddef.h>
#include <stdint.h>
#include <utility>

#include "base/numerics/safe_conversions.h"
#include "base/numerics/safe_math.h"
Expand Down Expand Up @@ -57,14 +58,14 @@ void BlobDataBuilder::AppendData(const char* data, size_t length) {
return;
scoped_ptr<DataElement> element(new DataElement());
element->SetToBytes(data, length);
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
}

size_t BlobDataBuilder::AppendFutureData(size_t length) {
CHECK_NE(length, 0u);
scoped_ptr<DataElement> element(new DataElement());
element->SetToBytesDescription(length);
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
return items_.size() - 1;
}

Expand Down Expand Up @@ -107,7 +108,7 @@ size_t BlobDataBuilder::AppendFutureFile(uint64_t offset, uint64_t length) {
element->SetToFilePathRange(base::FilePath::FromUTF8Unsafe(std::string(
kAppendFutureFileTemporaryFileName)),
offset, length, base::Time());
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
return items_.size() - 1;
}

Expand All @@ -131,7 +132,7 @@ bool BlobDataBuilder::PopulateFutureFile(
scoped_ptr<DataElement> element(new DataElement());
element->SetToFilePathRange(file_reference->path(), offset, length,
expected_modification_time);
items_[index] = new BlobDataItem(element.Pass(), file_reference);
items_[index] = new BlobDataItem(std::move(element), file_reference);
return true;
}

Expand All @@ -142,8 +143,8 @@ void BlobDataBuilder::AppendFile(const base::FilePath& file_path,
scoped_ptr<DataElement> element(new DataElement());
element->SetToFilePathRange(file_path, offset, length,
expected_modification_time);
items_.push_back(
new BlobDataItem(element.Pass(), ShareableFileReference::Get(file_path)));
items_.push_back(new BlobDataItem(std::move(element),
ShareableFileReference::Get(file_path)));
}

void BlobDataBuilder::AppendBlob(const std::string& uuid,
Expand All @@ -152,13 +153,13 @@ void BlobDataBuilder::AppendBlob(const std::string& uuid,
DCHECK_GT(length, 0ul);
scoped_ptr<DataElement> element(new DataElement());
element->SetToBlobRange(uuid, offset, length);
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
}

void BlobDataBuilder::AppendBlob(const std::string& uuid) {
scoped_ptr<DataElement> element(new DataElement());
element->SetToBlob(uuid);
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
}

void BlobDataBuilder::AppendFileSystemFile(
Expand All @@ -170,7 +171,7 @@ void BlobDataBuilder::AppendFileSystemFile(
scoped_ptr<DataElement> element(new DataElement());
element->SetToFileSystemUrlRange(url, offset, length,
expected_modification_time);
items_.push_back(new BlobDataItem(element.Pass()));
items_.push_back(new BlobDataItem(std::move(element)));
}

void BlobDataBuilder::AppendDiskCacheEntry(
Expand All @@ -180,9 +181,8 @@ void BlobDataBuilder::AppendDiskCacheEntry(
scoped_ptr<DataElement> element(new DataElement());
element->SetToDiskCacheEntryRange(
0U, disk_cache_entry->GetDataSize(disk_cache_stream_index));
items_.push_back(
new BlobDataItem(element.Pass(), data_handle, disk_cache_entry,
disk_cache_stream_index));
items_.push_back(new BlobDataItem(std::move(element), data_handle,
disk_cache_entry, disk_cache_stream_index));
}

void BlobDataBuilder::Clear() {
Expand Down
12 changes: 4 additions & 8 deletions storage/browser/blob/blob_data_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ class FileStreamReaderProviderImpl
int64_t max_bytes_to_read,
const base::Time& expected_modification_time) override {
return file_system_context_->CreateFileStreamReader(
storage::FileSystemURL(
file_system_context_->CrackURL(
filesystem_url)),
offset, max_bytes_to_read,
expected_modification_time)
.Pass();
storage::FileSystemURL(file_system_context_->CrackURL(filesystem_url)),
offset, max_bytes_to_read, expected_modification_time);
}

private:
Expand Down Expand Up @@ -85,7 +81,7 @@ scoped_ptr<BlobReader> BlobDataHandle::CreateReader(

scoped_ptr<BlobDataSnapshot>
BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const {
return context_->CreateSnapshot(uuid_).Pass();
return context_->CreateSnapshot(uuid_);
}

BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() {
Expand Down Expand Up @@ -121,7 +117,7 @@ BlobDataHandle::~BlobDataHandle() {

scoped_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
return shared_->CreateSnapshot().Pass();
return shared_->CreateSnapshot();
}

const std::string& BlobDataHandle::uuid() const {
Expand Down
17 changes: 8 additions & 9 deletions storage/browser/blob/blob_data_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@

#include "storage/browser/blob/blob_data_item.h"

#include <utility>

namespace storage {

BlobDataItem::DataHandle::~DataHandle() {
}

BlobDataItem::BlobDataItem(scoped_ptr<DataElement> item)
: item_(item.Pass()),
: item_(std::move(item)),
disk_cache_entry_(nullptr),
disk_cache_stream_index_(-1) {
}
disk_cache_stream_index_(-1) {}

BlobDataItem::BlobDataItem(scoped_ptr<DataElement> item,
const scoped_refptr<DataHandle>& data_handle)
: item_(item.Pass()),
: item_(std::move(item)),
data_handle_(data_handle),
disk_cache_entry_(nullptr),
disk_cache_stream_index_(-1) {
}
disk_cache_stream_index_(-1) {}

BlobDataItem::BlobDataItem(scoped_ptr<DataElement> item,
const scoped_refptr<DataHandle>& data_handle,
disk_cache::Entry* entry,
int disk_cache_stream_index)
: item_(item.Pass()),
: item_(std::move(item)),
data_handle_(data_handle),
disk_cache_entry_(entry),
disk_cache_stream_index_(disk_cache_stream_index) {
}
disk_cache_stream_index_(disk_cache_stream_index) {}

BlobDataItem::~BlobDataItem() {}

Expand Down
26 changes: 11 additions & 15 deletions storage/browser/blob/blob_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <limits>
#include <utility>

#include "base/bind.h"
#include "base/sequenced_task_runner.h"
Expand Down Expand Up @@ -44,12 +44,12 @@ BlobReader::BlobReader(
const BlobDataHandle* blob_handle,
scoped_ptr<FileStreamReaderProvider> file_stream_provider,
base::SequencedTaskRunner* file_task_runner)
: file_stream_provider_(file_stream_provider.Pass()),
: file_stream_provider_(std::move(file_stream_provider)),
file_task_runner_(file_task_runner),
net_error_(net::OK),
weak_factory_(this) {
if (blob_handle) {
blob_data_ = blob_handle->CreateSnapshot().Pass();
blob_data_ = blob_handle->CreateSnapshot();
}
}

Expand Down Expand Up @@ -527,19 +527,15 @@ scoped_ptr<FileStreamReader> BlobReader::CreateFileStreamReader(
switch (item.type()) {
case DataElement::TYPE_FILE:
return file_stream_provider_->CreateForLocalFile(
file_task_runner_.get(), item.path(),
item.offset() + additional_offset,
item.expected_modification_time())
.Pass();
file_task_runner_.get(), item.path(),
item.offset() + additional_offset, item.expected_modification_time());
case DataElement::TYPE_FILE_FILESYSTEM:
return file_stream_provider_
->CreateFileStreamReader(
item.filesystem_url(), item.offset() + additional_offset,
item.length() == std::numeric_limits<uint64_t>::max()
? storage::kMaximumLength
: item.length() - additional_offset,
item.expected_modification_time())
.Pass();
return file_stream_provider_->CreateFileStreamReader(
item.filesystem_url(), item.offset() + additional_offset,
item.length() == std::numeric_limits<uint64_t>::max()
? storage::kMaximumLength
: item.length() - additional_offset,
item.expected_modification_time());
case DataElement::TYPE_BLOB:
case DataElement::TYPE_BYTES:
case DataElement::TYPE_BYTES_DESCRIPTION:
Expand Down
26 changes: 13 additions & 13 deletions storage/browser/blob/blob_storage_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <limits>
#include <utility>

#include "base/bind.h"
#include "base/location.h"
Expand Down Expand Up @@ -75,15 +75,15 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromUUID(
scoped_ptr<BlobDataHandle> result;
BlobMap::iterator found = blob_map_.find(uuid);
if (found == blob_map_.end())
return result.Pass();
return result;
auto* entry = found->second;
if (entry->flags & EXCEEDED_MEMORY)
return result.Pass();
return result;
DCHECK(!entry->IsBeingBuilt());
result.reset(new BlobDataHandle(uuid, entry->data->content_type(),
entry->data->content_disposition(), this,
base::ThreadTaskRunnerHandle::Get().get()));
return result.Pass();
return result;
}

scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL(
Expand Down Expand Up @@ -119,7 +119,7 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::AddFinishedBlob(
scoped_ptr<BlobDataHandle> handle =
GetBlobDataFromUUID(external_builder.uuid_);
DecrementBlobRefCount(external_builder.uuid_);
return handle.Pass();
return handle;
}

scoped_ptr<BlobDataHandle> BlobStorageContext::AddFinishedBlob(
Expand Down Expand Up @@ -273,25 +273,25 @@ scoped_refptr<BlobDataItem> BlobStorageContext::AllocateBlobItem(
case DataElement::TYPE_BYTES:
DCHECK(!ipc_data.offset());
element->SetToBytes(ipc_data.bytes(), length);
blob_item = new BlobDataItem(element.Pass());
blob_item = new BlobDataItem(std::move(element));
break;
case DataElement::TYPE_FILE:
element->SetToFilePathRange(ipc_data.path(), ipc_data.offset(), length,
ipc_data.expected_modification_time());
blob_item = new BlobDataItem(
element.Pass(), ShareableFileReference::Get(ipc_data.path()));
std::move(element), ShareableFileReference::Get(ipc_data.path()));
break;
case DataElement::TYPE_FILE_FILESYSTEM:
element->SetToFileSystemUrlRange(ipc_data.filesystem_url(),
ipc_data.offset(), length,
ipc_data.expected_modification_time());
blob_item = new BlobDataItem(element.Pass());
blob_item = new BlobDataItem(std::move(element));
break;
case DataElement::TYPE_BLOB:
// This is a temporary item that will be deconstructed later.
element->SetToBlobRange(ipc_data.blob_uuid(), ipc_data.offset(),
ipc_data.length());
blob_item = new BlobDataItem(element.Pass());
blob_item = new BlobDataItem(std::move(element));
break;
case DataElement::TYPE_DISK_CACHE_ENTRY: // This type can't be sent by IPC.
NOTREACHED();
Expand Down Expand Up @@ -447,7 +447,7 @@ bool BlobStorageContext::AppendBlob(
static_cast<int64_t>(new_length));
memory_usage_ += new_length;
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
target_blob_uuid, new BlobDataItem(element.Pass())));
target_blob_uuid, new BlobDataItem(std::move(element))));
} break;
case DataElement::TYPE_FILE: {
DCHECK_NE(item.length(), std::numeric_limits<uint64_t>::max())
Expand All @@ -460,7 +460,7 @@ bool BlobStorageContext::AppendBlob(
item.expected_modification_time());
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
target_blob_uuid,
new BlobDataItem(element.Pass(), item.data_handle_)));
new BlobDataItem(std::move(element), item.data_handle_)));
} break;
case DataElement::TYPE_FILE_FILESYSTEM: {
UMA_HISTOGRAM_COUNTS("Storage.BlobItemSize.BlobSlice.FileSystem",
Expand All @@ -470,15 +470,15 @@ bool BlobStorageContext::AppendBlob(
item.offset() + offset, new_length,
item.expected_modification_time());
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
target_blob_uuid, new BlobDataItem(element.Pass())));
target_blob_uuid, new BlobDataItem(std::move(element))));
} break;
case DataElement::TYPE_DISK_CACHE_ENTRY: {
scoped_ptr<DataElement> element(new DataElement());
element->SetToDiskCacheEntryRange(item.offset() + offset,
new_length);
target_blob_builder->AppendSharedBlobItem(new ShareableBlobDataItem(
target_blob_uuid,
new BlobDataItem(element.Pass(), item.data_handle_,
new BlobDataItem(std::move(element), item.data_handle_,
item.disk_cache_entry(),
item.disk_cache_stream_index())));
} break;
Expand Down
8 changes: 5 additions & 3 deletions storage/browser/blob/blob_url_request_job_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "storage/browser/blob/blob_url_request_job_factory.h"

#include <utility>

#include "base/strings/string_util.h"
#include "net/base/request_priority.h"
#include "net/url_request/url_request_context.h"
Expand All @@ -28,8 +30,8 @@ scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest(
const GURL kBlobUrl("blob://see_user_data/");
scoped_ptr<net::URLRequest> request = request_context->CreateRequest(
kBlobUrl, net::DEFAULT_PRIORITY, request_delegate);
SetRequestedBlobDataHandle(request.get(), blob_data_handle.Pass());
return request.Pass();
SetRequestedBlobDataHandle(request.get(), std::move(blob_data_handle));
return request;
}

// static
Expand Down Expand Up @@ -84,7 +86,7 @@ BlobDataHandle* BlobProtocolHandler::LookupBlobHandle(
scoped_ptr<BlobDataHandle> handle = context_->GetBlobDataFromUUID(uuid);
BlobDataHandle* handle_ptr = handle.get();
if (handle) {
SetRequestedBlobDataHandle(request, handle.Pass());
SetRequestedBlobDataHandle(request, std::move(handle));
}
return handle_ptr;
}
Expand Down
3 changes: 2 additions & 1 deletion storage/browser/blob/internal_blob_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "storage/browser/blob/internal_blob_data.h"

#include <stddef.h>
#include <utility>

#include "base/containers/hash_tables.h"
#include "base/metrics/histogram.h"
Expand Down Expand Up @@ -50,7 +51,7 @@ size_t InternalBlobData::Builder::GetNonsharedMemoryUsage() const {

scoped_ptr<InternalBlobData> InternalBlobData::Builder::Build() {
DCHECK(data_);
return data_.Pass();
return std::move(data_);
}

InternalBlobData::InternalBlobData() {
Expand Down
5 changes: 3 additions & 2 deletions storage/browser/blob/shareable_file_reference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "storage/browser/blob/shareable_file_reference.h"

#include <map>
#include <utility>

#include "base/lazy_instance.h"
#include "base/macros.h"
Expand Down Expand Up @@ -97,7 +98,7 @@ scoped_refptr<ShareableFileReference> ShareableFileReference::GetOrCreate(

// Wasn't in the map, create a new reference and store the pointer.
scoped_refptr<ShareableFileReference> reference(
new ShareableFileReference(scoped_file.Pass()));
new ShareableFileReference(std::move(scoped_file)));
result.first->second = reference.get();
return reference;
}
Expand All @@ -109,7 +110,7 @@ void ShareableFileReference::AddFinalReleaseCallback(
}

ShareableFileReference::ShareableFileReference(ScopedFile scoped_file)
: scoped_file_(scoped_file.Pass()) {
: scoped_file_(std::move(scoped_file)) {
DCHECK(g_file_map.Get().Find(path())->second == NULL);
}

Expand Down
Loading

0 comments on commit dae4925

Please sign in to comment.