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

Unified Diff: chrome/browser/media_gallery/media_device_manager.cc

Issue 10409084: Media Gallery: Implement a basic version of GetMediaFileSystems(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_gallery/media_device_manager.cc
===================================================================
--- chrome/browser/media_gallery/media_device_manager.cc (revision 0)
+++ chrome/browser/media_gallery/media_device_manager.cc (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// MediaDeviceManager implementation.
+
+#include "chrome/browser/media_gallery/media_device_manager.h"
+
+#include <set>
+
+#include "base/path_service.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/common/chrome_paths.h"
+#include "content/public/browser/browser_thread.h"
+#include "webkit/fileapi/isolated_context.h"
+
+namespace chrome {
+
+static base::LazyInstance<MediaDeviceManager>::Leaky g_media_device_manager =
+ LAZY_INSTANCE_INITIALIZER;
+
+using content::BrowserThread;
+using fileapi::IsolatedContext;
+
+// static
+MediaDeviceManager* MediaDeviceManager::GetInstance() {
+ return g_media_device_manager.Pointer();
+}
+
+std::vector<MediaDeviceManager::MediaFSIDAndPath>*
+MediaDeviceManager::GetMediaFileSystems() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ std::vector<MediaFSIDAndPath>* results = new std::vector<MediaFSIDAndPath>;
+ for (MediaPathToFSIDMap::const_iterator it = media_fs_map_.begin();
+ it != media_fs_map_.end();
+ ++it) {
+ const FilePath path = it->first;
+ const std::string fsid = it->second;
+ results->push_back(std::make_pair(fsid, path));
+ }
+ return results;
+}
+
+MediaDeviceManager::MediaDeviceManager() {
+ FilePath pictures_path;
+ if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path)) {
+ RegisterPathAsFileSystem(pictures_path);
+ }
+}
+
+MediaDeviceManager::~MediaDeviceManager() {
+}
+
+void MediaDeviceManager::RegisterPathAsFileSystem(const FilePath& path) {
+ // Sanity checks for |path|.
+ CHECK(path.IsAbsolute());
+ CHECK(!path.ReferencesParent());
+ // Make sure |path| does not refer to '/' on Unix.
+ // TODO(thestig) Check how BaseName() works for say, 'C:\' on Windows.
+ CHECK(!path.BaseName().IsAbsolute());
+ CHECK(!path.BaseName().empty());
+
+ std::set<FilePath> fileset;
+ fileset.insert(path);
+ const std::string fsid =
+ IsolatedContext::GetInstance()->RegisterIsolatedFileSystem(fileset);
+ CHECK(!fsid.empty());
+ media_fs_map_.insert(std::make_pair(path, fsid));
+}
+
+} // namespace chrome
Property changes on: chrome/browser/media_gallery/media_device_manager.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698