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

Side by Side Diff: chrome/utility/media_galleries/iapps_xml_utils.cc

Issue 252683006: Remove ClosePlatformFile from media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/utility/media_galleries/iapps_xml_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/utility/media_galleries/iapps_xml_utils.h" 5 #include "chrome/utility/media_galleries/iapps_xml_utils.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "third_party/libxml/chromium/libxml_utils.h" 10 #include "third_party/libxml/chromium/libxml_utils.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return ReadSimpleValue(reader, "string", result); 70 return ReadSimpleValue(reader, "string", result);
71 } 71 }
72 72
73 bool ReadInteger(XmlReader* reader, uint64* result) { 73 bool ReadInteger(XmlReader* reader, uint64* result) {
74 std::string value; 74 std::string value;
75 if (!ReadSimpleValue(reader, "integer", &value)) 75 if (!ReadSimpleValue(reader, "integer", &value))
76 return false; 76 return false;
77 return base::StringToUint64(value, result); 77 return base::StringToUint64(value, result);
78 } 78 }
79 79
80 std::string ReadPlatformFileAsString(const base::PlatformFile file) { 80 std::string ReadFileAsString(base::File file) {
81 std::string result; 81 std::string result;
82 if (file == base::kInvalidPlatformFileValue) 82 if (!file.IsValid())
83 return result; 83 return result;
84 84
85 // A "reasonable" artificial limit. 85 // A "reasonable" artificial limit.
86 // TODO(vandebo): Add a UMA to figure out what common values are. 86 // TODO(vandebo): Add a UMA to figure out what common values are.
87 const int64 kMaxLibraryFileSize = 150 * 1024 * 1024; 87 const int64 kMaxLibraryFileSize = 150 * 1024 * 1024;
88 base::PlatformFileInfo file_info; 88 base::File::Info file_info;
89 if (!base::GetPlatformFileInfo(file, &file_info) || 89 if (!file.GetInfo(&file_info) || file_info.size > kMaxLibraryFileSize)
Lei Zhang 2014/04/28 19:47:00 nit: only 1 space after ||
rvargas (doing something else) 2014/04/28 19:53:15 Done.
90 file_info.size > kMaxLibraryFileSize) {
91 base::ClosePlatformFile(file);
92 return result; 90 return result;
93 }
94 91
95 result.resize(file_info.size); 92 result.resize(file_info.size);
96 int bytes_read = 93 int bytes_read = file.Read(0, string_as_array(&result), file_info.size);
97 base::ReadPlatformFile(file, 0, string_as_array(&result), file_info.size);
98 if (bytes_read != file_info.size) 94 if (bytes_read != file_info.size)
99 result.clear(); 95 result.clear();
100 96
101 base::ClosePlatformFile(file);
102 return result; 97 return result;
103 } 98 }
104 99
105 } // namespace iapps 100 } // namespace iapps
OLDNEW
« no previous file with comments | « chrome/utility/media_galleries/iapps_xml_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698