| Index: storage/browser/blob/blob_storage_context.cc
|
| diff --git a/webkit/browser/blob/blob_storage_context.cc b/storage/browser/blob/blob_storage_context.cc
|
| similarity index 81%
|
| rename from webkit/browser/blob/blob_storage_context.cc
|
| rename to storage/browser/blob/blob_storage_context.cc
|
| index f62a26dbe545aed3ab1bd27c1d6a83096670cd7e..b8ad724328a98e9d1bbedfc3e7a0244c78d99a21 100644
|
| --- a/webkit/browser/blob/blob_storage_context.cc
|
| +++ b/storage/browser/blob/blob_storage_context.cc
|
| @@ -2,17 +2,17 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/browser/blob/blob_storage_context.h"
|
| +#include "storage/browser/blob/blob_storage_context.h"
|
|
|
| #include "base/bind.h"
|
| #include "base/location.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| #include "url/gurl.h"
|
| -#include "webkit/browser/blob/blob_data_handle.h"
|
| -#include "webkit/common/blob/blob_data.h"
|
| +#include "storage/browser/blob/blob_data_handle.h"
|
| +#include "storage/common/blob/blob_data.h"
|
|
|
| -namespace webkit_blob {
|
| +namespace storage {
|
|
|
| namespace {
|
|
|
| @@ -38,20 +38,19 @@ static const int64 kMaxMemoryUsage = 500 * 1024 * 1024; // Half a gig.
|
|
|
| } // namespace
|
|
|
| -BlobStorageContext::BlobMapEntry::BlobMapEntry()
|
| - : refcount(0), flags(0) {
|
| +BlobStorageContext::BlobMapEntry::BlobMapEntry() : refcount(0), flags(0) {
|
| }
|
|
|
| -BlobStorageContext::BlobMapEntry::BlobMapEntry(
|
| - int refcount, int flags, BlobData* data)
|
| +BlobStorageContext::BlobMapEntry::BlobMapEntry(int refcount,
|
| + int flags,
|
| + BlobData* data)
|
| : refcount(refcount), flags(flags), data(data) {
|
| }
|
|
|
| BlobStorageContext::BlobMapEntry::~BlobMapEntry() {
|
| }
|
|
|
| -BlobStorageContext::BlobStorageContext()
|
| - : memory_usage_(0) {
|
| +BlobStorageContext::BlobStorageContext() : memory_usage_(0) {
|
| }
|
|
|
| BlobStorageContext::~BlobStorageContext() {
|
| @@ -73,8 +72,8 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromUUID(
|
|
|
| scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL(
|
| const GURL& url) {
|
| - BlobURLMap::iterator found = public_blob_urls_.find(
|
| - BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url);
|
| + BlobURLMap::iterator found =
|
| + public_blob_urls_.find(BlobUrlHasRef(url) ? ClearBlobUrlRef(url) : url);
|
| if (found == public_blob_urls_.end())
|
| return scoped_ptr<BlobDataHandle>();
|
| return GetBlobDataFromUUID(found->second);
|
| @@ -83,9 +82,9 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::GetBlobDataFromPublicURL(
|
| scoped_ptr<BlobDataHandle> BlobStorageContext::AddFinishedBlob(
|
| const BlobData* data) {
|
| StartBuildingBlob(data->uuid());
|
| - for (std::vector<BlobData::Item>::const_iterator iter =
|
| - data->items().begin();
|
| - iter != data->items().end(); ++iter) {
|
| + for (std::vector<BlobData::Item>::const_iterator iter = data->items().begin();
|
| + iter != data->items().end();
|
| + ++iter) {
|
| AppendBlobDataItem(data->uuid(), *iter);
|
| }
|
| FinishBuildingBlob(data->uuid(), data->content_type());
|
| @@ -94,8 +93,8 @@ scoped_ptr<BlobDataHandle> BlobStorageContext::AddFinishedBlob(
|
| return handle.Pass();
|
| }
|
|
|
| -bool BlobStorageContext::RegisterPublicBlobURL(
|
| - const GURL& blob_url, const std::string& uuid) {
|
| +bool BlobStorageContext::RegisterPublicBlobURL(const GURL& blob_url,
|
| + const std::string& uuid) {
|
| DCHECK(!BlobUrlHasRef(blob_url));
|
| DCHECK(IsInUse(uuid));
|
| DCHECK(!IsUrlRegistered(blob_url));
|
| @@ -119,8 +118,8 @@ void BlobStorageContext::StartBuildingBlob(const std::string& uuid) {
|
| blob_map_[uuid] = BlobMapEntry(1, BEING_BUILT, new BlobData(uuid));
|
| }
|
|
|
| -void BlobStorageContext::AppendBlobDataItem(
|
| - const std::string& uuid, const BlobData::Item& item) {
|
| +void BlobStorageContext::AppendBlobDataItem(const std::string& uuid,
|
| + const BlobData::Item& item) {
|
| DCHECK(IsBeingBuilt(uuid));
|
| BlobMap::iterator found = blob_map_.find(uuid);
|
| if (found == blob_map_.end())
|
| @@ -168,10 +167,9 @@ void BlobStorageContext::AppendBlobDataItem(
|
| case BlobData::Item::TYPE_BLOB: {
|
| scoped_ptr<BlobDataHandle> src = GetBlobDataFromUUID(item.blob_uuid());
|
| if (src)
|
| - exceeded_memory = !ExpandStorageItems(target_blob_data,
|
| - src->data(),
|
| - item.offset(),
|
| - item.length());
|
| + exceeded_memory =
|
| + !ExpandStorageItems(
|
| + target_blob_data, src->data(), item.offset(), item.length());
|
| break;
|
| }
|
| default:
|
| @@ -190,8 +188,8 @@ void BlobStorageContext::AppendBlobDataItem(
|
| }
|
| }
|
|
|
| -void BlobStorageContext::FinishBuildingBlob(
|
| - const std::string& uuid, const std::string& content_type) {
|
| +void BlobStorageContext::FinishBuildingBlob(const std::string& uuid,
|
| + const std::string& content_type) {
|
| DCHECK(IsBeingBuilt(uuid));
|
| BlobMap::iterator found = blob_map_.find(uuid);
|
| if (found == blob_map_.end())
|
| @@ -225,9 +223,10 @@ void BlobStorageContext::DecrementBlobRefCount(const std::string& uuid) {
|
| }
|
| }
|
|
|
| -bool BlobStorageContext::ExpandStorageItems(
|
| - BlobData* target_blob_data, BlobData* src_blob_data,
|
| - uint64 offset, uint64 length) {
|
| +bool BlobStorageContext::ExpandStorageItems(BlobData* target_blob_data,
|
| + BlobData* src_blob_data,
|
| + uint64 offset,
|
| + uint64 length) {
|
| DCHECK(target_blob_data && src_blob_data &&
|
| length != static_cast<uint64>(-1));
|
|
|
| @@ -272,8 +271,9 @@ bool BlobStorageContext::ExpandStorageItems(
|
| return true;
|
| }
|
|
|
| -bool BlobStorageContext::AppendBytesItem(
|
| - BlobData* target_blob_data, const char* bytes, int64 length) {
|
| +bool BlobStorageContext::AppendBytesItem(BlobData* target_blob_data,
|
| + const char* bytes,
|
| + int64 length) {
|
| if (length < 0) {
|
| DCHECK(false);
|
| return false;
|
| @@ -287,10 +287,12 @@ bool BlobStorageContext::AppendBytesItem(
|
|
|
| void BlobStorageContext::AppendFileItem(
|
| BlobData* target_blob_data,
|
| - const base::FilePath& file_path, uint64 offset, uint64 length,
|
| + const base::FilePath& file_path,
|
| + uint64 offset,
|
| + uint64 length,
|
| const base::Time& expected_modification_time) {
|
| - target_blob_data->AppendFile(file_path, offset, length,
|
| - expected_modification_time);
|
| + target_blob_data->AppendFile(
|
| + file_path, offset, length, expected_modification_time);
|
|
|
| // It may be a temporary file that should be deleted when no longer needed.
|
| scoped_refptr<ShareableFileReference> shareable_file =
|
| @@ -301,10 +303,12 @@ void BlobStorageContext::AppendFileItem(
|
|
|
| void BlobStorageContext::AppendFileSystemFileItem(
|
| BlobData* target_blob_data,
|
| - const GURL& filesystem_url, uint64 offset, uint64 length,
|
| + const GURL& filesystem_url,
|
| + uint64 offset,
|
| + uint64 length,
|
| const base::Time& expected_modification_time) {
|
| - target_blob_data->AppendFileSystemFile(filesystem_url, offset, length,
|
| - expected_modification_time);
|
| + target_blob_data->AppendFileSystemFile(
|
| + filesystem_url, offset, length, expected_modification_time);
|
| }
|
|
|
| bool BlobStorageContext::IsInUse(const std::string& uuid) {
|
| @@ -322,4 +326,4 @@ bool BlobStorageContext::IsUrlRegistered(const GURL& blob_url) {
|
| return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
|
| }
|
|
|
| -} // namespace webkit_blob
|
| +} // namespace storage
|
|
|