Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1037)

Unified Diff: webkit/fileapi/obfuscated_file_util.cc

Issue 10164025: Add UMA stats for ObfuscatedFileUtil::GetDirectoryForOriginAndTypes(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: label rename Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/fileapi/obfuscated_file_util.h ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/obfuscated_file_util.cc
diff --git a/webkit/fileapi/obfuscated_file_util.cc b/webkit/fileapi/obfuscated_file_util.cc
index 2fe4c0f1649726612273daa9ec564306285e17dc..85ff199939f7965cdeba4effcaebd394133c3053 100644
--- a/webkit/fileapi/obfuscated_file_util.cc
+++ b/webkit/fileapi/obfuscated_file_util.cc
@@ -12,6 +12,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
@@ -834,19 +835,34 @@ PlatformFileError ObfuscatedFileUtil::DeleteSingleDirectory(
}
FilePath ObfuscatedFileUtil::GetDirectoryForOriginAndType(
- const GURL& origin, FileSystemType type, bool create) {
- FilePath origin_dir = GetDirectoryForOrigin(origin, create);
+ const GURL& origin,
+ FileSystemType type,
+ bool create,
+ base::PlatformFileError* error_code) {
+ FilePath origin_dir = GetDirectoryForOrigin(origin, create, error_code);
if (origin_dir.empty())
return FilePath();
FilePath::StringType type_string = GetDirectoryNameForType(type);
if (type_string.empty()) {
LOG(WARNING) << "Unknown filesystem type requested:" << type;
+
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL;
return FilePath();
}
FilePath path = origin_dir.Append(type_string);
if (!file_util::DirectoryExists(path) &&
- (!create || !file_util::CreateDirectory(path)))
+ (!create || !file_util::CreateDirectory(path))) {
+ if (error_code) {
+ *error_code = create ?
+ base::PLATFORM_FILE_ERROR_FAILED :
+ base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ }
return FilePath();
+ }
+
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_OK;
return path;
}
@@ -865,7 +881,8 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType(
return false;
FilePath origin_path = origin_type_path.DirName();
- DCHECK_EQ(origin_path.value(), GetDirectoryForOrigin(origin, false).value());
+ DCHECK_EQ(origin_path.value(),
+ GetDirectoryForOrigin(origin, false, NULL).value());
// Delete the origin directory if the deleted one was the last remaining
// type for the origin.
@@ -1212,31 +1229,54 @@ FileSystemDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase(
}
FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
- const GURL& origin, bool create) {
- if (!InitOriginDatabase(create))
+ const GURL& origin, bool create, base::PlatformFileError* error_code) {
+ if (!InitOriginDatabase(create)) {
+ if (error_code) {
+ *error_code = create ?
+ base::PLATFORM_FILE_ERROR_FAILED :
+ base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ }
return FilePath();
+ }
FilePath directory_name;
std::string id = GetOriginIdentifierFromURL(origin);
bool exists_in_db = origin_database_->HasOriginPath(id);
- if (!exists_in_db && !create)
+ if (!exists_in_db && !create) {
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND;
return FilePath();
- if (!origin_database_->GetPathForOrigin(id, &directory_name))
+ }
+ if (!origin_database_->GetPathForOrigin(id, &directory_name)) {
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_FAILED;
return FilePath();
+ }
FilePath path = file_system_directory_.Append(directory_name);
bool exists_in_fs = file_util::DirectoryExists(path);
if (!exists_in_db && exists_in_fs) {
- if (!file_util::Delete(path, true))
+ if (!file_util::Delete(path, true)) {
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_ERROR_FAILED;
return FilePath();
+ }
exists_in_fs = false;
}
if (!exists_in_fs) {
- if (!create || !file_util::CreateDirectory(path))
+ if (!create || !file_util::CreateDirectory(path)) {
+ if (error_code)
+ *error_code = create ?
+ base::PLATFORM_FILE_ERROR_FAILED :
+ base::PLATFORM_FILE_ERROR_NOT_FOUND;
return FilePath();
+ }
}
+ if (error_code)
+ *error_code = base::PLATFORM_FILE_OK;
+
return path;
}
« no previous file with comments | « webkit/fileapi/obfuscated_file_util.h ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698