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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_window_win.cc

Issue 10917166: Extend the capability of SystemMonitor to support watching storage free space change (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: updated patch Created 8 years, 3 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 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi n.h" 5 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi n.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <dbt.h> 8 #include <dbt.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 RemovableDeviceNotificationsWindowWin::WndProcThunk>, 72 RemovableDeviceNotificationsWindowWin::WndProcThunk>,
73 0, 0, 0, NULL, NULL, NULL, NULL, NULL, 73 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
74 &window_class); 74 &window_class);
75 instance_ = window_class.hInstance; 75 instance_ = window_class.hInstance;
76 atom_ = RegisterClassEx(&window_class); 76 atom_ = RegisterClassEx(&window_class);
77 DCHECK(atom_); 77 DCHECK(atom_);
78 78
79 window_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0, 0, 0, instance_, 79 window_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0, 0, 0, instance_,
80 0); 80 0);
81 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); 81 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
82
83 if (SystemMonitor::Get())
84 SystemMonitor::Get()->set_storage_free_space_delegate(this);
82 } 85 }
83 86
84 RemovableDeviceNotificationsWindowWin::~RemovableDeviceNotificationsWindowWin( 87 RemovableDeviceNotificationsWindowWin::~RemovableDeviceNotificationsWindowWin(
85 ) { 88 ) {
89 if (SystemMonitor::Get() &&
90 SystemMonitor::Get()->storage_free_space_delegate())
91 SystemMonitor::Get()->set_storage_free_space_delegate(NULL);
92
86 if (window_) 93 if (window_)
87 DestroyWindow(window_); 94 DestroyWindow(window_);
88 95
89 if (atom_) 96 if (atom_)
90 UnregisterClass(MAKEINTATOM(atom_), instance_); 97 UnregisterClass(MAKEINTATOM(atom_), instance_);
91 } 98 }
92 99
93 LRESULT RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type, 100 LRESULT RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type,
94 DWORD data) { 101 DWORD data) {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const std::string& id, 161 const std::string& id,
155 const FilePath::StringType& device_name, 162 const FilePath::StringType& device_name,
156 const FilePath& path) { 163 const FilePath& path) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 165
159 SystemMonitor::Get()->ProcessRemovableStorageAttached(id, 166 SystemMonitor::Get()->ProcessRemovableStorageAttached(id,
160 device_name, 167 device_name,
161 path.value()); 168 path.value());
162 } 169 }
163 170
171 void RemovableDeviceNotificationsWindowWin::StartWatchingStorage(
172 const FilePath& path) {
173 NOTIMPLEMENTED();
174 }
175
176 void RemovableDeviceNotificationsWindowWin::StopWatchingStorage(
177 const FilePath& path) {
178 NOTIMPLEMENTED();
179 }
180
164 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProc( 181 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProc(
165 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { 182 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
166 switch (message) { 183 switch (message) {
167 case WM_DEVICECHANGE: 184 case WM_DEVICECHANGE:
168 return OnDeviceChange(static_cast<UINT>(wparam), 185 return OnDeviceChange(static_cast<UINT>(wparam),
169 static_cast<DWORD>(lparam)); 186 static_cast<DWORD>(lparam));
170 default: 187 default:
171 break; 188 break;
172 } 189 }
173 190
174 return ::DefWindowProc(hwnd, message, wparam, lparam); 191 return ::DefWindowProc(hwnd, message, wparam, lparam);
175 } 192 }
176 193
177 // static 194 // static
178 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProcThunk( 195 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProcThunk(
179 HWND hwnd, 196 HWND hwnd,
180 UINT message, 197 UINT message,
181 WPARAM wparam, 198 WPARAM wparam,
182 LPARAM lparam) { 199 LPARAM lparam) {
183 RemovableDeviceNotificationsWindowWin* msg_wnd = 200 RemovableDeviceNotificationsWindowWin* msg_wnd =
184 reinterpret_cast<RemovableDeviceNotificationsWindowWin*>( 201 reinterpret_cast<RemovableDeviceNotificationsWindowWin*>(
185 GetWindowLongPtr(hwnd, GWLP_USERDATA)); 202 GetWindowLongPtr(hwnd, GWLP_USERDATA));
186 if (msg_wnd) 203 if (msg_wnd)
187 return msg_wnd->WndProc(hwnd, message, wparam, lparam); 204 return msg_wnd->WndProc(hwnd, message, wparam, lparam);
188 return ::DefWindowProc(hwnd, message, wparam, lparam); 205 return ::DefWindowProc(hwnd, message, wparam, lparam);
189 } 206 }
190 207
191 } // namespace chrome 208 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698