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

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

Issue 10409084: Media Gallery: Implement a basic version of GetMediaFileSystems(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix win again 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
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // MediaFileSystemRegistry implementation.
6
7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8
9 #include <set>
10
11 #include "base/path_service.h"
12 #include "base/sys_string_conversions.h"
13 #include "chrome/common/chrome_paths.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "webkit/fileapi/isolated_context.h"
16
17 namespace chrome {
18
19 static base::LazyInstance<MediaFileSystemRegistry>::Leaky
20 g_media_file_system_registry = LAZY_INSTANCE_INITIALIZER;
21
22 using content::BrowserThread;
23 using fileapi::IsolatedContext;
24
25 // static
26 MediaFileSystemRegistry* MediaFileSystemRegistry::GetInstance() {
27 return g_media_file_system_registry.Pointer();
28 }
29
30 std::vector<MediaFileSystemRegistry::MediaFSIDAndPath>
31 MediaFileSystemRegistry::GetMediaFileSystems() const {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 std::vector<MediaFSIDAndPath> results;
34 for (MediaPathToFSIDMap::const_iterator it = media_fs_map_.begin();
35 it != media_fs_map_.end();
36 ++it) {
37 const FilePath path = it->first;
38 const std::string fsid = it->second;
39 results.push_back(std::make_pair(fsid, path));
40 }
41 return results;
42 }
43
44 MediaFileSystemRegistry::MediaFileSystemRegistry() {
45 FilePath pictures_path;
46 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) {
47 RegisterPathAsFileSystem(pictures_path);
48 }
49 }
50
51 MediaFileSystemRegistry::~MediaFileSystemRegistry() {
52 }
53
54 void MediaFileSystemRegistry::RegisterPathAsFileSystem(const FilePath& path) {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
56
57 // Sanity checks for |path|.
58 CHECK(path.IsAbsolute());
59 CHECK(!path.ReferencesParent());
60 // Make sure |path| does not refer to '/' on Unix.
61 // TODO(thestig) Check how BaseName() works for say, 'C:\' on Windows.
62 CHECK(!path.BaseName().IsAbsolute());
63 CHECK(!path.BaseName().empty());
64
65 std::set<FilePath> fileset;
66 fileset.insert(path);
67 const std::string fsid =
68 IsolatedContext::GetInstance()->RegisterIsolatedFileSystem(fileset);
69 CHECK(!fsid.empty());
70 media_fs_map_.insert(std::make_pair(path, fsid));
71 }
72
73 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698