OLD | NEW |
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 Loading... |
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 std::string name = IsolatedContext::GetNameForPath(path); |
149 fileset.insert(path); | |
150 const std::string fsid = | 145 const std::string fsid = |
151 IsolatedContext::GetInstance()->RegisterIsolatedFileSystem(fileset); | 146 IsolatedContext::GetInstance()->RegisterFileSystemForFile(name, path); |
152 CHECK(!fsid.empty()); | 147 CHECK(!fsid.empty()); |
153 return fsid; | 148 return fsid; |
154 } | 149 } |
155 | 150 |
156 void MediaFileSystemRegistry::RevokeMediaFileSystem(const FilePath& path) { | 151 void MediaFileSystemRegistry::RevokeMediaFileSystem(const FilePath& path) { |
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
158 | 153 |
159 IsolatedContext* isolated_context = IsolatedContext::GetInstance(); | 154 IsolatedContext* isolated_context = IsolatedContext::GetInstance(); |
160 for (ChildIdToMediaFSMap::iterator child_it = media_fs_map_.begin(); | 155 for (ChildIdToMediaFSMap::iterator child_it = media_fs_map_.begin(); |
161 child_it != media_fs_map_.end(); | 156 child_it != media_fs_map_.end(); |
162 ++child_it) { | 157 ++child_it) { |
163 MediaPathToFSIDMap& child_map = child_it->second; | 158 MediaPathToFSIDMap& child_map = child_it->second; |
164 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); | 159 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); |
165 if (media_path_it == child_map.end()) | 160 if (media_path_it == child_map.end()) |
166 continue; | 161 continue; |
167 isolated_context->RevokeIsolatedFileSystem(media_path_it->second); | 162 isolated_context->RevokeFileSystem(media_path_it->second); |
168 child_map.erase(media_path_it); | 163 child_map.erase(media_path_it); |
169 } | 164 } |
170 } | 165 } |
171 | 166 |
172 } // namespace chrome | 167 } // namespace chrome |
OLD | NEW |