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

Side by Side Diff: components/storage_monitor/storage_info.cc

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « components/storage_monitor/storage_info.h ('k') | components/storage_monitor/storage_monitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/storage_monitor/storage_info.h" 5 #include "components/storage_monitor/storage_info.h"
6 6
7 #include <stddef.h>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
9 #include "components/storage_monitor/media_storage_util.h" 11 #include "components/storage_monitor/media_storage_util.h"
10 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/text/bytes_formatting.h" 13 #include "ui/base/text/bytes_formatting.h"
12 14
13 namespace { 15 namespace {
14 16
15 // Prefix constants for different device id spaces. 17 // Prefix constants for different device id spaces.
16 const char kRemovableMassStorageWithDCIMPrefix[] = "dcim:"; 18 const char kRemovableMassStorageWithDCIMPrefix[] = "dcim:";
17 const char kRemovableMassStorageNoDCIMPrefix[] = "nodcim:"; 19 const char kRemovableMassStorageNoDCIMPrefix[] = "nodcim:";
18 const char kFixedMassStoragePrefix[] = "path:"; 20 const char kFixedMassStoragePrefix[] = "path:";
19 const char kMtpPtpPrefix[] = "mtp:"; 21 const char kMtpPtpPrefix[] = "mtp:";
20 const char kMacImageCapturePrefix[] = "ic:"; 22 const char kMacImageCapturePrefix[] = "ic:";
21 const char kITunesPrefix[] = "itunes:"; 23 const char kITunesPrefix[] = "itunes:";
22 const char kPicasaPrefix[] = "picasa:"; 24 const char kPicasaPrefix[] = "picasa:";
23 const char kIPhotoPrefix[] = "iphoto:"; 25 const char kIPhotoPrefix[] = "iphoto:";
24 26
25 base::string16 GetDisplayNameForDevice(uint64 storage_size_in_bytes, 27 base::string16 GetDisplayNameForDevice(uint64_t storage_size_in_bytes,
26 const base::string16& name) { 28 const base::string16& name) {
27 DCHECK(!name.empty()); 29 DCHECK(!name.empty());
28 return (storage_size_in_bytes == 0) ? 30 return (storage_size_in_bytes == 0) ?
29 name : 31 name :
30 ui::FormatBytes(storage_size_in_bytes) + base::ASCIIToUTF16(" ") + name; 32 ui::FormatBytes(storage_size_in_bytes) + base::ASCIIToUTF16(" ") + name;
31 } 33 }
32 34
33 base::string16 GetFullProductName(const base::string16& vendor_name, 35 base::string16 GetFullProductName(const base::string16& vendor_name,
34 const base::string16& model_name) { 36 const base::string16& model_name) {
35 if (vendor_name.empty() && model_name.empty()) 37 if (vendor_name.empty() && model_name.empty())
(...skipping 15 matching lines...) Expand all
51 namespace storage_monitor { 53 namespace storage_monitor {
52 54
53 StorageInfo::StorageInfo() : total_size_in_bytes_(0) { 55 StorageInfo::StorageInfo() : total_size_in_bytes_(0) {
54 } 56 }
55 57
56 StorageInfo::StorageInfo(const std::string& device_id_in, 58 StorageInfo::StorageInfo(const std::string& device_id_in,
57 const base::FilePath::StringType& device_location, 59 const base::FilePath::StringType& device_location,
58 const base::string16& label, 60 const base::string16& label,
59 const base::string16& vendor, 61 const base::string16& vendor,
60 const base::string16& model, 62 const base::string16& model,
61 uint64 size_in_bytes) 63 uint64_t size_in_bytes)
62 : device_id_(device_id_in), 64 : device_id_(device_id_in),
63 location_(device_location), 65 location_(device_location),
64 storage_label_(label), 66 storage_label_(label),
65 vendor_name_(vendor), 67 vendor_name_(vendor),
66 model_name_(model), 68 model_name_(model),
67 total_size_in_bytes_(size_in_bytes) { 69 total_size_in_bytes_(size_in_bytes) {}
68 }
69 70
70 StorageInfo::~StorageInfo() { 71 StorageInfo::~StorageInfo() {
71 } 72 }
72 73
73 // static 74 // static
74 std::string StorageInfo::MakeDeviceId(Type type, const std::string& unique_id) { 75 std::string StorageInfo::MakeDeviceId(Type type, const std::string& unique_id) {
75 DCHECK(!unique_id.empty()); 76 DCHECK(!unique_id.empty());
76 switch (type) { 77 switch (type) {
77 case REMOVABLE_MASS_STORAGE_WITH_DCIM: 78 case REMOVABLE_MASS_STORAGE_WITH_DCIM:
78 return std::string(kRemovableMassStorageWithDCIMPrefix) + unique_id; 79 return std::string(kRemovableMassStorageWithDCIMPrefix) + unique_id;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 name = GetFullProductName(vendor_name_, model_name_); 206 name = GetFullProductName(vendor_name_, model_name_);
206 if (name.empty()) 207 if (name.empty())
207 name = base::ASCIIToUTF16("Unlabeled device"); 208 name = base::ASCIIToUTF16("Unlabeled device");
208 209
209 if (with_size) 210 if (with_size)
210 name = GetDisplayNameForDevice(total_size_in_bytes_, name); 211 name = GetDisplayNameForDevice(total_size_in_bytes_, name);
211 return name; 212 return name;
212 } 213 }
213 214
214 } // namespace storage_monitor 215 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_info.h ('k') | components/storage_monitor/storage_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698