Commit e0433a1f authored by Daniel Murphy's avatar Daniel Murphy Committed by Commit Bot

[BlobStorage] Adding DVLOG for debugging help

R: pwnall
Bug: 757142, 756754
Change-Id: Id055826191299965eddf8640eb09c640ad3f58c3
Reviewed-on: https://chromium-review.googlesource.com/627019
Commit-Queue: Daniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496487}
parent bd29fbdd
......@@ -121,6 +121,9 @@ void BlobDispatcherHost::OnRegisterBlob(
if (!FileSystemURLIsValid(file_system_context_.get(), filesystem_url) ||
!security_policy->CanReadFileSystemFile(process_id_,
filesystem_url)) {
DVLOG(1) << "BlobDispatcherHost::OnRegisterBlob(" << uuid
<< "): Invalid or prohibited FileSystem URL: "
<< filesystem_url.DebugString();
HostedBlobState hosted_state(
context->AddBrokenBlob(uuid, content_type, content_disposition,
BlobStatus::ERR_FILE_WRITE_FAILED));
......@@ -133,6 +136,9 @@ void BlobDispatcherHost::OnRegisterBlob(
}
case storage::DataElement::TYPE_FILE: {
if (!security_policy->CanReadFile(process_id_, item.path())) {
DVLOG(1) << "BlobDispatcherHost::OnRegisterBlob(" << uuid
<< "): Invalid or prohibited FilePath: "
<< item.path().value();
HostedBlobState hosted_state(
context->AddBrokenBlob(uuid, content_type, content_disposition,
BlobStatus::ERR_FILE_WRITE_FAILED));
......@@ -243,6 +249,8 @@ void BlobDispatcherHost::OnIncrementBlobRefCount(const std::string& uuid) {
return;
}
if (!context->registry().HasEntry(uuid)) {
DVLOG(1) << "BlobDispatcherHost::OnIncrementBlobRefCount(" << uuid
<< "): Unknown UUID.";
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
return;
......@@ -265,6 +273,8 @@ void BlobDispatcherHost::OnDecrementBlobRefCount(const std::string& uuid) {
}
auto state_it = blobs_inuse_map_.find(uuid);
if (state_it == blobs_inuse_map_.end()) {
DVLOG(1) << "BlobDispatcherHost::OnDecrementBlobRefCount(" << uuid
<< "): Unknown UUID.";
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidReference", BDH_DECREMENT,
BDH_TRACING_ENUM_LAST);
return;
......@@ -295,6 +305,9 @@ void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
// on the URL is allowed to be rendered in this process.
if (!public_url.SchemeIsBlob() ||
!security_policy->CanCommitURL(process_id_, public_url)) {
DVLOG(1) << "BlobDispatcherHost::OnRegisterPublicBlobURL("
<< public_url.spec() << ", " << uuid
<< "): Invalid or prohibited URL.";
bad_message::ReceivedBadMessage(this, bad_message::BDH_DISALLOWED_ORIGIN);
return;
}
......@@ -305,6 +318,8 @@ void BlobDispatcherHost::OnRegisterPublicBlobURL(const GURL& public_url,
}
BlobStorageContext* context = this->context();
if (!IsInUseInHost(uuid) || context->registry().IsURLMapped(public_url)) {
DVLOG(1) << "BlobDispatcherHost::OnRegisterPublicBlobURL("
<< public_url.spec() << ", " << uuid << "): Invalid url or uuid.";
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_INCREMENT,
BDH_TRACING_ENUM_LAST);
return;
......@@ -321,6 +336,8 @@ void BlobDispatcherHost::OnRevokePublicBlobURL(const GURL& public_url) {
return;
}
if (!IsUrlRegisteredInHost(public_url)) {
DVLOG(1) << "BlobDispatcherHost::OnRevokePublicBlobURL("
<< public_url.spec() << "): Unknown URL.";
UMA_HISTOGRAM_ENUMERATION("Storage.Blob.InvalidURLRegister", BDH_DECREMENT,
BDH_TRACING_ENUM_LAST);
return;
......
......@@ -641,6 +641,8 @@ void BlobStorageContext::DecrementBlobRefCount(const std::string& uuid) {
DCHECK_GT(entry->refcount(), 0u);
entry->DecrementRefCount();
if (entry->refcount() == 0) {
DVLOG(1) << "BlobStorageContext::DecrementBlobRefCount(" << uuid
<< "): Deleting blob.";
ClearAndFreeMemory(entry);
registry_.DeleteEntry(uuid);
}
......
......@@ -62,6 +62,11 @@ void ScopedFile::Reset() {
iter->second->PostTask(FROM_HERE, base::Bind(iter->first, path_));
}
DVLOG(1) << "ScopedFile::Reset(): "
<< (scope_out_policy_ == DELETE_ON_SCOPE_OUT ? "Deleting "
: "Not deleting ")
<< path_.value();
if (scope_out_policy_ == DELETE_ON_SCOPE_OUT) {
file_task_runner_->PostTask(
FROM_HERE,
......
......@@ -63,6 +63,8 @@ class STORAGE_EXPORT ScopedFile {
// The full file path.
const base::FilePath& path() const { return path_; }
ScopeOutPolicy policy() const { return scope_out_policy_; }
// Releases the file. After calling this, this instance will hold
// an empty file path and scoping out won't make any file deletion
// or callback dispatch. (If an owned pointer is attached to any of
......
......@@ -95,6 +95,14 @@ scoped_refptr<ShareableFileReference> ShareableFileReference::GetOrCreate(
typedef std::pair<ShareableFileMap::iterator, bool> InsertResult;
InsertResult result = g_file_map.Get().Insert(
ShareableFileMap::value_type(scoped_file.path(), nullptr));
DVLOG(1) << "ShareableFileReference::GetOrCreate("
<< scoped_file.path().value() << ", "
<< (scoped_file.policy() == ScopedFile::DELETE_ON_SCOPE_OUT
? "DELETE_ON_SCOPE_OUT"
: "DONT_DELETE_ON_SCOPE_OUT")
<< "): " << (result.second ? "Creation." : "New Reference.");
if (result.second == false) {
scoped_file.Release();
return scoped_refptr<ShareableFileReference>(result.first->second);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment