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

Side by Side Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 10713007: Make isolated file system works for a device root (e.g. X:\\) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 5 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 // MediaFileSystemRegistry implementation. 5 // MediaFileSystemRegistry implementation.
6 6
7 #include "chrome/browser/media_gallery/media_file_system_registry.h" 7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 content::Source<RenderProcessHost>(rph)); 133 content::Source<RenderProcessHost>(rph));
134 } 134 }
135 135
136 std::string MediaFileSystemRegistry::RegisterPathAsFileSystem( 136 std::string MediaFileSystemRegistry::RegisterPathAsFileSystem(
137 const FilePath& path) { 137 const FilePath& path) {
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
139 139
140 // Sanity checks for |path|. 140 // Sanity checks for |path|.
141 CHECK(path.IsAbsolute()); 141 CHECK(path.IsAbsolute());
142 CHECK(!path.ReferencesParent()); 142 CHECK(!path.ReferencesParent());
143 // Make sure |path| does not refer to '/' on Unix.
144 // TODO(thestig) Check how BaseName() works for say, 'C:\' on Windows.
145 CHECK(!path.BaseName().IsAbsolute());
146 CHECK(!path.BaseName().empty());
147 143
148 std::set<FilePath> fileset; 144 // The directory name is not exposed to the js layer and we simply use
149 fileset.insert(path); 145 // a fixed name (as we only register a single directory per file system).
146 std::string register_name("_");
150 const std::string fsid = 147 const std::string fsid =
151 IsolatedContext::GetInstance()->RegisterIsolatedFileSystem(fileset); 148 IsolatedContext::GetInstance()->RegisterFileSystemForFile(
149 path, &register_name);
152 CHECK(!fsid.empty()); 150 CHECK(!fsid.empty());
153 return fsid; 151 return fsid;
154 } 152 }
155 153
156 void MediaFileSystemRegistry::RevokeMediaFileSystem(const FilePath& path) { 154 void MediaFileSystemRegistry::RevokeMediaFileSystem(const FilePath& path) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 156
159 IsolatedContext* isolated_context = IsolatedContext::GetInstance(); 157 IsolatedContext* isolated_context = IsolatedContext::GetInstance();
160 for (ChildIdToMediaFSMap::iterator child_it = media_fs_map_.begin(); 158 for (ChildIdToMediaFSMap::iterator child_it = media_fs_map_.begin();
161 child_it != media_fs_map_.end(); 159 child_it != media_fs_map_.end();
162 ++child_it) { 160 ++child_it) {
163 MediaPathToFSIDMap& child_map = child_it->second; 161 MediaPathToFSIDMap& child_map = child_it->second;
164 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); 162 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path);
165 if (media_path_it == child_map.end()) 163 if (media_path_it == child_map.end())
166 continue; 164 continue;
167 isolated_context->RevokeIsolatedFileSystem(media_path_it->second); 165 isolated_context->RevokeFileSystem(media_path_it->second);
168 child_map.erase(media_path_it); 166 child_map.erase(media_path_it);
169 } 167 }
170 } 168 }
171 169
172 } // namespace chrome 170 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/intents/device_attached_intent_source.cc ('k') | content/browser/intents/intent_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698