Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "storage/browser/fileapi/plugin_private_file_system_backend.h" | 5 #include "storage/browser/fileapi/plugin_private_file_system_backend.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 while (!(origin = enumerator->Next()).is_empty()) { | 259 while (!(origin = enumerator->Next()).is_empty()) { |
| 260 if (host == net::GetHostOrSpecFromURL(origin)) | 260 if (host == net::GetHostOrSpecFromURL(origin)) |
| 261 origins->insert(origin); | 261 origins->insert(origin); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( | 265 int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( |
| 266 FileSystemContext* context, | 266 FileSystemContext* context, |
| 267 const GURL& origin_url, | 267 const GURL& origin_url, |
| 268 FileSystemType type) { | 268 FileSystemType type) { |
| 269 // We don't track usage on this filesystem. | 269 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
| 270 return 0; | 270 |
| 271 if (!CanHandleType(type)) | |
| 272 return 0; | |
| 273 | |
| 274 int64_t total_size; | |
| 275 base::Time last_modified_time; | |
| 276 GetOriginDetailsOnFileTaskRunner(context, origin_url, &total_size, | |
| 277 &last_modified_time); | |
| 278 return total_size; | |
| 279 } | |
| 280 | |
| 281 void PluginPrivateFileSystemBackend::GetOriginDetailsOnFileTaskRunner( | |
| 282 FileSystemContext* context, | |
| 283 const GURL& origin_url, | |
| 284 int64_t* total_size, | |
| 285 base::Time* last_modified_time) { | |
| 286 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | |
| 287 | |
| 288 *total_size = 0; | |
| 289 *last_modified_time = base::Time::UnixEpoch(); | |
| 290 std::string fsid = | |
| 291 storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath( | |
| 292 storage::kFileSystemTypePluginPrivate, "pluginprivate", | |
| 293 base::FilePath()); | |
| 294 DCHECK(storage::ValidateIsolatedFileSystemId(fsid)); | |
| 295 | |
| 296 std::string root = storage::GetIsolatedFileSystemRootURIString( | |
| 297 origin_url, fsid, "pluginprivate"); | |
| 298 | |
| 299 std::unique_ptr<FileSystemOperationContext> operation_context( | |
| 300 new FileSystemOperationContext(context)); | |
| 301 | |
| 302 std::vector<std::string> supported_plugins = { | |
| 303 "application_x-ppapi-widevine-cdm", // Widevine | |
| 304 "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.
| |
| 305 }; | |
| 306 | |
| 307 for (const auto& plugin : supported_plugins) { | |
| 308 if (OpenFileSystemOnFileTaskRunner( | |
| 309 obfuscated_file_util(), plugin_map_, origin_url, fsid, plugin, | |
| 310 storage::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT) == | |
| 311 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.
| |
| 312 std::unique_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator( | |
| 313 obfuscated_file_util()->CreateFileEnumerator( | |
| 314 operation_context.get(), context->CrackURL(GURL(root)), true)); | |
| 315 | |
| 316 base::FilePath current; | |
| 317 while (!(current = enumerator->Next()).empty()) { | |
| 318 *total_size += enumerator->Size(); | |
| 319 if (enumerator->LastModifiedTime() > *last_modified_time) | |
| 320 *last_modified_time = enumerator->LastModifiedTime(); | |
| 321 } | |
| 322 } | |
| 323 } | |
| 271 } | 324 } |
| 272 | 325 |
| 273 scoped_refptr<QuotaReservation> | 326 scoped_refptr<QuotaReservation> |
| 274 PluginPrivateFileSystemBackend::CreateQuotaReservationOnFileTaskRunner( | 327 PluginPrivateFileSystemBackend::CreateQuotaReservationOnFileTaskRunner( |
| 275 const GURL& origin_url, | 328 const GURL& origin_url, |
| 276 FileSystemType type) { | 329 FileSystemType type) { |
| 277 // We don't track usage on this filesystem. | 330 // We don't track usage on this filesystem. |
| 278 NOTREACHED(); | 331 NOTREACHED(); |
| 279 return scoped_refptr<QuotaReservation>(); | 332 return scoped_refptr<QuotaReservation>(); |
| 280 } | 333 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 293 FileSystemType type) const { | 346 FileSystemType type) const { |
| 294 return NULL; | 347 return NULL; |
| 295 } | 348 } |
| 296 | 349 |
| 297 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() { | 350 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() { |
| 298 return static_cast<ObfuscatedFileUtil*>( | 351 return static_cast<ObfuscatedFileUtil*>( |
| 299 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util()); | 352 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util()); |
| 300 } | 353 } |
| 301 | 354 |
| 302 } // namespace storage | 355 } // namespace storage |
| OLD | NEW |