summaryrefslogtreecommitdiffstats
path: root/media/base/test_data_util.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 23:15:17 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 23:15:17 +0000
commit948991f3093cd31fc5757a9f32ec8a6a057a3d82 (patch)
tree9d37b8313cd70b9ed20a32f665e74fbbadddf19f /media/base/test_data_util.cc
parentc47c03736dd5f52be91b5fe10e08a35c27249ac8 (diff)
downloadchromium_src-948991f3093cd31fc5757a9f32ec8a6a057a3d82.zip
chromium_src-948991f3093cd31fc5757a9f32ec8a6a057a3d82.tar.gz
chromium_src-948991f3093cd31fc5757a9f32ec8a6a057a3d82.tar.bz2
Cleanup: Simplify media::ReadTestDataFile() and do some more checks.
Review URL: https://codereview.chromium.org/168543005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/test_data_util.cc')
-rw-r--r--media/base/test_data_util.cc16
1 files changed, 6 insertions, 10 deletions
diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc
index 386617e..a83fa84 100644
--- a/media/base/test_data_util.cc
+++ b/media/base/test_data_util.cc
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "media/base/decoder_buffer.h"
@@ -15,25 +16,20 @@ base::FilePath GetTestDataFilePath(const std::string& name) {
base::FilePath file_path;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
- file_path = file_path.Append(FILE_PATH_LITERAL("media"))
- .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data"))
+ return file_path.AppendASCII("media")
+ .AppendASCII("test")
+ .AppendASCII("data")
.AppendASCII(name);
- return file_path;
}
scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
- base::FilePath file_path;
- CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
-
- file_path = file_path.Append(FILE_PATH_LITERAL("media"))
- .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data"))
- .AppendASCII(name);
+ base::FilePath file_path = GetTestDataFilePath(name);
int64 tmp = 0;
CHECK(base::GetFileSize(file_path, &tmp))
<< "Failed to get file size for '" << name << "'";
- int file_size = static_cast<int>(tmp);
+ int file_size = base::checked_cast<int>(tmp);
scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size));
CHECK_EQ(file_size,