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

Side by Side Diff: webkit/fileapi/file_system_context.cc

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test on Win Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_context_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/fileapi/file_system_context.h" 5 #include "webkit/fileapi/file_system_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "webkit/fileapi/external_mount_points.h" 11 #include "webkit/fileapi/external_mount_points.h"
12 #include "webkit/fileapi/file_system_file_util.h" 12 #include "webkit/fileapi/file_system_file_util.h"
13 #include "webkit/fileapi/file_system_operation.h" 13 #include "webkit/fileapi/file_system_operation.h"
14 #include "webkit/fileapi/file_system_options.h" 14 #include "webkit/fileapi/file_system_options.h"
15 #include "webkit/fileapi/file_system_quota_client.h" 15 #include "webkit/fileapi/file_system_quota_client.h"
16 #include "webkit/fileapi/file_system_task_runners.h" 16 #include "webkit/fileapi/file_system_task_runners.h"
17 #include "webkit/fileapi/file_system_url.h" 17 #include "webkit/fileapi/file_system_url.h"
18 #include "webkit/fileapi/file_system_util.h" 18 #include "webkit/fileapi/file_system_util.h"
19 #include "webkit/fileapi/isolated_context.h" 19 #include "webkit/fileapi/isolated_context.h"
20 #include "webkit/fileapi/isolated_mount_point_provider.h" 20 #include "webkit/fileapi/isolated_mount_point_provider.h"
21 #include "webkit/fileapi/mount_points.h"
21 #include "webkit/fileapi/sandbox_mount_point_provider.h" 22 #include "webkit/fileapi/sandbox_mount_point_provider.h"
22 #include "webkit/fileapi/syncable/local_file_change_tracker.h" 23 #include "webkit/fileapi/syncable/local_file_change_tracker.h"
23 #include "webkit/fileapi/syncable/local_file_sync_context.h" 24 #include "webkit/fileapi/syncable/local_file_sync_context.h"
24 #include "webkit/fileapi/syncable/syncable_file_system_util.h" 25 #include "webkit/fileapi/syncable/syncable_file_system_util.h"
25 #include "webkit/fileapi/test_mount_point_provider.h" 26 #include "webkit/fileapi/test_mount_point_provider.h"
26 #include "webkit/quota/quota_manager.h" 27 #include "webkit/quota/quota_manager.h"
27 #include "webkit/quota/special_storage_policy.h" 28 #include "webkit/quota/special_storage_policy.h"
28 29
29 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
30 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" 31 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 options)), 69 options)),
69 isolated_provider_(new IsolatedMountPointProvider(partition_path)), 70 isolated_provider_(new IsolatedMountPointProvider(partition_path)),
70 partition_path_(partition_path) { 71 partition_path_(partition_path) {
71 DCHECK(task_runners_.get()); 72 DCHECK(task_runners_.get());
72 73
73 if (quota_manager_proxy) { 74 if (quota_manager_proxy) {
74 quota_manager_proxy->RegisterClient(CreateQuotaClient( 75 quota_manager_proxy->RegisterClient(CreateQuotaClient(
75 this, options.is_incognito())); 76 this, options.is_incognito()));
76 } 77 }
77 #if defined(OS_CHROMEOS) 78 #if defined(OS_CHROMEOS)
79 // TODO(tbarzic): Pass this through ctor.
80 scoped_refptr<ExternalMountPoints> external_mount_points =
81 ExternalMountPoints::CreateRefCounted();
82 // |external_provider_| will take a reference or external_mount_points so this
83 // doesn't have to retain one for itself.
78 external_provider_.reset( 84 external_provider_.reset(
79 new chromeos::CrosMountPointProvider( 85 new chromeos::CrosMountPointProvider(
80 special_storage_policy, 86 special_storage_policy,
81 // TODO(tbarzic): Switch this to |external_mount_points_|. 87 external_mount_points,
82 fileapi::ExternalMountPoints::GetSystemInstance(), 88 ExternalMountPoints::GetSystemInstance()));
83 fileapi::ExternalMountPoints::GetSystemInstance())); 89 url_crackers_.push_back(external_mount_points.get());
84 #endif 90 #endif
91
92 url_crackers_.push_back(ExternalMountPoints::GetSystemInstance());
93 url_crackers_.push_back(IsolatedContext::GetInstance());
85 } 94 }
86 95
87 bool FileSystemContext::DeleteDataForOriginOnFileThread( 96 bool FileSystemContext::DeleteDataForOriginOnFileThread(
88 const GURL& origin_url) { 97 const GURL& origin_url) {
89 DCHECK(task_runners_->file_task_runner()->RunsTasksOnCurrentThread()); 98 DCHECK(task_runners_->file_task_runner()->RunsTasksOnCurrentThread());
90 DCHECK(sandbox_provider()); 99 DCHECK(sandbox_provider());
91 DCHECK(origin_url == origin_url.GetOrigin()); 100 DCHECK(origin_url == origin_url.GetOrigin());
92 101
93 // Delete temporary and persistent data. 102 // Delete temporary and persistent data.
94 return 103 return
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 sandbox_provider_->AddSyncableFileChangeObserver( 308 sandbox_provider_->AddSyncableFileChangeObserver(
300 change_tracker_.get(), 309 change_tracker_.get(),
301 task_runners_->file_task_runner()); 310 task_runners_->file_task_runner());
302 } 311 }
303 312
304 void FileSystemContext::set_sync_context( 313 void FileSystemContext::set_sync_context(
305 LocalFileSyncContext* sync_context) { 314 LocalFileSyncContext* sync_context) {
306 sync_context_ = sync_context; 315 sync_context_ = sync_context;
307 } 316 }
308 317
318 FileSystemURL FileSystemContext::CrackURL(const GURL& url) const {
319 return CrackFileSystemURL(FileSystemURL(url));
320 }
321
322 FileSystemURL FileSystemContext::CreateCrackedFileSystemURL(
323 const GURL& origin,
324 FileSystemType type,
325 const FilePath& path) const {
326 return CrackFileSystemURL(FileSystemURL(origin, type, path));
327 }
328
309 FileSystemContext::~FileSystemContext() { 329 FileSystemContext::~FileSystemContext() {
310 task_runners_->file_task_runner()->DeleteSoon( 330 task_runners_->file_task_runner()->DeleteSoon(
311 FROM_HERE, change_tracker_.release()); 331 FROM_HERE, change_tracker_.release());
312 } 332 }
313 333
314 void FileSystemContext::DeleteOnCorrectThread() const { 334 void FileSystemContext::DeleteOnCorrectThread() const {
315 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() && 335 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() &&
316 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) { 336 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) {
317 return; 337 return;
318 } 338 }
319 STLDeleteContainerPairSecondPointers(provider_map_.begin(), 339 STLDeleteContainerPairSecondPointers(provider_map_.begin(),
320 provider_map_.end()); 340 provider_map_.end());
321 delete this; 341 delete this;
322 } 342 }
323 343
344 FileSystemURL FileSystemContext::CrackFileSystemURL(
345 const FileSystemURL& url) const {
346 if (!url.is_valid())
347 return FileSystemURL();
348
349 // The returned value in case there is no crackers which can crack the url.
350 // This is valid situation for non isolated/external file systems.
351 FileSystemURL result = url;
352
353 for (size_t i = 0; i < url_crackers_.size(); ++i) {
354 if (!url_crackers_[i]->HandlesFileSystemMountType(url.type()))
355 continue;
356
357 result = url_crackers_[i]->CreateCrackedFileSystemURL(url.origin(),
358 url.type(),
359 url.path());
360 if (result.is_valid())
361 return result;
362 }
363
364 return result;
365 }
366
324 } // namespace fileapi 367 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698