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

Unified Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc

Issue 1492403002: Remove kuint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: http security header file Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
diff --git a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
index aacc58a36b3a28a136a60cf8f545f7ef1cb5e1ca..d00847a6d03c7bd1a5b8d014c84f58200fa2d0eb 100644
--- a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
+++ b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
@@ -6,7 +6,9 @@
#include <errno.h>
#include <fcntl.h>
+
#include <algorithm>
+#include <limits>
#include <vector>
#include "base/bind.h"
@@ -102,7 +104,7 @@ void OpenStorageOnUIThread(
void CreateDirectoryOnUIThread(
const std::string& storage_name,
const bool read_only,
- const uint32 parent_id,
+ const uint32_t parent_id,
const std::string& directory_name,
const MTPDeviceTaskHelper::CreateDirectorySuccessCallback& success_callback,
const MTPDeviceTaskHelper::ErrorCallback& error_callback) {
@@ -130,7 +132,7 @@ void CreateDirectoryOnUIThread(
void ReadDirectoryOnUIThread(
const std::string& storage_name,
const bool read_only,
- const uint32 directory_id,
+ const uint32_t directory_id,
const size_t max_size,
const MTPDeviceTaskHelper::ReadDirectorySuccessCallback& success_callback,
const MTPDeviceTaskHelper::ErrorCallback& error_callback) {
@@ -156,7 +158,7 @@ void ReadDirectoryOnUIThread(
void GetFileInfoOnUIThread(
const std::string& storage_name,
const bool read_only,
- uint32 file_id,
+ uint32_t file_id,
const MTPDeviceTaskHelper::GetFileInfoSuccessCallback& success_callback,
const MTPDeviceTaskHelper::ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -226,7 +228,7 @@ void ReadBytesOnUIThread(
void RenameObjectOnUIThread(
const std::string& storage_name,
const bool read_only,
- const uint32 object_id,
+ const uint32_t object_id,
const std::string& new_name,
const MTPDeviceTaskHelper::RenameObjectSuccessCallback& success_callback,
const MTPDeviceTaskHelper::ErrorCallback& error_callback) {
@@ -254,7 +256,7 @@ void CopyFileFromLocalOnUIThread(
const std::string& storage_name,
const bool read_only,
const int source_file_descriptor,
- const uint32 parent_id,
+ const uint32_t parent_id,
const std::string& file_name,
const MTPDeviceTaskHelper::CopyFileFromLocalSuccessCallback&
success_callback,
@@ -283,7 +285,7 @@ void CopyFileFromLocalOnUIThread(
void DeleteObjectOnUIThread(
const std::string storage_name,
const bool read_only,
- const uint32 object_id,
+ const uint32_t object_id,
const MTPDeviceTaskHelper::DeleteObjectSuccessCallback success_callback,
const MTPDeviceTaskHelper::ErrorCallback error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -348,8 +350,7 @@ void DeleteTemporaryFile(const base::FilePath& file_path) {
}
// A fake callback to be passed as CopyFileProgressCallback.
-void FakeCopyFileProgressCallback(int64 size) {
-}
+void FakeCopyFileProgressCallback(int64_t size) {}
} // namespace
@@ -371,7 +372,7 @@ MTPDeviceDelegateImplLinux::PendingTaskInfo::~PendingTaskInfo() {
// Lives on the IO thread.
class MTPDeviceDelegateImplLinux::MTPFileNode {
public:
- MTPFileNode(uint32 file_id,
+ MTPFileNode(uint32_t file_id,
const std::string& file_name,
MTPFileNode* parent,
FileIdToMTPFileNodeMap* file_id_to_node_map);
@@ -379,17 +380,17 @@ class MTPDeviceDelegateImplLinux::MTPFileNode {
const MTPFileNode* GetChild(const std::string& name) const;
- void EnsureChildExists(const std::string& name, uint32 id);
+ void EnsureChildExists(const std::string& name, uint32_t id);
// Clears all the children, except those in |children_to_keep|.
void ClearNonexistentChildren(
const std::set<std::string>& children_to_keep);
- bool DeleteChild(uint32 file_id);
+ bool DeleteChild(uint32_t file_id);
bool HasChildren() const;
- uint32 file_id() const { return file_id_; }
+ uint32_t file_id() const { return file_id_; }
const std::string& file_name() const { return file_name_; }
MTPFileNode* parent() { return parent_; }
@@ -398,7 +399,7 @@ class MTPDeviceDelegateImplLinux::MTPFileNode {
typedef base::ScopedPtrHashMap<std::string, scoped_ptr<MTPFileNode>>
ChildNodes;
- const uint32 file_id_;
+ const uint32_t file_id_;
const std::string file_name_;
ChildNodes children_;
@@ -409,7 +410,7 @@ class MTPDeviceDelegateImplLinux::MTPFileNode {
};
MTPDeviceDelegateImplLinux::MTPFileNode::MTPFileNode(
- uint32 file_id,
+ uint32_t file_id,
const std::string& file_name,
MTPFileNode* parent,
FileIdToMTPFileNodeMap* file_id_to_node_map)
@@ -438,7 +439,7 @@ MTPDeviceDelegateImplLinux::MTPFileNode::GetChild(
void MTPDeviceDelegateImplLinux::MTPFileNode::EnsureChildExists(
const std::string& name,
- uint32 id) {
+ uint32_t id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
const MTPFileNode* child = GetChild(name);
if (child && child->file_id() == id)
@@ -465,7 +466,7 @@ void MTPDeviceDelegateImplLinux::MTPFileNode::ClearNonexistentChildren(
}
}
-bool MTPDeviceDelegateImplLinux::MTPFileNode::DeleteChild(uint32 file_id) {
+bool MTPDeviceDelegateImplLinux::MTPFileNode::DeleteChild(uint32_t file_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
for (ChildNodes::iterator it = children_.begin();
it != children_.end(); ++it) {
@@ -615,7 +616,7 @@ bool MTPDeviceDelegateImplLinux::IsStreaming() {
void MTPDeviceDelegateImplLinux::ReadBytes(
const base::FilePath& device_file_path,
const scoped_refptr<net::IOBuffer>& buf,
- int64 offset,
+ int64_t offset,
int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
@@ -835,7 +836,7 @@ void MTPDeviceDelegateImplLinux::GetFileInfoInternal(
const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- uint32 file_id;
+ uint32_t file_id;
if (CachedPathToId(file_path, &file_id)) {
GetFileInfoSuccessCallback success_callback_wrapper =
base::Bind(&MTPDeviceDelegateImplLinux::OnDidGetFileInfo,
@@ -878,7 +879,7 @@ void MTPDeviceDelegateImplLinux::CreateDirectoryInternal(
if (other_components.empty()) {
// Either we reached the last component in the recursive case, or this is
// the non-recursive case.
- uint32 parent_id;
+ uint32_t parent_id;
if (CachedPathToId(current_component.DirName(), &parent_id)) {
const base::Closure closure =
base::Bind(&MTPDeviceDelegateImplLinux::CreateSingleDirectory,
@@ -891,7 +892,7 @@ void MTPDeviceDelegateImplLinux::CreateDirectoryInternal(
}
} else {
// Ensures that parent directories are created for recursive case.
- uint32 directory_id;
+ uint32_t directory_id;
if (CachedPathToId(current_component, &directory_id)) {
// Parent directory |current_component| already exists, continue creating
// directories.
@@ -934,7 +935,7 @@ void MTPDeviceDelegateImplLinux::ReadDirectoryInternal(
const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- uint32 dir_id;
+ uint32_t dir_id;
if (CachedPathToId(root, &dir_id)) {
GetFileInfoSuccessCallback success_callback_wrapper =
base::Bind(&MTPDeviceDelegateImplLinux::OnDidGetFileInfoToReadDirectory,
@@ -970,7 +971,7 @@ void MTPDeviceDelegateImplLinux::CreateSnapshotFileInternal(
const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- uint32 file_id;
+ uint32_t file_id;
if (CachedPathToId(device_file_path, &file_id)) {
scoped_ptr<SnapshotRequestInfo> request_info(
new SnapshotRequestInfo(file_id,
@@ -1005,12 +1006,14 @@ void MTPDeviceDelegateImplLinux::CreateSnapshotFileInternal(
void MTPDeviceDelegateImplLinux::ReadBytesInternal(
const base::FilePath& device_file_path,
- net::IOBuffer* buf, int64 offset, int buf_len,
+ net::IOBuffer* buf,
+ int64_t offset,
+ int buf_len,
const ReadBytesSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- uint32 file_id;
+ uint32_t file_id;
if (CachedPathToId(device_file_path, &file_id)) {
ReadBytesRequest request(
file_id, buf, offset, buf_len,
@@ -1050,7 +1053,7 @@ void MTPDeviceDelegateImplLinux::MoveFileLocalInternal(
if (source_file_path.DirName() == device_file_path.DirName()) {
// If a file is moved in a same directory, rename the file.
- uint32 file_id;
+ uint32_t file_id;
if (CachedPathToId(source_file_path, &file_id)) {
const MTPDeviceTaskHelper::RenameObjectSuccessCallback
success_callback_wrapper = base::Bind(
@@ -1097,7 +1100,7 @@ void MTPDeviceDelegateImplLinux::OnDidOpenFDToCopyFileFromLocal(
}
const int source_file_descriptor = open_fd_result.first;
- uint32 parent_id;
+ uint32_t parent_id;
if (CachedPathToId(device_file_path.DirName(), &parent_id)) {
CopyFileFromLocalSuccessCallback success_callback_wrapper =
base::Bind(&MTPDeviceDelegateImplLinux::OnDidCopyFileFromLocal,
@@ -1135,7 +1138,7 @@ void MTPDeviceDelegateImplLinux::DeleteFileInternal(
if (file_info.is_directory) {
error_callback.Run(base::File::FILE_ERROR_NOT_A_FILE);
} else {
- uint32 file_id;
+ uint32_t file_id;
if (CachedPathToId(file_path, &file_id))
RunDeleteObjectOnUIThread(file_path, file_id, success_callback,
error_callback);
@@ -1156,7 +1159,7 @@ void MTPDeviceDelegateImplLinux::DeleteDirectoryInternal(
return;
}
- uint32 directory_id;
+ uint32_t directory_id;
if (!CachedPathToId(file_path, &directory_id)) {
error_callback.Run(base::File::FILE_ERROR_NOT_FOUND);
return;
@@ -1234,7 +1237,7 @@ void MTPDeviceDelegateImplLinux::OnDidReadDirectoryToCreateDirectory(
void MTPDeviceDelegateImplLinux::OnDidReadDirectoryToDeleteDirectory(
const base::FilePath& directory_path,
- const uint32 directory_id,
+ const uint32_t directory_id,
const DeleteDirectorySuccessCallback& success_callback,
const ErrorCallback& error_callback,
const MTPDeviceTaskHelper::MTPEntries& entries,
@@ -1254,7 +1257,7 @@ void MTPDeviceDelegateImplLinux::OnDidReadDirectoryToDeleteDirectory(
void MTPDeviceDelegateImplLinux::RunDeleteObjectOnUIThread(
const base::FilePath& object_path,
- const uint32 object_id,
+ const uint32_t object_id,
const DeleteObjectSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
const MTPDeviceTaskHelper::DeleteObjectSuccessCallback
@@ -1406,7 +1409,7 @@ void MTPDeviceDelegateImplLinux::OnPathDoesNotExistForCreateSingleDirectory(
return;
}
- uint32 parent_id;
+ uint32_t parent_id;
if (!CachedPathToId(directory_path.DirName(), &parent_id)) {
error_callback.Run(base::File::FILE_ERROR_NOT_FOUND);
return;
@@ -1428,7 +1431,7 @@ void MTPDeviceDelegateImplLinux::OnPathDoesNotExistForCreateSingleDirectory(
}
void MTPDeviceDelegateImplLinux::OnDidGetFileInfoToReadDirectory(
- uint32 dir_id,
+ uint32_t dir_id,
const ReadDirectorySuccessCallback& success_callback,
const ErrorCallback& error_callback,
const base::File::Info& file_info) {
@@ -1462,7 +1465,8 @@ void MTPDeviceDelegateImplLinux::OnDidGetFileInfoToCreateSnapshotFile(
base::File::Error error = base::File::FILE_OK;
if (file_info.is_directory)
error = base::File::FILE_ERROR_NOT_A_FILE;
- else if (file_info.size < 0 || file_info.size > kuint32max)
+ else if (file_info.size < 0 ||
+ file_info.size > std::numeric_limits<uint32_t>::max())
error = base::File::FILE_ERROR_FAILED;
if (error != base::File::FILE_OK)
@@ -1560,7 +1564,7 @@ void MTPDeviceDelegateImplLinux::OnCreateParentDirectoryErrorToCreateDirectory(
}
void MTPDeviceDelegateImplLinux::OnDidReadDirectory(
- uint32 dir_id,
+ uint32_t dir_id,
const ReadDirectorySuccessCallback& success_callback,
const MTPDeviceTaskHelper::MTPEntries& mtp_entries,
bool has_more) {
@@ -1717,7 +1721,7 @@ void MTPDeviceDelegateImplLinux::OnDidCopyFileFromLocalOfCopyFileLocal(
void MTPDeviceDelegateImplLinux::OnDidMoveFileLocalWithRename(
const MoveFileLocalSuccessCallback& success_callback,
const base::FilePath& source_file_path,
- const uint32 file_id) {
+ const uint32_t file_id) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
EvictCachedPathToId(file_id);
@@ -1775,7 +1779,7 @@ void MTPDeviceDelegateImplLinux::HandleCopyFileFromLocalError(
void MTPDeviceDelegateImplLinux::OnDidDeleteObject(
const base::FilePath& object_path,
- const uint32 object_id,
+ const uint32_t object_id,
const DeleteObjectSuccessCallback success_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
@@ -1798,7 +1802,7 @@ void MTPDeviceDelegateImplLinux::HandleDeleteFileOrDirectoryError(
void MTPDeviceDelegateImplLinux::HandleDeviceFileError(
const ErrorCallback& error_callback,
- uint32 file_id,
+ uint32_t file_id,
base::File::Error error) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
@@ -1855,9 +1859,8 @@ void MTPDeviceDelegateImplLinux::FillFileCache(
ReadDirectoryInternal(uncached_path, success_callback, error_callback);
}
-
bool MTPDeviceDelegateImplLinux::CachedPathToId(const base::FilePath& path,
- uint32* id) const {
+ uint32_t* id) const {
DCHECK(id);
std::string device_relpath = GetDeviceRelativePath(device_path_, path);
@@ -1878,7 +1881,7 @@ bool MTPDeviceDelegateImplLinux::CachedPathToId(const base::FilePath& path,
return true;
}
-void MTPDeviceDelegateImplLinux::EvictCachedPathToId(const uint32 id) {
+void MTPDeviceDelegateImplLinux::EvictCachedPathToId(const uint32_t id) {
FileIdToMTPFileNodeMap::iterator it = file_id_to_node_map_.find(id);
if (it != file_id_to_node_map_.end()) {
DCHECK(!it->second->HasChildren());

Powered by Google App Engine
This is Rietveld 408576698