diff options
author | brettw <brettw@chromium.org> | 2015-07-06 16:53:00 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-06 23:54:14 +0000 |
commit | 8cc24ae2b51f9db4a16011eb1ab7dbfca0eb6d54 (patch) | |
tree | 876a4d239206096f180630fc3657a1aa58a74630 /media/ffmpeg | |
parent | f359166a9a5dc5c4ea15b0b718b643fc06d3c870 (diff) | |
download | chromium_src-8cc24ae2b51f9db4a16011eb1ab7dbfca0eb6d54.zip chromium_src-8cc24ae2b51f9db4a16011eb1ab7dbfca0eb6d54.tar.gz chromium_src-8cc24ae2b51f9db4a16011eb1ab7dbfca0eb6d54.tar.bz2 |
Replace remaining Tokenize calls to SplitString
SplitString is now more general and does the job of Tokenize with specific parameters.
The biggest change is in time_util.cc where the old return pattern better matched how the code was structured. With the new style the conditionals are more nested.
Some simple cases were changed to StringPieces when copies were not required.
BUG=506920, 506255
Review URL: https://codereview.chromium.org/1219263002
Cr-Commit-Position: refs/heads/master@{#337520}
Diffstat (limited to 'media/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.cc | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc index 25f6ed4..cb806c7 100644 --- a/media/ffmpeg/ffmpeg_common.cc +++ b/media/ffmpeg/ffmpeg_common.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "media/base/decoder_buffer.h" #include "media/base/video_util.h" @@ -563,23 +564,30 @@ PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { return PIX_FMT_NONE; } -bool FFmpegUTCDateToTime(const char* date_utc, - base::Time* out) { +bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out) { DCHECK(date_utc); DCHECK(out); - std::vector<std::string> fields; - std::vector<std::string> date_fields; - std::vector<std::string> time_fields; - base::Time::Exploded exploded; - exploded.millisecond = 0; + std::vector<base::StringPiece> fields = base::SplitStringPiece( + date_utc, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + if (fields.size() != 2) + return false; + + std::vector<base::StringPiece> date_fields = base::SplitStringPiece( + fields[0], "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + if (date_fields.size() != 3) + return false; // TODO(acolwell): Update this parsing code when FFmpeg returns sub-second // information. - if ((Tokenize(date_utc, " ", &fields) == 2) && - (Tokenize(fields[0], "-", &date_fields) == 3) && - (Tokenize(fields[1], ":", &time_fields) == 3) && - base::StringToInt(date_fields[0], &exploded.year) && + std::vector<base::StringPiece> time_fields = base::SplitStringPiece( + fields[1], ":", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + if (time_fields.size() != 3) + return false; + + base::Time::Exploded exploded; + exploded.millisecond = 0; + if (base::StringToInt(date_fields[0], &exploded.year) && base::StringToInt(date_fields[1], &exploded.month) && base::StringToInt(date_fields[2], &exploded.day_of_month) && base::StringToInt(time_fields[0], &exploded.hour) && |