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

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: Rebase and add available_capacity into the observer callback 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()->set_storage_free_space_delegate(NULL);
91
86 if (window_) 92 if (window_)
87 DestroyWindow(window_); 93 DestroyWindow(window_);
88 94
89 if (atom_) 95 if (atom_)
90 UnregisterClass(MAKEINTATOM(atom_), instance_); 96 UnregisterClass(MAKEINTATOM(atom_), instance_);
91 } 97 }
92 98
93 LRESULT RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type, 99 LRESULT RemovableDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type,
94 DWORD data) { 100 DWORD data) {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 RemovableDeviceNotificationsWindowWin::ProcessRemovableDeviceAttachedOnUIThread( 159 RemovableDeviceNotificationsWindowWin::ProcessRemovableDeviceAttachedOnUIThread(
154 const std::string& id, 160 const std::string& id,
155 const FilePath::StringType& device_name, 161 const FilePath::StringType& device_name,
156 const FilePath& path) { 162 const FilePath& path) {
157 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
158 164
159 SystemMonitor::Get()->ProcessRemovableStorageAttached(id, 165 SystemMonitor::Get()->ProcessRemovableStorageAttached(id,
160 device_name, 166 device_name,
161 path.value()); 167 path.value());
162 } 168 }
169 bool RemovableDeviceNotificationsWindowWin::IsWatchingStorage(
170 const FilePath& path) {
171 NOTIMPLEMENTED();
172 return false;
173 }
174
175 void RemovableDeviceNotificationsWindowWin::StartWatchingStorage(
176 const FilePath& path) {
177 NOTIMPLEMENTED();
178 }
179
180 void RemovableDeviceNotificationsWindowWin::StopWatchingStorage(
181 const FilePath& path) {
182 NOTIMPLEMENTED();
183 }
163 184
164 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProc( 185 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProc(
165 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { 186 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
166 switch (message) { 187 switch (message) {
167 case WM_DEVICECHANGE: 188 case WM_DEVICECHANGE:
168 return OnDeviceChange(static_cast<UINT>(wparam), 189 return OnDeviceChange(static_cast<UINT>(wparam),
169 static_cast<DWORD>(lparam)); 190 static_cast<DWORD>(lparam));
170 default: 191 default:
171 break; 192 break;
172 } 193 }
173 194
174 return ::DefWindowProc(hwnd, message, wparam, lparam); 195 return ::DefWindowProc(hwnd, message, wparam, lparam);
175 } 196 }
176 197
177 // static 198 // static
178 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProcThunk( 199 LRESULT CALLBACK RemovableDeviceNotificationsWindowWin::WndProcThunk(
179 HWND hwnd, 200 HWND hwnd,
180 UINT message, 201 UINT message,
181 WPARAM wparam, 202 WPARAM wparam,
182 LPARAM lparam) { 203 LPARAM lparam) {
183 RemovableDeviceNotificationsWindowWin* msg_wnd = 204 RemovableDeviceNotificationsWindowWin* msg_wnd =
184 reinterpret_cast<RemovableDeviceNotificationsWindowWin*>( 205 reinterpret_cast<RemovableDeviceNotificationsWindowWin*>(
185 GetWindowLongPtr(hwnd, GWLP_USERDATA)); 206 GetWindowLongPtr(hwnd, GWLP_USERDATA));
186 if (msg_wnd) 207 if (msg_wnd)
187 return msg_wnd->WndProc(hwnd, message, wparam, lparam); 208 return msg_wnd->WndProc(hwnd, message, wparam, lparam);
188 return ::DefWindowProc(hwnd, message, wparam, lparam); 209 return ::DefWindowProc(hwnd, message, wparam, lparam);
189 } 210 }
190 211
191 } // namespace chrome 212 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698