Chromium Code Reviews| Index: storage/browser/fileapi/plugin_private_file_system_backend.cc | 
| diff --git a/storage/browser/fileapi/plugin_private_file_system_backend.cc b/storage/browser/fileapi/plugin_private_file_system_backend.cc | 
| index 06e9aefb3f1f49a0db1f66b796b502854e998cfb..323c90f9b28bf9d382343533becdbd12a1387dd3 100644 | 
| --- a/storage/browser/fileapi/plugin_private_file_system_backend.cc | 
| +++ b/storage/browser/fileapi/plugin_private_file_system_backend.cc | 
| @@ -266,8 +266,61 @@ int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( | 
| FileSystemContext* context, | 
| const GURL& origin_url, | 
| FileSystemType type) { | 
| - // We don't track usage on this filesystem. | 
| - return 0; | 
| + DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 
| + | 
| + if (!CanHandleType(type)) | 
| + return 0; | 
| + | 
| + int64_t total_size; | 
| + base::Time last_modified_time; | 
| + GetOriginDetailsOnFileTaskRunner(context, origin_url, &total_size, | 
| + &last_modified_time); | 
| + return total_size; | 
| +} | 
| + | 
| +void PluginPrivateFileSystemBackend::GetOriginDetailsOnFileTaskRunner( | 
| + FileSystemContext* context, | 
| + const GURL& origin_url, | 
| + int64_t* total_size, | 
| + base::Time* last_modified_time) { | 
| + DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 
| + | 
| + *total_size = 0; | 
| + *last_modified_time = base::Time::UnixEpoch(); | 
| + std::string fsid = | 
| + storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath( | 
| + storage::kFileSystemTypePluginPrivate, "pluginprivate", | 
| + base::FilePath()); | 
| + DCHECK(storage::ValidateIsolatedFileSystemId(fsid)); | 
| + | 
| + std::string root = storage::GetIsolatedFileSystemRootURIString( | 
| + origin_url, fsid, "pluginprivate"); | 
| + | 
| + std::unique_ptr<FileSystemOperationContext> operation_context( | 
| + new FileSystemOperationContext(context)); | 
| + | 
| + std::vector<std::string> supported_plugins = { | 
| + "application_x-ppapi-widevine-cdm", // Widevine | 
| + "application_x-ppapi-clearkey-cdm", // ClearKey | 
| 
 
nhiroki
2016/09/30 08:34:19
I'd prefer to avoid widevine-specific code from th
 
jrummell
2016/10/03 19:05:47
Done.
 
 | 
| + }; | 
| + | 
| + for (const auto& plugin : supported_plugins) { | 
| + if (OpenFileSystemOnFileTaskRunner( | 
| + obfuscated_file_util(), plugin_map_, origin_url, fsid, plugin, | 
| + storage::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT) == | 
| + base::File::FILE_OK) { | 
| 
 
nhiroki
2016/09/30 08:34:19
nit: Early-continue could be more readable because
 
jrummell
2016/10/03 19:05:47
Done.
 
 | 
| + std::unique_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( | 
| + obfuscated_file_util()->CreateFileEnumerator( | 
| + operation_context.get(), context->CrackURL(GURL(root)), true)); | 
| + | 
| + base::FilePath current; | 
| + while (!(current = enumerator->Next()).empty()) { | 
| + *total_size += enumerator->Size(); | 
| + if (enumerator->LastModifiedTime() > *last_modified_time) | 
| + *last_modified_time = enumerator->LastModifiedTime(); | 
| + } | 
| + } | 
| + } | 
| } | 
| scoped_refptr<QuotaReservation> |