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

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

Issue 13524003: [StorageMonitor] Remove GetStorageSize. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Compiling... Created 7 years, 8 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/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
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); 72 SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
73 volume_mount_watcher_->Init(); 73 volume_mount_watcher_->Init();
74 portable_device_watcher_->Init(window_); 74 portable_device_watcher_->Init(window_);
75 } 75 }
76 76
77 bool StorageMonitorWin::GetStorageInfoForPath(const base::FilePath& path, 77 bool StorageMonitorWin::GetStorageInfoForPath(const base::FilePath& path,
78 StorageInfo* device_info) const { 78 StorageInfo* device_info) const {
79 string16 location; 79 string16 location;
80 std::string unique_id; 80 std::string unique_id;
81 string16 name; 81 string16 name;
82 bool removable; 82 bool removable = false;
83 uint64 total_size_in_bytes; 83 uint64 total_size_in_bytes = 0;
84 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable, 84 if (!GetDeviceInfo(path, &location, &unique_id, &name, &removable,
85 &total_size_in_bytes)) { 85 &total_size_in_bytes)) {
86 return false; 86 return false;
87 } 87 }
88 88
89 // To compute the device id, the device type is needed. For removable 89 // To compute the device id, the device type is needed. For removable
90 // devices, that requires knowing if there's a DCIM directory, which would 90 // devices, that requires knowing if there's a DCIM directory, which would
91 // require bouncing over to the file thread. Instead, just iterate the 91 // require bouncing over to the file thread. Instead, just iterate the
92 // devices. 92 // devices.
93 std::string device_id; 93 std::string device_id;
(...skipping 15 matching lines...) Expand all
109 return false; 109 return false;
110 } else { 110 } else {
111 device_id = MediaStorageUtil::MakeDeviceId( 111 device_id = MediaStorageUtil::MakeDeviceId(
112 MediaStorageUtil::FIXED_MASS_STORAGE, unique_id); 112 MediaStorageUtil::FIXED_MASS_STORAGE, unique_id);
113 } 113 }
114 114
115 if (device_info) { 115 if (device_info) {
116 device_info->device_id = device_id; 116 device_info->device_id = device_id;
117 device_info->name = name; 117 device_info->name = name;
118 device_info->location = location; 118 device_info->location = location;
119 device_info->total_size_in_bytes = total_size_in_bytes;
119 } 120 }
120 return true; 121 return true;
121 } 122 }
122 123
123 uint64 StorageMonitorWin::GetStorageSize(
124 const base::FilePath::StringType& location) const {
125 return volume_mount_watcher_->GetStorageSize(location);
126 }
127
128 bool StorageMonitorWin::GetMTPStorageInfoFromDeviceId( 124 bool StorageMonitorWin::GetMTPStorageInfoFromDeviceId(
129 const std::string& storage_device_id, 125 const std::string& storage_device_id,
130 string16* device_location, 126 string16* device_location,
131 string16* storage_object_id) const { 127 string16* storage_object_id) const {
132 MediaStorageUtil::Type type; 128 MediaStorageUtil::Type type;
133 MediaStorageUtil::CrackDeviceId(storage_device_id, &type, NULL); 129 MediaStorageUtil::CrackDeviceId(storage_device_id, &type, NULL);
134 return ((type == MediaStorageUtil::MTP_OR_PTP) && 130 return ((type == MediaStorageUtil::MTP_OR_PTP) &&
135 portable_device_watcher_->GetMTPStorageInfoFromDeviceId( 131 portable_device_watcher_->GetMTPStorageInfoFromDeviceId(
136 storage_device_id, device_location, storage_object_id)); 132 storage_device_id, device_location, storage_object_id));
137 } 133 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 unique_id, name, removable, 168 unique_id, name, removable,
173 total_size_in_bytes); 169 total_size_in_bytes);
174 } 170 }
175 171
176 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) { 172 void StorageMonitorWin::OnDeviceChange(UINT event_type, LPARAM data) {
177 volume_mount_watcher_->OnWindowMessage(event_type, data); 173 volume_mount_watcher_->OnWindowMessage(event_type, data);
178 portable_device_watcher_->OnWindowMessage(event_type, data); 174 portable_device_watcher_->OnWindowMessage(event_type, data);
179 } 175 }
180 176
181 } // namespace chrome 177 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/storage_monitor/storage_monitor_win.h ('k') | chrome/browser/storage_monitor/test_storage_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698