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

Side by Side Diff: media/filters/file_data_source.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/filters/file_data_source.h" 5 #include "media/filters/file_data_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 bool FileDataSource::Initialize(const base::FilePath& file_path) { 26 bool FileDataSource::Initialize(const base::FilePath& file_path) {
27 DCHECK(!file_.IsValid()); 27 DCHECK(!file_.IsValid());
28 return file_.Initialize(file_path); 28 return file_.Initialize(file_path);
29 } 29 }
30 30
31 void FileDataSource::Stop() { 31 void FileDataSource::Stop() {
32 } 32 }
33 33
34 void FileDataSource::Read(int64 position, int size, uint8* data, 34 void FileDataSource::Read(int64_t position,
35 int size,
36 uint8_t* data,
35 const DataSource::ReadCB& read_cb) { 37 const DataSource::ReadCB& read_cb) {
36 if (force_read_errors_ || !file_.IsValid()) { 38 if (force_read_errors_ || !file_.IsValid()) {
37 read_cb.Run(kReadError); 39 read_cb.Run(kReadError);
38 return; 40 return;
39 } 41 }
40 42
41 int64 file_size = file_.length(); 43 int64_t file_size = file_.length();
42 44
43 CHECK_GE(file_size, 0); 45 CHECK_GE(file_size, 0);
44 CHECK_GE(position, 0); 46 CHECK_GE(position, 0);
45 CHECK_GE(size, 0); 47 CHECK_GE(size, 0);
46 48
47 // Cap position and size within bounds. 49 // Cap position and size within bounds.
48 position = std::min(position, file_size); 50 position = std::min(position, file_size);
49 int64 clamped_size = std::min(static_cast<int64>(size), file_size - position); 51 int64_t clamped_size =
52 std::min(static_cast<int64_t>(size), file_size - position);
50 53
51 memcpy(data, file_.data() + position, clamped_size); 54 memcpy(data, file_.data() + position, clamped_size);
52 bytes_read_ += clamped_size; 55 bytes_read_ += clamped_size;
53 read_cb.Run(clamped_size); 56 read_cb.Run(clamped_size);
54 } 57 }
55 58
56 bool FileDataSource::GetSize(int64* size_out) { 59 bool FileDataSource::GetSize(int64_t* size_out) {
57 *size_out = file_.length(); 60 *size_out = file_.length();
58 return true; 61 return true;
59 } 62 }
60 63
61 bool FileDataSource::IsStreaming() { 64 bool FileDataSource::IsStreaming() {
62 return force_streaming_; 65 return force_streaming_;
63 } 66 }
64 67
65 void FileDataSource::SetBitrate(int bitrate) {} 68 void FileDataSource::SetBitrate(int bitrate) {}
66 69
67 FileDataSource::~FileDataSource() {} 70 FileDataSource::~FileDataSource() {}
68 71
69 } // namespace media 72 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698