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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_win.h

Issue 16703025: [StorageMonitor] Move StorageMonitor ownership to BrowserProcessImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set storage monitor in browser process for unit tests. etc. Created 7 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
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_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 5 #ifndef CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 6 #define CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/storage_monitor/storage_monitor.h" 11 #include "chrome/browser/storage_monitor/storage_monitor.h"
12 12
13 namespace base { 13 namespace base {
14 class FilePath; 14 class FilePath;
15 } 15 }
16 16
17 namespace chrome { 17 namespace chrome {
18 18
19 namespace test { 19 namespace test {
20 class TestStorageMonitorWin; 20 class TestStorageMonitorWin;
21 } 21 }
22 22
23 class PortableDeviceWatcherWin; 23 class PortableDeviceWatcherWin;
24 class VolumeMountWatcherWin; 24 class VolumeMountWatcherWin;
25 25
26 class StorageMonitorWin : public StorageMonitor { 26 class StorageMonitorWin : public StorageMonitor {
27 public: 27 public:
28 // Creates an instance of StorageMonitorWin. Should only be called by browser 28 // To support unit tests, this constructor takes |volume_mount_watcher| and
29 // start up code. Use GetInstance() instead. 29 // |portable_device_watcher| objects. These params are either constructed in
30 static StorageMonitorWin* Create(); 30 // unit tests or in StorageMonitorWin::Create() function.
31 31 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher,
vandebo (ex-Chrome) 2013/07/09 15:38:12 Can this stay private?
Greg Billock 2013/07/09 17:35:21 Taking out Create() here means the factory method
vandebo (ex-Chrome) 2013/07/09 21:14:11 I think this constructor is only used for testing,
Greg Billock 2013/07/09 21:29:06 It's used by the factory as well. (The factory use
vandebo (ex-Chrome) 2013/07/10 16:57:45 Which factory? Searching the diff shows it used i
Greg Billock 2013/07/10 21:11:16 The StorageMonitor::Create method was what I meant
32 PortableDeviceWatcherWin* portable_device_watcher);
32 virtual ~StorageMonitorWin(); 33 virtual ~StorageMonitorWin();
33 34
34 // Must be called after the file thread is created. 35 // Must be called after the file thread is created.
35 virtual void Init() OVERRIDE; 36 virtual void Init() OVERRIDE;
36 37
37 // StorageMonitor: 38 // StorageMonitor:
38 virtual bool GetStorageInfoForPath(const base::FilePath& path, 39 virtual bool GetStorageInfoForPath(const base::FilePath& path,
39 StorageInfo* device_info) const OVERRIDE; 40 StorageInfo* device_info) const OVERRIDE;
40 virtual bool GetMTPStorageInfoFromDeviceId( 41 virtual bool GetMTPStorageInfoFromDeviceId(
41 const std::string& storage_device_id, 42 const std::string& storage_device_id,
42 base::string16* device_location, 43 base::string16* device_location,
43 base::string16* storage_object_id) const OVERRIDE; 44 base::string16* storage_object_id) const OVERRIDE;
44 45
45 virtual void EjectDevice( 46 virtual void EjectDevice(
46 const std::string& device_id, 47 const std::string& device_id,
47 base::Callback<void(EjectStatus)> callback) OVERRIDE; 48 base::Callback<void(EjectStatus)> callback) OVERRIDE;
48 49
49 private: 50 private:
50 class PortableDeviceNotifications; 51 class PortableDeviceNotifications;
51 friend class test::TestStorageMonitorWin; 52 friend class test::TestStorageMonitorWin;
52 53
53 // To support unit tests, this constructor takes |volume_mount_watcher| and
54 // |portable_device_watcher| objects. These params are either constructed in
55 // unit tests or in StorageMonitorWin::Create() function.
56 StorageMonitorWin(VolumeMountWatcherWin* volume_mount_watcher,
57 PortableDeviceWatcherWin* portable_device_watcher);
58
59 // Gets the removable storage information given a |device_path|. On success, 54 // Gets the removable storage information given a |device_path|. On success,
60 // returns true and fills in |info|. 55 // returns true and fills in |info|.
61 bool GetDeviceInfo(const base::FilePath& device_path, 56 bool GetDeviceInfo(const base::FilePath& device_path,
62 StorageInfo* info) const; 57 StorageInfo* info) const;
63 58
64 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam, 59 static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT message, WPARAM wparam,
65 LPARAM lparam); 60 LPARAM lparam);
66 61
67 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, 62 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam,
68 LPARAM lparam); 63 LPARAM lparam);
(...skipping 13 matching lines...) Expand all
82 // The portable device watcher, used to manage media transfer protocol 77 // The portable device watcher, used to manage media transfer protocol
83 // devices. 78 // devices.
84 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_; 79 scoped_ptr<PortableDeviceWatcherWin> portable_device_watcher_;
85 80
86 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin); 81 DISALLOW_COPY_AND_ASSIGN(StorageMonitorWin);
87 }; 82 };
88 83
89 } // namespace chrome 84 } // namespace chrome
90 85
91 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_ 86 #endif // CHROME_BROWSER_STORAGE_MONITOR_STORAGE_MONITOR_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698