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

Side by Side Diff: webkit/chromeos/fileapi/cros_mount_point_provider.cc

Issue 10532085: Retry: Make Isolated file system writable only if it is configured so (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 8 years, 6 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/chromeos/fileapi/cros_mount_point_provider.h" 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
6 6
7 #include "base/chromeos/chromeos_version.h" 7 #include "base/chromeos/chromeos_version.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
18 #include "webkit/chromeos/fileapi/file_access_permissions.h" 18 #include "webkit/chromeos/fileapi/file_access_permissions.h"
19 #include "webkit/chromeos/fileapi/remote_file_system_operation.h" 19 #include "webkit/chromeos/fileapi/remote_file_system_operation.h"
20 #include "webkit/fileapi/file_system_file_stream_reader.h" 20 #include "webkit/fileapi/file_system_file_stream_reader.h"
21 #include "webkit/fileapi/file_system_operation.h" 21 #include "webkit/fileapi/file_system_operation.h"
22 #include "webkit/fileapi/file_system_util.h" 22 #include "webkit/fileapi/file_system_util.h"
23 #include "webkit/fileapi/local_file_stream_writer.h"
23 #include "webkit/glue/webkit_glue.h" 24 #include "webkit/glue/webkit_glue.h"
24 25
25 namespace { 26 namespace {
26 27
27 const char kChromeUIScheme[] = "chrome"; 28 const char kChromeUIScheme[] = "chrome";
28 29
29 // Returns the home directory path, or an empty string if the home directory 30 // Returns the home directory path, or an empty string if the home directory
30 // is not found. 31 // is not found.
31 std::string GetHomeDirectory() { 32 std::string GetHomeDirectory() {
32 if (base::chromeos::IsRunningOnChromeOS()) 33 if (base::chromeos::IsRunningOnChromeOS())
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // For now we return a generic Reader implementation which utilizes 262 // For now we return a generic Reader implementation which utilizes
262 // CreateSnapshotFile internally (i.e. will download everything first). 263 // CreateSnapshotFile internally (i.e. will download everything first).
263 // TODO(satorux,zel): implement more efficient reader for remote cases. 264 // TODO(satorux,zel): implement more efficient reader for remote cases.
264 return new fileapi::FileSystemFileStreamReader(context, url, offset); 265 return new fileapi::FileSystemFileStreamReader(context, url, offset);
265 } 266 }
266 267
267 fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( 268 fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter(
268 const GURL& url, 269 const GURL& url,
269 int64 offset, 270 int64 offset,
270 fileapi::FileSystemContext* context) const { 271 fileapi::FileSystemContext* context) const {
271 // TODO(kinaba,kinuko,benchan,satorux): return a writer for remote or local 272 FilePath virtual_path;
272 // file system depending on the mount point location. 273 if (!fileapi::CrackFileSystemURL(url, NULL, NULL, &virtual_path))
273 NOTIMPLEMENTED(); 274 return NULL;
274 return NULL; 275 const MountPoint* mount_point = GetMountPoint(virtual_path);
kinaba 2012/06/12 06:39:32 We need to exit earlier for NULL return: if (!moun
276 if (mount_point && mount_point->location == REMOTE) {
277 // TODO(kinaba): return a gdata writer for remote file system.
278 return NULL;
279 }
280 FilePath root_path = mount_point->local_root_path;
281 return new fileapi::LocalFileStreamWriter(
282 root_path.Append(virtual_path), offset);
275 } 283 }
276 284
277 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path, 285 bool CrosMountPointProvider::GetVirtualPath(const FilePath& filesystem_path,
278 FilePath* virtual_path) { 286 FilePath* virtual_path) {
279 for (MountPointMap::const_iterator iter = mount_point_map_.begin(); 287 for (MountPointMap::const_iterator iter = mount_point_map_.begin();
280 iter != mount_point_map_.end(); 288 iter != mount_point_map_.end();
281 ++iter) { 289 ++iter) {
282 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first); 290 FilePath mount_prefix = iter->second.local_root_path.Append(iter->first);
283 *virtual_path = FilePath(iter->first); 291 *virtual_path = FilePath(iter->first);
284 if (mount_prefix == filesystem_path) { 292 if (mount_prefix == filesystem_path) {
285 return true; 293 return true;
286 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { 294 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) {
287 return true; 295 return true;
288 } 296 }
289 } 297 }
290 return false; 298 return false;
291 } 299 }
292 300
293 } // namespace chromeos 301 } // namespace chromeos
OLDNEW
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | webkit/fileapi/file_system_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698