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

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: browser_tests compile 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
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 an ownership of reference or
kinuko 2013/01/18 07:33:32 will take a reference of ?
tbarzic 2013/01/18 21:33:15 Done.
83 // external_mount_points so this 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
329
kinuko 2013/01/18 07:33:32 nit: extra empty line
tbarzic 2013/01/18 21:33:15 Done.
309 FileSystemContext::~FileSystemContext() { 330 FileSystemContext::~FileSystemContext() {
310 task_runners_->file_task_runner()->DeleteSoon( 331 task_runners_->file_task_runner()->DeleteSoon(
311 FROM_HERE, change_tracker_.release()); 332 FROM_HERE, change_tracker_.release());
312 } 333 }
313 334
314 void FileSystemContext::DeleteOnCorrectThread() const { 335 void FileSystemContext::DeleteOnCorrectThread() const {
315 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() && 336 if (!task_runners_->io_task_runner()->RunsTasksOnCurrentThread() &&
316 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) { 337 task_runners_->io_task_runner()->DeleteSoon(FROM_HERE, this)) {
317 return; 338 return;
318 } 339 }
319 STLDeleteContainerPairSecondPointers(provider_map_.begin(), 340 STLDeleteContainerPairSecondPointers(provider_map_.begin(),
320 provider_map_.end()); 341 provider_map_.end());
321 delete this; 342 delete this;
322 } 343 }
323 344
345 FileSystemURL FileSystemContext::CrackFileSystemURL(
346 const FileSystemURL& url) const {
347 if (url.is_cracked())
348 return url;
349
350 // The returned value in case there is no crackers which can crack the url.
351 // This is valid situation for non isolated/external file systems.
352 FileSystemURL result = url;
353
354 for (size_t i = 0; i < url_crackers_.size(); ++i) {
355 if (!url_crackers_[i]->CanHandleURL(url))
356 continue;
357
358 result = url_crackers_[i]->CrackFileSystemURL(url);
359 if (result.is_valid())
360 return result;
361 }
362
363 return result;
364 }
365
324 } // namespace fileapi 366 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698