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

Side by Side Diff: chrome/browser/chromeos/usb_mount_observer.h

Issue 6674043: Rewritten MountLibrary to work with non-blocking mount API calls in libcros.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_CHROMEOS_USB_MOUNT_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_
6 #define CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <map>
10 #include <vector> 11 #include <vector>
11 12
12 #include "chrome/browser/chromeos/cros/mount_library.h" 13 #include "chrome/browser/chromeos/cros/mount_library.h"
13 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
15 #include "content/common/notification_source.h" 16 #include "content/common/notification_source.h"
16 #include "content/common/notification_type.h" 17 #include "content/common/notification_type.h"
17 18
18 class Browser; 19 class Browser;
19 template <typename T> struct DefaultSingletonTraits; 20 template <typename T> struct DefaultSingletonTraits;
20 class Profile; 21 class Profile;
21 22
22 namespace chromeos { // NOLINT 23 namespace chromeos { // NOLINT
23 24
24 // Used to monitor mount changes and popup a new window when 25 // Used to monitor mount changes and popup a new window when
25 // a new mounted usb device is found. 26 // a new mounted usb device is found.
26 class USBMountObserver : public chromeos::MountLibrary::Observer, 27 class USBMountObserver : public MountLibrary::Observer,
27 public NotificationObserver { 28 public NotificationObserver {
28 public: 29 public:
29 struct BrowserWithPath { 30 struct BrowserWithPath {
30 Browser* browser; 31 Browser* browser;
31 std::string device_path; 32 std::string device_path;
32 std::string mount_path; 33 std::string mount_path;
33 }; 34 };
34 35
35 static USBMountObserver* GetInstance(); 36 static USBMountObserver* GetInstance();
36 37
37 void Observe(NotificationType type, 38 // NotificationObserver overrides.
38 const NotificationSource& source, 39 virtual void Observe(NotificationType type,
39 const NotificationDetails& details); 40 const NotificationSource& source,
41 const NotificationDetails& details);
40 42
41 void MountChanged(chromeos::MountLibrary* obj, 43 // MountLibrary::Observer overrides.
42 chromeos::MountEventType evt, 44 virtual void DiskChanged(MountLibraryEventType event,
43 const std::string& path); 45 const MountLibrary::Disk* disk);
44 46 virtual void DeviceChanged(MountLibraryEventType event,
45 void ScanForDevices(chromeos::MountLibrary* obj); 47 const std::string& device_path);
46 48
47 private: 49 private:
48 friend struct DefaultSingletonTraits<USBMountObserver>; 50 friend struct DefaultSingletonTraits<USBMountObserver>;
49 typedef std::vector<BrowserWithPath>::iterator BrowserIterator; 51 typedef std::vector<BrowserWithPath>::iterator BrowserIterator;
52 typedef std::map<std::string, std::string> MountPointMap;
53
54 USBMountObserver() {}
55 virtual ~USBMountObserver() {}
56
57 // USB mount event handlers.
58 void OnDiskAdded(const MountLibrary::Disk* disk);
59 void OnDiskRemoved(const MountLibrary::Disk* disk);
60 void OnDiskChanged(const MountLibrary::Disk* disk);
61 void OnDeviceAdded(const std::string& device_path);
62 void OnDeviceRemoved(const std::string& device_path);
63 void OnDeviceScanned(const std::string& device_path);
64
50 BrowserIterator FindBrowserForPath(const std::string& path); 65 BrowserIterator FindBrowserForPath(const std::string& path);
51 66
52 USBMountObserver() {} 67 // Sends filesystem changed extension message to all renderers.
53 ~USBMountObserver() {} 68 void FireFileSystemChanged(const std::string& web_path);
54 69
55 void RemoveBrowserFromVector(const std::string& path); 70 void RemoveBrowserFromVector(const std::string& path);
56 71
57 // Used to create a window of a standard size, and add it to a list 72 // Used to create a window of a standard size, and add it to a list
58 // of tracked browser windows in case that device goes away. 73 // of tracked browser windows in case that device goes away.
59 void OpenFileBrowse(const std::string& url, 74 void OpenFileBrowse(const std::string& url,
60 const std::string& device_path, 75 const std::string& device_path,
61 bool small); 76 bool small);
62 77
63 std::vector<BrowserWithPath> browsers_; 78 std::vector<BrowserWithPath> browsers_;
64 NotificationRegistrar registrar_; 79 NotificationRegistrar registrar_;
80 MountPointMap mounted_devices_;
65 81
66 DISALLOW_COPY_AND_ASSIGN(USBMountObserver); 82 DISALLOW_COPY_AND_ASSIGN(USBMountObserver);
67 }; 83 };
68 84
69 } // namespace chromeos 85 } // namespace chromeos
70 #endif // CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_ 86 #endif // CHROME_BROWSER_CHROMEOS_USB_MOUNT_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mount_library.cc ('k') | chrome/browser/chromeos/usb_mount_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698