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

Side by Side Diff: chrome/browser/chromeos/cros/mount_library.h

Issue 1142005: Mocks for all libcros elements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_CROS_MOUNT_LIBRARY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 }; 38 };
39 typedef std::vector<Disk> DiskVector; 39 typedef std::vector<Disk> DiskVector;
40 40
41 class Observer { 41 class Observer {
42 public: 42 public:
43 virtual void MountChanged(MountLibrary* obj, 43 virtual void MountChanged(MountLibrary* obj,
44 MountEventType evt, 44 MountEventType evt,
45 const std::string& path) = 0; 45 const std::string& path) = 0;
46 }; 46 };
47 47
48 // This gets the singleton MountLibrary 48 virtual ~MountLibrary() {}
49 static MountLibrary* Get(); 49 virtual void AddObserver(Observer* observer) = 0;
50 virtual void RemoveObserver(Observer* observer) = 0;
51 virtual const DiskVector& disks() const = 0;
52 };
50 53
51 void AddObserver(Observer* observer);
52 void RemoveObserver(Observer* observer);
53 54
54 const DiskVector& disks() const { return disks_; } 55 // This class handles the interaction with the ChromeOS mount library APIs.
56 // Classes can add themselves as observers. Users can get an instance of this
57 // library class like this: MountLibrary::Get().
58 class MountLibraryImpl : public MountLibrary {
59 public:
60 MountLibraryImpl();
61 virtual ~MountLibraryImpl();
62
63 // MountLibrary overrides.
64 virtual void AddObserver(Observer* observer);
65 virtual void RemoveObserver(Observer* observer);
66 virtual const DiskVector& disks() const { return disks_; }
55 67
56 private: 68 private:
57 friend struct DefaultSingletonTraits<MountLibrary>;
58
59 void ParseDisks(const MountStatus& status); 69 void ParseDisks(const MountStatus& status);
60 70
61 MountLibrary();
62 ~MountLibrary();
63
64 // This method is called when there's a change in mount status. 71 // This method is called when there's a change in mount status.
65 // This method is called the UI Thread. 72 // This method is called the UI Thread.
66 static void MountStatusChangedHandler(void* object, 73 static void MountStatusChangedHandler(void* object,
67 const MountStatus& status, 74 const MountStatus& status,
68 MountEventType evt, 75 MountEventType evt,
69 const char* path); 76 const char* path);
70 77
71 // This methods starts the monitoring of mount changes. 78 // This methods starts the monitoring of mount changes.
72 // It should be called on the UI Thread. 79 // It should be called on the UI Thread.
73 void Init(); 80 void Init();
74 81
75 // Called by the handler to update the mount status. 82 // Called by the handler to update the mount status.
76 // This will notify all the Observers. 83 // This will notify all the Observers.
77 void UpdateMountStatus(const MountStatus& status, 84 void UpdateMountStatus(const MountStatus& status,
78 MountEventType evt, 85 MountEventType evt,
79 const std::string& path); 86 const std::string& path);
80 87
81 ObserverList<Observer> observers_; 88 ObserverList<Observer> observers_;
82 89
83 // A reference to the mount api, to allow callbacks when the mount 90 // A reference to the mount api, to allow callbacks when the mount
84 // status changes. 91 // status changes.
85 MountStatusConnection mount_status_connection_; 92 MountStatusConnection mount_status_connection_;
86 93
87 // The list of disks found. 94 // The list of disks found.
88 DiskVector disks_; 95 DiskVector disks_;
89 96
90 DISALLOW_COPY_AND_ASSIGN(MountLibrary); 97 DISALLOW_COPY_AND_ASSIGN(MountLibraryImpl);
91 }; 98 };
92 99
93 } // namespace chromeos 100 } // namespace chromeos
94 101
95 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_ 102 #endif // CHROME_BROWSER_CHROMEOS_CROS_MOUNT_LIBRARY_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mock_synaptics_library.h ('k') | chrome/browser/chromeos/cros/mount_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698