| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 namespace storage { | 31 namespace storage { |
| 32 | 32 |
| 33 class PluginPrivateFileSystemBackend::FileSystemIDToPluginMap { | 33 class PluginPrivateFileSystemBackend::FileSystemIDToPluginMap { |
| 34 public: | 34 public: |
| 35 explicit FileSystemIDToPluginMap(base::SequencedTaskRunner* task_runner) | 35 explicit FileSystemIDToPluginMap(base::SequencedTaskRunner* task_runner) |
| 36 : task_runner_(task_runner) {} | 36 : task_runner_(task_runner) {} |
| 37 ~FileSystemIDToPluginMap() {} | 37 ~FileSystemIDToPluginMap() {} |
| 38 | 38 |
| 39 std::string GetPluginIDForURL(const FileSystemURL& url) { | 39 std::string GetPluginIDForURL(const FileSystemURL& url) { |
| 40 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 40 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 41 Map::iterator found = map_.find(url.filesystem_id()); | 41 Map::iterator found = map_.find(url.filesystem_id()); |
| 42 if (url.type() != kFileSystemTypePluginPrivate || found == map_.end()) { | 42 if (url.type() != kFileSystemTypePluginPrivate || found == map_.end()) { |
| 43 NOTREACHED() << "Unsupported url is given: " << url.DebugString(); | 43 NOTREACHED() << "Unsupported url is given: " << url.DebugString(); |
| 44 return std::string(); | 44 return std::string(); |
| 45 } | 45 } |
| 46 return found->second; | 46 return found->second; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void RegisterFileSystem(const std::string& filesystem_id, | 49 void RegisterFileSystem(const std::string& filesystem_id, |
| 50 const std::string& plugin_id) { | 50 const std::string& plugin_id) { |
| 51 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 51 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 52 DCHECK(!filesystem_id.empty()); | 52 DCHECK(!filesystem_id.empty()); |
| 53 DCHECK(!base::ContainsKey(map_, filesystem_id)) << filesystem_id; | 53 DCHECK(!base::ContainsKey(map_, filesystem_id)) << filesystem_id; |
| 54 map_[filesystem_id] = plugin_id; | 54 map_[filesystem_id] = plugin_id; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void RemoveFileSystem(const std::string& filesystem_id) { | 57 void RemoveFileSystem(const std::string& filesystem_id) { |
| 58 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 58 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 59 map_.erase(filesystem_id); | 59 map_.erase(filesystem_id); |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 typedef std::map<std::string, std::string> Map; | 63 typedef std::map<std::string, std::string> Map; |
| 64 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 64 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 65 Map map_; | 65 Map map_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 namespace { | 68 namespace { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 special_storage_policy, | 106 special_storage_policy, |
| 107 base_path_, file_system_options.env_override(), | 107 base_path_, file_system_options.env_override(), |
| 108 file_task_runner, | 108 file_task_runner, |
| 109 base::Bind(&FileSystemIDToPluginMap::GetPluginIDForURL, | 109 base::Bind(&FileSystemIDToPluginMap::GetPluginIDForURL, |
| 110 base::Owned(plugin_map_)), | 110 base::Owned(plugin_map_)), |
| 111 std::set<std::string>(), | 111 std::set<std::string>(), |
| 112 NULL))); | 112 NULL))); |
| 113 } | 113 } |
| 114 | 114 |
| 115 PluginPrivateFileSystemBackend::~PluginPrivateFileSystemBackend() { | 115 PluginPrivateFileSystemBackend::~PluginPrivateFileSystemBackend() { |
| 116 if (!file_task_runner_->RunsTasksOnCurrentThread()) { | 116 if (!file_task_runner_->RunsTasksInCurrentSequence()) { |
| 117 AsyncFileUtil* file_util = file_util_.release(); | 117 AsyncFileUtil* file_util = file_util_.release(); |
| 118 if (!file_task_runner_->DeleteSoon(FROM_HERE, file_util)) | 118 if (!file_task_runner_->DeleteSoon(FROM_HERE, file_util)) |
| 119 delete file_util; | 119 delete file_util; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 void PluginPrivateFileSystemBackend::OpenPrivateFileSystem( | 123 void PluginPrivateFileSystemBackend::OpenPrivateFileSystem( |
| 124 const GURL& origin_url, | 124 const GURL& origin_url, |
| 125 FileSystemType type, | 125 FileSystemType type, |
| 126 const std::string& filesystem_id, | 126 const std::string& filesystem_id, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 while (!(origin = enumerator->Next()).is_empty()) { | 261 while (!(origin = enumerator->Next()).is_empty()) { |
| 262 if (host == net::GetHostOrSpecFromURL(origin)) | 262 if (host == net::GetHostOrSpecFromURL(origin)) |
| 263 origins->insert(origin); | 263 origins->insert(origin); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( | 267 int64_t PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner( |
| 268 FileSystemContext* context, | 268 FileSystemContext* context, |
| 269 const GURL& origin_url, | 269 const GURL& origin_url, |
| 270 FileSystemType type) { | 270 FileSystemType type) { |
| 271 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 271 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 272 | 272 |
| 273 if (!CanHandleType(type)) | 273 if (!CanHandleType(type)) |
| 274 return 0; | 274 return 0; |
| 275 | 275 |
| 276 int64_t total_size; | 276 int64_t total_size; |
| 277 base::Time last_modified_time; | 277 base::Time last_modified_time; |
| 278 GetOriginDetailsOnFileTaskRunner(context, origin_url, &total_size, | 278 GetOriginDetailsOnFileTaskRunner(context, origin_url, &total_size, |
| 279 &last_modified_time); | 279 &last_modified_time); |
| 280 return total_size; | 280 return total_size; |
| 281 } | 281 } |
| 282 | 282 |
| 283 void PluginPrivateFileSystemBackend::GetOriginDetailsOnFileTaskRunner( | 283 void PluginPrivateFileSystemBackend::GetOriginDetailsOnFileTaskRunner( |
| 284 FileSystemContext* context, | 284 FileSystemContext* context, |
| 285 const GURL& origin_url, | 285 const GURL& origin_url, |
| 286 int64_t* total_size, | 286 int64_t* total_size, |
| 287 base::Time* last_modified_time) { | 287 base::Time* last_modified_time) { |
| 288 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 288 DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); |
| 289 | 289 |
| 290 *total_size = 0; | 290 *total_size = 0; |
| 291 *last_modified_time = base::Time::UnixEpoch(); | 291 *last_modified_time = base::Time::UnixEpoch(); |
| 292 std::string fsid = | 292 std::string fsid = |
| 293 storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath( | 293 storage::IsolatedContext::GetInstance()->RegisterFileSystemForVirtualPath( |
| 294 storage::kFileSystemTypePluginPrivate, "pluginprivate", | 294 storage::kFileSystemTypePluginPrivate, "pluginprivate", |
| 295 base::FilePath()); | 295 base::FilePath()); |
| 296 DCHECK(storage::ValidateIsolatedFileSystemId(fsid)); | 296 DCHECK(storage::ValidateIsolatedFileSystemId(fsid)); |
| 297 | 297 |
| 298 std::string root = storage::GetIsolatedFileSystemRootURIString( | 298 std::string root = storage::GetIsolatedFileSystemRootURIString( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 FileSystemType type) const { | 362 FileSystemType type) const { |
| 363 return NULL; | 363 return NULL; |
| 364 } | 364 } |
| 365 | 365 |
| 366 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() { | 366 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() { |
| 367 return static_cast<ObfuscatedFileUtil*>( | 367 return static_cast<ObfuscatedFileUtil*>( |
| 368 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util()); | 368 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 } // namespace storage | 371 } // namespace storage |
| OLD | NEW |