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

Side by Side Diff: ppapi/proxy/file_ref_resource.cc

Issue 915403003: Enable size_t to int truncation warnings in PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ppapi_unittests win x64 Created 5 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ppapi/proxy/file_ref_resource.h" 5 #include "ppapi/proxy/file_ref_resource.h"
6 6
7 #include "base/numerics/safe_conversions.h"
7 #include "ppapi/c/pp_directory_entry.h" 8 #include "ppapi/c/pp_directory_entry.h"
8 #include "ppapi/c/pp_instance.h" 9 #include "ppapi/c/pp_instance.h"
9 #include "ppapi/c/pp_resource.h" 10 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/proxy/ppapi_messages.h" 11 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/array_writer.h" 12 #include "ppapi/shared_impl/array_writer.h"
12 #include "ppapi/shared_impl/file_ref_util.h" 13 #include "ppapi/shared_impl/file_ref_util.h"
13 #include "ppapi/shared_impl/resource.h" 14 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/shared_impl/resource_tracker.h" 15 #include "ppapi/shared_impl/resource_tracker.h"
15 #include "ppapi/shared_impl/var.h" 16 #include "ppapi/shared_impl/var.h"
16 #include "ppapi/thunk/enter.h" 17 #include "ppapi/thunk/enter.h"
17 #include "ppapi/thunk/ppb_file_system_api.h" 18 #include "ppapi/thunk/ppb_file_system_api.h"
18 19
19 namespace ppapi { 20 namespace ppapi {
20 namespace proxy { 21 namespace proxy {
21 22
22 FileRefResource::FileRefResource( 23 FileRefResource::FileRefResource(
23 Connection connection, 24 Connection connection,
24 PP_Instance instance, 25 PP_Instance instance,
25 const FileRefCreateInfo& create_info) 26 const FileRefCreateInfo& create_info)
26 : PluginResource(connection, instance), 27 : PluginResource(connection, instance),
27 create_info_(create_info), 28 create_info_(create_info),
28 file_system_resource_(create_info.file_system_plugin_resource) { 29 file_system_resource_(create_info.file_system_plugin_resource) {
29 if (uses_internal_paths()) { 30 if (uses_internal_paths()) {
30 // If path ends with a slash, then normalize it away unless path is 31 // If path ends with a slash, then normalize it away unless path is
31 // the root path. 32 // the root path.
32 int path_size = create_info_.internal_path.size(); 33 int path_size = base::checked_cast<int>(create_info_.internal_path.size());
33 if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/') 34 if (path_size > 1 && create_info_.internal_path.at(path_size - 1) == '/')
34 create_info_.internal_path.erase(path_size - 1, 1); 35 create_info_.internal_path.erase(path_size - 1, 1);
35 36
36 path_var_ = new StringVar(create_info_.internal_path); 37 path_var_ = new StringVar(create_info_.internal_path);
37 create_info_.display_name = GetNameForInternalFilePath( 38 create_info_.display_name = GetNameForInternalFilePath(
38 create_info_.internal_path); 39 create_info_.internal_path);
39 } else { 40 } else {
40 DCHECK(!create_info_.display_name.empty()); 41 DCHECK(!create_info_.display_name.empty());
41 } 42 }
42 name_var_ = new StringVar(create_info_.display_name); 43 name_var_ = new StringVar(create_info_.display_name);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 callback->Run(params.result()); 259 callback->Run(params.result());
259 } 260 }
260 261
261 bool FileRefResource::uses_internal_paths() const { 262 bool FileRefResource::uses_internal_paths() const {
262 return (create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL) || 263 return (create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL) ||
263 !create_info_.internal_path.empty(); 264 !create_info_.internal_path.empty();
264 } 265 }
265 266
266 } // namespace proxy 267 } // namespace proxy
267 } // namespace ppapi 268 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/device_enumeration_resource_helper.cc ('k') | ppapi/proxy/flash_clipboard_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698