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

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

Issue 16056002: Cleanup Various bits of Windows StorageMonitor classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 #include "chrome/browser/storage_monitor/storage_monitor_win.h" 5 #include "chrome/browser/storage_monitor/storage_monitor_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbt.h> 8 #include <dbt.h>
9 #include <fileapi.h> 9 #include <fileapi.h>
10 10
11 #include "base/win/wrapped_window_proc.h" 11 #include "base/win/wrapped_window_proc.h"
12 #include "chrome/browser/storage_monitor/portable_device_watcher_win.h" 12 #include "chrome/browser/storage_monitor/portable_device_watcher_win.h"
13 #include "chrome/browser/storage_monitor/removable_device_constants.h" 13 #include "chrome/browser/storage_monitor/removable_device_constants.h"
14 #include "chrome/browser/storage_monitor/storage_info.h" 14 #include "chrome/browser/storage_monitor/storage_info.h"
15 #include "chrome/browser/storage_monitor/volume_mount_watcher_win.h" 15 #include "chrome/browser/storage_monitor/volume_mount_watcher_win.h"
16 16
17 namespace chrome { 17 namespace chrome {
18 18
19 namespace {
20
21 const char16 kWindowClassName[] = L"Chrome_StorageMonitorWindow";
22
23 } // namespace
24
25
26 // StorageMonitorWin ------------------------------------------------------- 19 // StorageMonitorWin -------------------------------------------------------
27 20
28 // static 21 // static
29 StorageMonitorWin* StorageMonitorWin::Create() { 22 StorageMonitorWin* StorageMonitorWin::Create() {
30 return new StorageMonitorWin(new VolumeMountWatcherWin(), 23 return new StorageMonitorWin(new VolumeMountWatcherWin(),
31 new PortableDeviceWatcherWin()); 24 new PortableDeviceWatcherWin());
32 } 25 }
33 26
34 StorageMonitorWin::StorageMonitorWin( 27 StorageMonitorWin::StorageMonitorWin(
35 VolumeMountWatcherWin* volume_mount_watcher, 28 VolumeMountWatcherWin* volume_mount_watcher,
(...skipping 16 matching lines...) Expand all
52 if (window_) 45 if (window_)
53 DestroyWindow(window_); 46 DestroyWindow(window_);
54 47
55 if (window_class_) 48 if (window_class_)
56 UnregisterClass(MAKEINTATOM(window_class_), instance_); 49 UnregisterClass(MAKEINTATOM(window_class_), instance_);
57 } 50 }
58 51
59 void StorageMonitorWin::Init() { 52 void StorageMonitorWin::Init() {
60 WNDCLASSEX window_class; 53 WNDCLASSEX window_class;
61 base::win::InitializeWindowClass( 54 base::win::InitializeWindowClass(
62 kWindowClassName, 55 L"Chrome_StorageMonitorWindow",
63 &base::win::WrappedWindowProc<StorageMonitorWin::WndProcThunk>, 56 &base::win::WrappedWindowProc<StorageMonitorWin::WndProcThunk>,
64 0, 0, 0, NULL, NULL, NULL, NULL, NULL, 57 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
65 &window_class); 58 &window_class);
66 instance_ = window_class.hInstance; 59 instance_ = window_class.hInstance;
67 window_class_ = RegisterClassEx(&window_class); 60 window_class_ = RegisterClassEx(&window_class);
68 DCHECK(window_class_); 61 DCHECK(window_class_);
69 62
70 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0, 63 window_ = CreateWindow(MAKEINTATOM(window_class_), 0, 0, 0, 0, 0, 0, 0, 0,
71 instance_, 0); 64 instance_, 0);
72 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); 65 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (type == StorageInfo::MTP_OR_PTP) 111 if (type == StorageInfo::MTP_OR_PTP)
119 portable_device_watcher_->EjectDevice(device_id, callback); 112 portable_device_watcher_->EjectDevice(device_id, callback);
120 else if (StorageInfo::IsRemovableDevice(device_id)) 113 else if (StorageInfo::IsRemovableDevice(device_id))
121 volume_mount_watcher_->EjectDevice(device_id, callback); 114 volume_mount_watcher_->EjectDevice(device_id, callback);
122 else 115 else
123 callback.Run(EJECT_FAILURE); 116 callback.Run(EJECT_FAILURE);
124 } 117 }
125 118
126 bool StorageMonitorWin::GetMTPStorageInfoFromDeviceId( 119 bool StorageMonitorWin::GetMTPStorageInfoFromDeviceId(
127 const std::string& storage_device_id, 120 const std::string& storage_device_id,
128 string16* device_location, 121 base::string16* device_location,
129 string16* storage_object_id) const { 122 base::string16* storage_object_id) const {
130 StorageInfo::Type type; 123 StorageInfo::Type type;
131 StorageInfo::CrackDeviceId(storage_device_id, &type, NULL); 124 StorageInfo::CrackDeviceId(storage_device_id, &type, NULL);
132 return ((type == StorageInfo::MTP_OR_PTP) && 125 return ((type == StorageInfo::MTP_OR_PTP) &&
133 portable_device_watcher_->GetMTPStorageInfoFromDeviceId( 126 portable_device_watcher_->GetMTPStorageInfoFromDeviceId(
134 storage_device_id, device_location, storage_object_id)); 127 storage_device_id, device_location, storage_object_id));
135 } 128 }
136 129
137 // static 130 // static
138 LRESULT CALLBACK StorageMonitorWin::WndProcThunk(HWND hwnd, UINT message, 131 LRESULT CALLBACK StorageMonitorWin::WndProcThunk(HWND hwnd, UINT message,
139 WPARAM wparam, LPARAM lparam) { 132 WPARAM wparam, LPARAM lparam) {
(...skipping 12 matching lines...) Expand all
152 return TRUE; 145 return TRUE;
153 default: 146 default:
154 break; 147 break;
155 } 148 }
156 149
157 return ::DefWindowProc(hwnd, message, wparam, lparam); 150 return ::DefWindowProc(hwnd, message, wparam, lparam);
158 } 151 }
159 152
160 bool StorageMonitorWin::GetDeviceInfo(const base::FilePath& device_path, 153 bool StorageMonitorWin::GetDeviceInfo(const base::FilePath& device_path,
161 StorageInfo* info) const { 154 StorageInfo* info) const {
155 DCHECK(info);
156
162 // TODO(kmadhusu) Implement PortableDeviceWatcherWin::GetDeviceInfo() 157 // TODO(kmadhusu) Implement PortableDeviceWatcherWin::GetDeviceInfo()
163 // function when we have the functionality to add a sub directory of 158 // function when we have the functionality to add a sub directory of
164 // portable device as a media gallery. 159 // portable device as a media gallery.
165 return volume_mount_watcher_->GetDeviceInfo(device_path, info); 160 return volume_mount_watcher_->GetDeviceInfo(device_path, info);
166 } 161 }
167 162
168 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) { 163 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) {
169 volume_mount_watcher_->OnWindowMessage(event_type, data); 164 volume_mount_watcher_->OnWindowMessage(event_type, data);
170 portable_device_watcher_->OnWindowMessage(event_type, data); 165 portable_device_watcher_->OnWindowMessage(event_type, data);
171 } 166 }
172 167
173 } // namespace chrome 168 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_win.h ('k') | chrome/browser/storage_monitor/storage_monitor_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698