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

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

Issue 11787028: New FileSystemURL cracking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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/local_file_system_test_helper.h" 5 #include "webkit/fileapi/local_file_system_test_helper.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 void LocalFileSystemTestOriginHelper::SetUp( 45 void LocalFileSystemTestOriginHelper::SetUp(
46 FileSystemContext* file_system_context, FileSystemFileUtil* file_util) { 46 FileSystemContext* file_system_context, FileSystemFileUtil* file_util) {
47 file_util_ = file_util; 47 file_util_ = file_util;
48 file_system_context_ = file_system_context; 48 file_system_context_ = file_system_context;
49 if (!file_util_) 49 if (!file_util_)
50 file_util_ = file_system_context->GetFileUtil(type_); 50 file_util_ = file_system_context->GetFileUtil(type_);
51 DCHECK(file_util_); 51 DCHECK(file_util_);
52 52
53 // Prepare the origin's root directory. 53 // Prepare the origin's root directory.
54 file_system_context_->GetMountPointProvider(type_)-> 54 file_system_context_->GetMountPointProvider(type_)->
55 GetFileSystemRootPathOnFileThread( 55 GetFileSystemRootPathOnFileThread(CreateURL(FilePath()),
56 FileSystemURL(origin_, type_, FilePath()), true /* create */); 56 true /* create */);
57 57
58 // Initialize the usage cache file. 58 // Initialize the usage cache file.
59 FilePath usage_cache_path = GetUsageCachePath(); 59 FilePath usage_cache_path = GetUsageCachePath();
60 if (!usage_cache_path.empty()) 60 if (!usage_cache_path.empty())
61 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); 61 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0);
62 } 62 }
63 63
64 void LocalFileSystemTestOriginHelper::SetUp( 64 void LocalFileSystemTestOriginHelper::SetUp(
65 const FilePath& base_dir, 65 const FilePath& base_dir,
66 bool unlimited_quota, 66 bool unlimited_quota,
(...skipping 13 matching lines...) Expand all
80 file_system_context_->RegisterMountPointProvider( 80 file_system_context_->RegisterMountPointProvider(
81 type_, 81 type_,
82 new TestMountPointProvider( 82 new TestMountPointProvider(
83 file_system_context_->task_runners()->file_task_runner(), 83 file_system_context_->task_runners()->file_task_runner(),
84 base_dir)); 84 base_dir));
85 } 85 }
86 86
87 // Prepare the origin's root directory. 87 // Prepare the origin's root directory.
88 FileSystemMountPointProvider* mount_point_provider = 88 FileSystemMountPointProvider* mount_point_provider =
89 file_system_context_->GetMountPointProvider(type_); 89 file_system_context_->GetMountPointProvider(type_);
90 mount_point_provider->GetFileSystemRootPathOnFileThread( 90 mount_point_provider->GetFileSystemRootPathOnFileThread(CreateURL(FilePath()),
91 FileSystemURL(origin_, type_, FilePath()), true /* create */); 91 true /* create */);
92 92
93 if (file_util) 93 if (file_util)
94 file_util_ = file_util; 94 file_util_ = file_util;
95 else 95 else
96 file_util_ = mount_point_provider->GetFileUtil(type_); 96 file_util_ = mount_point_provider->GetFileUtil(type_);
97 97
98 DCHECK(file_util_); 98 DCHECK(file_util_);
99 99
100 // Initialize the usage cache file. 100 // Initialize the usage cache file.
101 FilePath usage_cache_path = GetUsageCachePath(); 101 FilePath usage_cache_path = GetUsageCachePath();
102 if (!usage_cache_path.empty()) 102 if (!usage_cache_path.empty())
103 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); 103 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0);
104 } 104 }
105 105
106 void LocalFileSystemTestOriginHelper::TearDown() { 106 void LocalFileSystemTestOriginHelper::TearDown() {
107 file_system_context_ = NULL; 107 file_system_context_ = NULL;
108 MessageLoop::current()->RunUntilIdle(); 108 MessageLoop::current()->RunUntilIdle();
109 } 109 }
110 110
111 FilePath LocalFileSystemTestOriginHelper::GetOriginRootPath() const { 111 FilePath LocalFileSystemTestOriginHelper::GetOriginRootPath() const {
112 return file_system_context_->GetMountPointProvider(type_)-> 112 return file_system_context_->GetMountPointProvider(type_)->
113 GetFileSystemRootPathOnFileThread( 113 GetFileSystemRootPathOnFileThread(CreateURL(FilePath()), false);
114 FileSystemURL(origin_, type_, FilePath()), false);
115 } 114 }
116 115
117 FilePath LocalFileSystemTestOriginHelper::GetLocalPath(const FilePath& path) { 116 FilePath LocalFileSystemTestOriginHelper::GetLocalPath(const FilePath& path) {
118 DCHECK(file_util_); 117 DCHECK(file_util_);
119 FilePath local_path; 118 FilePath local_path;
120 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 119 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
121 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path); 120 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path);
122 return local_path; 121 return local_path;
123 } 122 }
124 123
125 FilePath LocalFileSystemTestOriginHelper::GetLocalPathFromASCII( 124 FilePath LocalFileSystemTestOriginHelper::GetLocalPathFromASCII(
126 const std::string& path) { 125 const std::string& path) {
127 return GetLocalPath(FilePath().AppendASCII(path)); 126 return GetLocalPath(FilePath().AppendASCII(path));
128 } 127 }
129 128
130 FilePath LocalFileSystemTestOriginHelper::GetUsageCachePath() const { 129 FilePath LocalFileSystemTestOriginHelper::GetUsageCachePath() const {
131 if (type_ != kFileSystemTypeTemporary && 130 if (type_ != kFileSystemTypeTemporary &&
132 type_ != kFileSystemTypePersistent) 131 type_ != kFileSystemTypePersistent)
133 return FilePath(); 132 return FilePath();
134 return file_system_context_-> 133 return file_system_context_->
135 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); 134 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_);
136 } 135 }
137 136
138 FileSystemURL LocalFileSystemTestOriginHelper::CreateURL(const FilePath& path) 137 FileSystemURL LocalFileSystemTestOriginHelper::CreateURL(const FilePath& path)
139 const { 138 const {
140 return FileSystemURL(origin_, type_, path); 139 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path);
141 } 140 }
142 141
143 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilCopy( 142 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilCopy(
144 FileSystemOperationContext* context, 143 FileSystemOperationContext* context,
145 const FileSystemURL& src, 144 const FileSystemURL& src,
146 const FileSystemURL& dest) const { 145 const FileSystemURL& dest) const {
147 return FileUtilHelper::Copy(context, file_util(), file_util(), src, dest); 146 return FileUtilHelper::Copy(context, file_util(), file_util(), src, dest);
148 } 147 }
149 148
150 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilMove( 149 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilMove(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 LocalFileSystemTestOriginHelper::NewOperationContext() { 187 LocalFileSystemTestOriginHelper::NewOperationContext() {
189 DCHECK(file_system_context_.get()); 188 DCHECK(file_system_context_.get());
190 FileSystemOperationContext* context = 189 FileSystemOperationContext* context =
191 new FileSystemOperationContext(file_system_context_.get()); 190 new FileSystemOperationContext(file_system_context_.get());
192 context->set_update_observers( 191 context->set_update_observers(
193 *file_system_context_->GetUpdateObservers(type_)); 192 *file_system_context_->GetUpdateObservers(type_));
194 return context; 193 return context;
195 } 194 }
196 195
197 } // namespace fileapi 196 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698