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

Side by Side Diff: content/common/gpu/gpu_messages.cc

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase over crrev.com/1645873002 Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
11 #include "content/common/gpu/gpu_messages.h" 11 #include "content/common/gpu/gpu_messages.h"
12 12
13 namespace IPC { 13 namespace IPC {
14 14
15 void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m, 15 void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m,
16 const param_type& p) { 16 const param_type& p) {
17 WriteParam(m, p.id()); 17 WriteParam(m, p.id());
18 WriteParam(m, static_cast<uint64_t>(p.size())); 18 WriteParam(m, static_cast<uint64_t>(p.size()));
19 WriteParam(m, static_cast<int64_t>(p.offset()));
dcheng 2016/03/01 01:48:43 Does it make sense to DCHECK() that this is non-ne
Owen Lin 2016/03/02 02:50:52 I agree with Pawel that "MapAt() will fail us if t
dcheng 2016/03/02 05:58:20 It's not in the contract of SharedMemory::MapAt(),
19 WriteParam(m, p.presentation_timestamp()); 20 WriteParam(m, p.presentation_timestamp());
20 WriteParam(m, p.key_id()); 21 WriteParam(m, p.key_id());
21 if (!p.key_id().empty()) { 22 if (!p.key_id().empty()) {
22 WriteParam(m, p.iv()); 23 WriteParam(m, p.iv());
23 WriteParam(m, p.subsamples()); 24 WriteParam(m, p.subsamples());
24 } 25 }
25 WriteParam(m, p.handle()); 26 WriteParam(m, p.handle());
26 } 27 }
27 28
28 bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m, 29 bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m,
29 base::PickleIterator* iter, 30 base::PickleIterator* iter,
30 param_type* r) { 31 param_type* r) {
31 DCHECK(r); 32 DCHECK(r);
32 uint64_t size = 0; 33 uint64_t size = 0;
34 int64_t offset = 0;
33 if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &size) && 35 if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &size) &&
36 ReadParam(m, iter, &offset) &&
34 ReadParam(m, iter, &r->presentation_timestamp_) && 37 ReadParam(m, iter, &r->presentation_timestamp_) &&
35 ReadParam(m, iter, &r->key_id_))) 38 ReadParam(m, iter, &r->key_id_)))
36 return false; 39 return false;
37 40
38 base::CheckedNumeric<size_t> checked_size(size); 41 base::CheckedNumeric<size_t> checked_size(size);
39 if (!checked_size.IsValid()) { 42 if (!checked_size.IsValid()) {
40 DLOG(ERROR) << "Invalid size: " << size; 43 DLOG(ERROR) << "Invalid size: " << size;
41 return false; 44 return false;
42 } 45 }
43 r->size_ = checked_size.ValueOrDie(); 46 r->size_ = checked_size.ValueOrDie();
44 47
48 base::CheckedNumeric<off_t> checked_offset(offset);
49 if (!checked_offset.IsValid()) {
dcheng 2016/03/01 01:48:43 Similarly, does it make sense to assert that the v
Owen Lin 2016/03/02 02:50:52 See above.
50 DLOG(ERROR) << "Invalid offset: " << offset;
51 return false;
52 }
53 r->offset_ = checked_offset.ValueOrDie();
54
45 if (!r->key_id_.empty()) { 55 if (!r->key_id_.empty()) {
46 if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_))) 56 if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_)))
47 return false; 57 return false;
48 } 58 }
49 59
50 return ReadParam(m, iter, &r->handle_); 60 return ReadParam(m, iter, &r->handle_);
51 } 61 }
52 62
53 void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p, 63 void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p,
54 std::string* l) { 64 std::string* l) {
55 std::ostringstream oss; 65 std::ostringstream oss;
56 oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp=" 66 oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp="
57 << p.presentation_timestamp().ToInternalValue(); 67 << p.presentation_timestamp().ToInternalValue();
58 l->append(oss.str()); 68 l->append(oss.str());
59 } 69 }
60 70
61 } // namespace IPC 71 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698