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

Side by Side Diff: chrome/browser/system_monitor/portable_device_watcher_win.h

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed DCHECK, added lock in PortableDeviceWatcherWin and fixed tests. Created 8 years 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 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
6 #define CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 6 #define CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
7 7
8 #include <portabledeviceapi.h> 8 #include <portabledeviceapi.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "base/synchronization/lock.h"
17 #include "base/system_monitor/system_monitor.h" 18 #include "base/system_monitor/system_monitor.h"
18 19
19 namespace base { 20 namespace base {
20 class SequencedTaskRunner; 21 class SequencedTaskRunner;
21 } 22 }
22 23
23 class FilePath; 24 class FilePath;
24 25
25 namespace chrome { 26 namespace chrome {
26 27
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 virtual ~PortableDeviceWatcherWin(); 65 virtual ~PortableDeviceWatcherWin();
65 66
66 // Must be called after the browser blocking pool is ready for use. 67 // Must be called after the browser blocking pool is ready for use.
67 // RemovableDeviceNotificationsWindowsWin::Init() will call this function. 68 // RemovableDeviceNotificationsWindowsWin::Init() will call this function.
68 void Init(HWND hwnd); 69 void Init(HWND hwnd);
69 70
70 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a 71 // Processes DEV_BROADCAST_DEVICEINTERFACE messages and triggers a
71 // SystemMonitor notification if appropriate. 72 // SystemMonitor notification if appropriate.
72 void OnWindowMessage(UINT event_type, LPARAM data); 73 void OnWindowMessage(UINT event_type, LPARAM data);
73 74
75 // Gets the information of the MTP storage specified by |storage_device_id|.
76 // On success, returns true and fills in |device_location| with device
77 // interface details and |storage_object_id| with storage object temporary
78 // identifier.
79 bool GetMTPStorageInfoFromDeviceId(const std::string& storage_device_id,
80 string16* device_location,
81 string16* storage_object_id);
82
74 private: 83 private:
75 friend class TestPortableDeviceWatcherWin; 84 friend class TestPortableDeviceWatcherWin;
76 85
77 // Key: MTP device storage unique id. 86 // Key: MTP device storage unique id.
78 // Value: Metadata for the given storage. 87 // Value: Metadata for the given storage.
79 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo> 88 typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo>
80 MTPStorageMap; 89 MTPStorageMap;
81 90
82 // Key: MTP device plug and play ID string. 91 // Key: MTP device plug and play ID string.
83 // Value: Vector of device storage objects. 92 // Value: Vector of device storage objects.
(...skipping 14 matching lines...) Expand all
98 107
99 // The portable device notifications handle. 108 // The portable device notifications handle.
100 HDEVNOTIFY notifications_; 109 HDEVNOTIFY notifications_;
101 110
102 // Attached media transfer protocol device map. 111 // Attached media transfer protocol device map.
103 MTPDeviceMap device_map_; 112 MTPDeviceMap device_map_;
104 113
105 // Attached media transfer protocol device storage objects map. 114 // Attached media transfer protocol device storage objects map.
106 MTPStorageMap storage_map_; 115 MTPStorageMap storage_map_;
107 116
117 // The lock to protect |device_map_| and |storage_map_|.
118 // TODO(kmadhusu): Remove this after fixing crbug.com/154835.
119 base::Lock lock_;
120
108 // The task runner used to execute tasks that may take a long time and thus 121 // The task runner used to execute tasks that may take a long time and thus
109 // should not be performed on the UI thread. 122 // should not be performed on the UI thread.
110 scoped_refptr<base::SequencedTaskRunner> media_task_runner_; 123 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
111 124
112 // Used by |media_task_runner_| to create cancelable callbacks. 125 // Used by |media_task_runner_| to create cancelable callbacks.
113 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_; 126 base::WeakPtrFactory<PortableDeviceWatcherWin> weak_ptr_factory_;
114 127
115 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin); 128 DISALLOW_COPY_AND_ASSIGN(PortableDeviceWatcherWin);
116 }; 129 };
117 130
118 } // namespace chrome 131 } // namespace chrome
119 132
120 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_ 133 #endif // CHROME_BROWSER_SYSTEM_MONITOR_PORTABLE_DEVICE_WATCHER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698