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

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

Issue 10810053: Enables internal filesystem types via Isolated filesystems (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: layout test crash fix Created 8 years, 4 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/isolated_context.h ('k') | webkit/fileapi/isolated_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/isolated_context.h" 5 #include "webkit/fileapi/isolated_context.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DCHECK(found->second->ref_counts() > 0); 174 DCHECK(found->second->ref_counts() > 0);
175 found->second->RemoveRef(); 175 found->second->RemoveRef();
176 if (found->second->ref_counts() == 0) { 176 if (found->second->ref_counts() == 0) {
177 delete found->second; 177 delete found->second;
178 instance_map_.erase(found); 178 instance_map_.erase(found);
179 } 179 }
180 } 180 }
181 181
182 bool IsolatedContext::CrackIsolatedPath(const FilePath& virtual_path, 182 bool IsolatedContext::CrackIsolatedPath(const FilePath& virtual_path,
183 std::string* filesystem_id, 183 std::string* filesystem_id,
184 FileInfo* root_info, 184 FileSystemType* type,
185 FilePath* path) const { 185 FilePath* path) const {
186 DCHECK(filesystem_id); 186 DCHECK(filesystem_id);
187 DCHECK(path); 187 DCHECK(path);
188 188
189 // This should not contain any '..' references. 189 // This should not contain any '..' references.
190 if (virtual_path.ReferencesParent()) 190 if (virtual_path.ReferencesParent())
191 return false; 191 return false;
192 192
193 // The virtual_path should comprise <filesystem_id> and <relative_path> parts. 193 // The virtual_path should comprise <filesystem_id> and <relative_path> parts.
194 std::vector<FilePath::StringType> components; 194 std::vector<FilePath::StringType> components;
195 virtual_path.GetComponents(&components); 195 virtual_path.GetComponents(&components);
196 if (components.size() < 1) 196 if (components.size() < 1)
197 return false; 197 return false;
198 198
199 base::AutoLock locker(lock_); 199 base::AutoLock locker(lock_);
200 std::string fsid = FilePath(components[0]).MaybeAsASCII(); 200 std::string fsid = FilePath(components[0]).MaybeAsASCII();
201 if (fsid.empty()) 201 if (fsid.empty())
202 return false; 202 return false;
203 IDToInstance::const_iterator found_instance = instance_map_.find(fsid); 203 IDToInstance::const_iterator found_instance = instance_map_.find(fsid);
204 if (found_instance == instance_map_.end()) 204 if (found_instance == instance_map_.end())
205 return false; 205 return false;
206 *filesystem_id = fsid; 206 *filesystem_id = fsid;
207 if (type)
208 *type = found_instance->second->type();
207 if (components.size() == 1) { 209 if (components.size() == 1) {
208 path->clear(); 210 path->clear();
209 return true; 211 return true;
210 } 212 }
211 // components[1] should be a name of the registered paths. 213 // components[1] should be a name of the registered paths.
212 FilePath cracked_path; 214 FilePath cracked_path;
213 std::string name = FilePath(components[1]).AsUTF8Unsafe(); 215 std::string name = FilePath(components[1]).AsUTF8Unsafe();
214 if (!found_instance->second->ResolvePathForName(name, &cracked_path)) 216 if (!found_instance->second->ResolvePathForName(name, &cracked_path))
215 return false; 217 return false;
216 if (root_info)
217 *root_info = FileInfo(name, cracked_path);
218 for (size_t i = 2; i < components.size(); ++i) 218 for (size_t i = 2; i < components.size(); ++i)
219 cracked_path = cracked_path.Append(components[i]); 219 cracked_path = cracked_path.Append(components[i]);
220 *path = cracked_path; 220 *path = cracked_path;
221 return true; 221 return true;
222 } 222 }
223 223
224 bool IsolatedContext::GetDraggedFileInfo( 224 bool IsolatedContext::GetDraggedFileInfo(
225 const std::string& filesystem_id, std::vector<FileInfo>* files) const { 225 const std::string& filesystem_id, std::vector<FileInfo>* files) const {
226 DCHECK(files); 226 DCHECK(files);
227 base::AutoLock locker(lock_); 227 base::AutoLock locker(lock_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 uint32 random_data[4]; 264 uint32 random_data[4];
265 std::string id; 265 std::string id;
266 do { 266 do {
267 base::RandBytes(random_data, sizeof(random_data)); 267 base::RandBytes(random_data, sizeof(random_data));
268 id = base::HexEncode(random_data, sizeof(random_data)); 268 id = base::HexEncode(random_data, sizeof(random_data));
269 } while (instance_map_.find(id) != instance_map_.end()); 269 } while (instance_map_.find(id) != instance_map_.end());
270 return id; 270 return id;
271 } 271 }
272 272
273 } // namespace fileapi 273 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/isolated_context.h ('k') | webkit/fileapi/isolated_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698