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

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

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix win 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
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/utf_string_conversions.h"
12 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
15 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
17 #include "webkit/fileapi/isolated_context.h" 18 #include "webkit/fileapi/isolated_context.h"
18 19
19 namespace chrome { 20 namespace chrome {
20 21
21 static base::LazyInstance<MediaFileSystemRegistry>::Leaky 22 static base::LazyInstance<MediaFileSystemRegistry>::Leaky
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 std::string fsid = RegisterPathAsFileSystem(pictures_path); 54 std::string fsid = RegisterPathAsFileSystem(pictures_path);
54 child_it->second.insert(std::make_pair(pictures_path, fsid)); 55 child_it->second.insert(std::make_pair(pictures_path, fsid));
55 } 56 }
56 } 57 }
57 58
58 // TODO(thestig) Handle overlap between devices and media directories. 59 // TODO(thestig) Handle overlap between devices and media directories.
59 SystemMonitor* monitor = SystemMonitor::Get(); 60 SystemMonitor* monitor = SystemMonitor::Get();
60 const std::vector<SystemMonitor::MediaDeviceInfo> media_devices = 61 const std::vector<SystemMonitor::MediaDeviceInfo> media_devices =
61 monitor->GetAttachedMediaDevices(); 62 monitor->GetAttachedMediaDevices();
62 for (size_t i = 0; i < media_devices.size(); ++i) { 63 for (size_t i = 0; i < media_devices.size(); ++i) {
63 const SystemMonitor::DeviceIdType& id = media_devices[i].a; 64 if (media_devices[i].c == SystemMonitor::TYPE_PATH) {
64 const FilePath& path = media_devices[i].c; 65 const SystemMonitor::DeviceIdType& id = media_devices[i].a;
65 device_id_map_.insert(std::make_pair(id, path)); 66 const FilePath path(
66 std::string fsid = RegisterPathAsFileSystem(path); 67 #if defined(OS_WIN)
vandebo (ex-Chrome) 2012/07/19 19:05:20 ugg... Anyway to kill the ifdef here?
Lei Zhang 2012/07/19 21:17:10 If we make location FilePath::StringType instead o
67 child_it->second.insert(std::make_pair(path, fsid)); 68 media_devices[i].d
69 #else
70 UTF16ToUTF8(media_devices[i].d)
71 #endif
72 );
73 device_id_map_.insert(std::make_pair(id, path));
74 std::string fsid = RegisterPathAsFileSystem(path);
75 child_it->second.insert(std::make_pair(path, fsid));
76 }
68 } 77 }
69 78
70 MediaPathToFSIDMap& child_map = child_it->second; 79 MediaPathToFSIDMap& child_map = child_it->second;
71 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); 80 for (MediaPathToFSIDMap::const_iterator it = child_map.begin();
72 it != child_map.end(); 81 it != child_map.end();
73 ++it) { 82 ++it) {
74 const FilePath path = it->first; 83 const FilePath path = it->first;
75 const std::string fsid = it->second; 84 const std::string fsid = it->second;
76 results.push_back(std::make_pair(fsid, path)); 85 results.push_back(std::make_pair(fsid, path));
77 } 86 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 MediaPathToFSIDMap& child_map = child_it->second; 170 MediaPathToFSIDMap& child_map = child_it->second;
162 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); 171 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path);
163 if (media_path_it == child_map.end()) 172 if (media_path_it == child_map.end())
164 continue; 173 continue;
165 isolated_context->RevokeFileSystem(media_path_it->second); 174 isolated_context->RevokeFileSystem(media_path_it->second);
166 child_map.erase(media_path_it); 175 child_map.erase(media_path_it);
167 } 176 }
168 } 177 }
169 178
170 } // namespace chrome 179 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698