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

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

Issue 1645873002: Use ParamTraits for media::BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiling errors on mac and address review comments 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/gpu/gpu_messages.h"
6
7 namespace IPC {
8
9 void ParamTraits<media::BitstreamBuffer>::Write(base::Pickle* m,
10 const param_type& p) {
11 DCHECK_GE(p.id(), 0);
12 DCHECK(base::SharedMemory::IsHandleValid(p.handle()));
13
14 WriteParam(m, p.id());
15 WriteParam(m, static_cast<uint64_t>(p.size()));
16 WriteParam(m, p.presentation_timestamp());
17 WriteParam(m, p.key_id());
18 if (!p.key_id().empty()) {
19 WriteParam(m, p.iv());
20 WriteParam(m, p.subsamples());
21 }
22 WriteParam(m, p.handle());
23 }
24
25 bool ParamTraits<media::BitstreamBuffer>::Read(const base::Pickle* m,
26 base::PickleIterator* iter,
27 param_type* r) {
28 DCHECK(r);
29 uint64_t size = 0;
30 if (!(ReadParam(m, iter, &r->id_) && ReadParam(m, iter, &size) &&
31 ReadParam(m, iter, &r->presentation_timestamp_) &&
32 ReadParam(m, iter, &r->key_id_)))
33 return false;
34
35 if (!base::IsValueInRangeForNumericType<size_t>(size)) {
dcheng 2016/02/18 21:06:09 #include <stddef.h> Also, I think it would be sli
Owen Lin 2016/02/23 03:40:11 Done.
36 LOG(ERROR) << "Invalid size: " << size;
dcheng 2016/02/18 21:06:09 #include "base/logging.h" Also, let's make this (
Owen Lin 2016/02/23 03:40:11 Done.
37 return false;
38 }
39 r->size_ = static_cast<size_t>(size);
40
41 if (r->id_ < 0) {
42 LOG(ERROR) << "Invalid id: " << r->id_;
43 return false;
44 }
45 if (!r->key_id_.empty()) {
46 if (!(ReadParam(m, iter, &r->iv_) && ReadParam(m, iter, &r->subsamples_)))
47 return false;
48 }
49 if (!(ReadParam(m, iter, &r->handle_) &&
50 base::SharedMemory::IsHandleValid(r->handle_))) {
51 LOG(ERROR) << "fail to read valid handle.";
52 return false;
53 }
54 return true;
55 }
56
57 void ParamTraits<media::BitstreamBuffer>::Log(const param_type& p,
58 std::string* l) {
59 std::ostringstream oss;
dcheng 2016/02/18 21:06:09 #include <sstream>
Owen Lin 2016/02/23 03:40:11 Done.
60 oss << "id=" << p.id() << ", size=" << p.size() << ", presentation_timestamp="
61 << p.presentation_timestamp().ToInternalValue();
62 l->append(oss.str());
63 }
64
65 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698